5 ms·
Takes: Java web framework without static methods or annotations
- saagarjha 7y ago> Not a single public static method main?
- chrisjc 7y agoI think this is the doesn't-need-to-be-said exception.
- deleted 7y ago[deleted]
- clhodapp 7y agoIt looks like the framework user or the servlet engine provides the main method.
- klez 7y agoI think it's safe to assume "no public static interface to the framework". The rest are hidden implementation details. It's like saying that a program in Java can be completely object oriented. Of course it can't because the innards still contain pieces of procedural code and they still use primitives which may not be actual instances of objects. What counts is how it presents itself on the outside.
- mdaniel 7y agoUnknown if this framework adheres to it, but the JavaEE standard allows one to deploy apps that don't contain a main method, and in fact can run in a security restricted environment that prohibits reading properties, environment variables, and a lot more. So that's a long way of saying that if it doesn't need a main method unless they're trying to deploy their own webserver, too
- lalaithion 7y agoI write very annotation/static method heavy Java at work, and I write Haskell for fun at home, and my kneejerk reaction to seeing this code in the "Why are static methods bad" link: void transform(File in, File out) { Collection<String> src = new Trimmed( new FileLines(new UnicodeFile(in)) ); Collection<String> dest = new FileLines( new UnicodeFile(out) ); dest.addAll(src); } was "That looks just like Haskell".
- LoSboccacc 7y agoand from that link > public class Max implements Number uhm
- Xorlev 7y agoNot trying to knock the work, but why is no static methods a selling point? How does one do utility classes instead? And do you eschew static factory methods entirely?
- vbezhenar 7y agoYegor has quite orthodox view on Java development. You might want to read his blog to get better understanding on his position. While I don't agree with many of his points, it's a very interesting and refreshing perspective that is useful to learn IMO.
- saagarjha 7y agoUnorthodox?
- Jach 7y ago"Native"? "At home"? "Happy Commoner in the Kingdom of Nouns[0]"? Or stockholm syndrome... I kind of get on "no static methods! 'util' and 'helper' are smells!" bends myself from time to time in order to make designs clearer and unit testing somewhat saner (because the even more sane approach of writing or refactoring to smaller pure functions and keeping them that way is too much to ask for sometimes) but it's all just because I spend too much time working in an insane language with a broken idea of what OOP is. Still, I appreciate write-ups like the author's, and at least he's right about immutability being good in general. [0] http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom...
- jayd16 7y agoI think orthodox works here as its a more strict reading of the "everything is an object" dogma.
- Xorlev 7y agoI didn't know the context, so thanks! I'll take a look. :)
- deleted 7y ago
- gerbilly 7y agoOk, so we know the framework does not contain all these supposedly bad things¹, but what does the framework do exactly? 1: Reminds me of Golang, which likes to define itself as a set of 'negative liberties' (No exceptions, no inheritance, no polymorphism, no ...).
- tetha 7y agoI was reminded of golang as well. I kind of like this framework, because I dislike the overly magic dispatch mechanisms of annotation-driven java. Basic request dispatching in golang can look and be clunky, but that one clunky place tells you where to look.
- yegor256a 7y agoIt is a web framework. It helps you create a web app. Similar to what other frameworks do, like Spring, Spark, Play, Struts, etc.
- jbverschoor 7y agoSo instead of static, you’re using fixed classes. No difference there. What’s next, a classfactory? One inner platform effect coming up! It’s a good exercise though!
- saagarjha 7y agoI was reading through one of the linked articles of why the author doesn't like using null or static objects: https://www.yegor256.com/2014/05/13/why-null-is-bad.html https://www.yegor256.com/2014/05/13/why-null-is-bad.html https://www.yegor256.com/2014/05/05/oop-alternative-to-utility-classes.html https://www.yegor256.com/2014/05/05/oop-alternative-to-utili... Apparently he replaces null with null objects or throwing exceptions, and creates objects for every static method. Go figure. Actually, there are a few gems: > The Map interface (no offense to its authors) has a design flaw. > It is a good practice to make your code as fragile as possible, letting it break when necessary. > The method is basically asking the object about its… race. Black objects go right while white objects go left. That’s what this instanceof is doing, and that’s what discrimination is all about.
- this_user 7y ago> Apparently he replaces null with null objects That's what Optional was introduced for in Java 8. If you want to be absolutely null-safe, using it makes sense. But if you want to optimise performance, going with the slightly more risky route is still the better choice.
- killface 7y agoPassing optional objects as method params is bad. The trouble is that an Optional<T> can still be null itself.
- kjeetgill 7y agoThat's not really "why" it was introduced. Optional is used as a null wrapper in other JVM languages so that idiom bled over pretty naturally. Here's a talk "Optional - Mother of all Bikesheds" by Stuart Marks, the guy who added it to OpenJDK: https://m.youtube.com/watch?v=Ej0sss6cq14 https://m.youtube.com/watch?v=Ej0sss6cq14 It was mostly just meant to cover the zero or one case on fluent-style interfaces like the Streams API, so check as getFirst() or getAny(). In hindsight, the name Optional was a poor choice if they didn't want the idiom coming over.
- kasperni 7y agoSo from the OOP Alternative to Utility Classes on the site int max = new Max(10, 5).intValue(); over int max = Math.max(10, 5) Yeah, think I am going to pass.
- jforberg 7y agoGotta get rid of all those nasty pure functions. Can't have any of that cruft in muh object oriented language.
- smt88 7y agoConstructing an immutable object/value isn't any different than a pure function that outputs that object/value. The difference is just syntax. That said, I don't know if this library uses the practice of immutable-only objects.
- fwilhe 7y agoI don't understand why the names are so bad. FtFoo, TkBar, XyBaz. Not pronounceable, meaning not inferable. I like Yegor's stuff mostly, but the naming just kills me.
- ribtoks 7y agoGiven style of the code, what Yegor needs is Lisp, but not OOP.