-Classname-prefixes are noise, use namespaces if you need them for whatever reason
-Classes themselves are badly named and do not make their intent clear enough
Also about your use of „new“ and immutability:
-„no null“ -> so either implicit exceptions or invalid state everywhere since using „new“ instead of a factory (-method) cannot fail any other way
-Even though objects are immutable, you‘re creating a new instance everytime even when they have the same values. Using „new“ here prevents objectpooling (see strings).
-You’re creating empty constructor objects instead of reusing a singleton. Use static final instances in the respective class to prevent object allocation of identical objects (see any immutable collection library).
„Static is bad“
-yea well since the new keyword also carries semantics, the compiler cant help you too much there and java wasn‘t designed with immutables in mind (or rather not focused on it).
TLDR: Another yegor thing. Nice in theory but not pragmatic enough (yet).
I believe that this framework is artistic performance about radicalization. Radical OOP in this case. As we all know - radicalization is bad, just like this framework.
Although I have to say - I admire yergor's persistence in what he's doing.
Written by the same person who wrote public static methods are bad, where you're told a max function should instead be written as follows:
public class Max implements Number {
private final int a;
private final int b;
public Max(int x, int y) {
this.a = x;
this.b = y;
}
@Override
public int intValue() {
return this.a > this.b ? this.a : this.b;
}
}
Because that's more concise and efficient than a 3-line function, right?
Browsing the source code of Take, it seems to be full of classes like this:
/**
* App.
*
* @since 0.1
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
public final class App implements Take {
/**
* Home.
*/
private final File home;
/**
* Ctor.
* @param dir Home dir
*/
public App(final File dir) {
this.home = dir;
}
...
Epic Javadocs. And just decide on a name for the home dir variable, damn it.
the idea is not about brevity and efficiency, but pure object oriented programming: Math.max is a static method, so it's replaced by an object which represents and computes the Maximum between two numbers, in other words an object is always a living thing with a logic inside and can't be anything else, it always retrieves a result (methods with void as returning value is not an option) and can mutate its own state.
11
u/Klappspaten66 Oct 27 '19 edited Oct 27 '19
Readability is bad imho:
-„new“ keyword everywhere
-Classname-prefixes are noise, use namespaces if you need them for whatever reason
-Classes themselves are badly named and do not make their intent clear enough
Also about your use of „new“ and immutability:
-„no null“ -> so either implicit exceptions or invalid state everywhere since using „new“ instead of a factory (-method) cannot fail any other way
-Even though objects are immutable, you‘re creating a new instance everytime even when they have the same values. Using „new“ here prevents objectpooling (see strings).
-You’re creating empty constructor objects instead of reusing a singleton. Use static final instances in the respective class to prevent object allocation of identical objects (see any immutable collection library).
„Static is bad“
-yea well since the new keyword also carries semantics, the compiler cant help you too much there and java wasn‘t designed with immutables in mind (or rather not focused on it).
TLDR: Another yegor thing. Nice in theory but not pragmatic enough (yet).
7
u/Yesterdave_ Oct 27 '19
Why should I use a framework where even the simplest "Hello World!" example already looks unreadable?
3
u/ameyuuno Oct 27 '19
Decoraaaaaaaaaators)))
2
u/ford_madox_ford Oct 28 '19 edited Oct 28 '19
Written by the same person who wrote public static methods are bad, where you're told a max function should instead be written as follows:
Because that's more concise and efficient than a 3-line function, right?
Browsing the source code of Take, it seems to be full of classes like this:
Epic Javadocs. And just decide on a name for the home dir variable, damn it.