10 ms·
"Having hard-coded class-names like in the example Time.now is effectively the same as communicating via global variables." But having DI is exactly that: DI i
by martinced 14y ago
"Having hard-coded class-names like in the example Time.now is effectively the same as communicating via global variables."
But having DI is exactly that: DI is about glorified global variables!
I realize most HN participants living in the Java/C# + ORM ([N]Hibernate)) + XML + SQL hell are just loving DI because it's a tad bit less worse then global variables but, dudes, there's another world out there.
A lot of functions can be made idempotent (always returning the same output for a given set of inputs) and also pure (idempotent and without any side-effect) and this facilitates everything: it gets much easier to "recreate the state" and it makes it easier to reason about your programs.
It's sad because HN is a community built by pg, who talked about "beating the average", about using Lisp dialects, about Emacs, etc.
I took all his writing as "thinking outside the box".
And what do I see here? I see that HN is mostly consisting of enterprisey programmers living in the Java/C# + ORM + XML + SQL hell and not even realizing there's another world out there.
It is sadening me.
- laureny 14y ago> A lot of functions can be made idempotent Idempotency is completely orthogonal to the problem of functions accepting parameters that are a mix of live parameters and ones that can be injected at start up.
- brown9-2 14y agoDI is about glorified global variables! Can you expand on what you mean by this?
- _ikke_ 14y agoDI is not about glorified globals at all. Nothing forces you to pass in the same object to all things dependend on it. It just allows you to pass in anything the situation requires. It allows your code to depend on an interface, instead of an implementation, even if the language doesn't have explicit interfaces.
- mpweiher 14y agoDid you bother to read about Newspeak or click on the links? Did you see the part about Java "AbstractAbstractFactory" actually being very close to "worse" than global variables? http://newspeaklanguage.org http://newspeaklanguage.org But apparently clicking on links is too hard, so I'll quote inline: "Newspeak is a new programming language in the tradition of Self and Smalltalk. Newspeak is highly dynamic and reflective – but designed to support modularity and security. It supports both object-oriented and functional programming. Like Self, Newspeak is message-based; all names are dynamically bound. However, like Smalltalk, Newspeak uses classes rather than prototypes. As in Beta, classes may nest. Because class names are late bound, all classes are virtual, every class can act as a mixin, and class hierarchy inheritance falls out automatically. Top level classes are essentially self contained parametric namespaces, and serve to define component style modules, which naturally define sandboxes in an object-capability style. Newspeak was deliberately designed as a principled dynamically typed language. We plan to evolve the language to support pluggable types." Sheesh. Update: I know the creators of Newspeak, but am not affiliated in any way.