Timeline for Is the use of ***Helper or *** Util classes containing just static methods an AntiPattern
Current License: CC BY-SA 4.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 20, 2018 at 9:01 | comment | added | Deduplicator | @TimothyTruckle Only depending on public interfaces is weak coupling: The internals are free to change. Dependency-injection is a tool for special cases, not to be abused and overused, as it increases complexity and (generally) reduces efficiency. | |
Jul 20, 2018 at 8:35 | comment | added | Timothy Truckle | @JimmyJames " Tight coupling in this context would imply some sort of inter-dependency. A one-way dependency does not meet that requirement." A "two way dependency" is not tight coupling but a design error. | |
Jul 19, 2018 at 20:31 | comment | added | JimmyJames | @TimothyTruckle That's not tight coupling. You are describing loose coupling. Tight coupling in this context would imply some sort of inter-dependency. A one-way dependency does not meet that requirement. | |
Jul 19, 2018 at 20:16 | comment | added | Timothy Truckle | @JimmyJames: "Calling a stateless static function that knows nothing about it's callers is not tight coupling" Well, you cannot simply exchange the function accessed, so the using code has tight coupling to the static function. | |
Jul 19, 2018 at 20:11 | comment | added | JimmyJames | @TimothyTruckle Use of static methods does not always lead to tight coupling. Calling a stateless static function that knows nothing about it's callers is not tight coupling | |
Jul 19, 2018 at 11:27 | comment | added | Deduplicator | @DavidArno: Made special notice that shared mutable state, especially the global kind, remains evil. | |
Jul 19, 2018 at 11:25 | history | edited | Deduplicator | CC BY-SA 4.0 |
added 129 characters in body
|
Jul 19, 2018 at 10:54 | comment | added | David Arno | @nvoigt, I feel this answer would be greatly improved by explicitly stating that point. Stateful statics are bad; stateless ones are good. Really quite simple. | |
Jul 19, 2018 at 8:48 | comment | added | nvoigt | @TimothyTruckle Absolutely, maintaining state would be the prime reason for being "not good". | |
Jul 19, 2018 at 8:30 | comment | added | Timothy Truckle | @nvoigt "Whether that's good or not is entirely up to what the function in question does." I agree as long as the function does not maintain state (directly or indirectly) | |
Jul 19, 2018 at 8:24 | comment | added | Caleth | @TimothyTruckle you don't have to use static access to access static functions. They can just be instances of a function interface that you pass around | |
Jul 19, 2018 at 8:23 | comment | added | Timothy Truckle | @Caleth ok, I agree. But require something be instantiated appropriately is not something bad in an OO language (free function belong to a Functional language and the tight coupling along with the hidden dependency is still a problem of static access at least in Java. | |
Jul 19, 2018 at 8:22 | comment | added | nvoigt | @TimothyTruckle Because it's Java. Other languages can have free functions without the overhead of having to put them into a class only to declare it not being an instance method. And at some point, you have to have tight coupling. Whether that's good or not is entirely up to what the function in question does. | |
Jul 19, 2018 at 8:18 | comment | added | Caleth |
@TimothyTruckle Either they are static, or they have a superfluous this , and require something be instantiated appropriately
|
|
Jul 19, 2018 at 8:03 | comment | added | Timothy Truckle |
I don't see why "free functions" require to be static . static access always leads to tight coupling which should be avoided.
|
|
Jul 18, 2018 at 21:12 | history | answered | Deduplicator | CC BY-SA 4.0 |