-
-
Save peashutop/309605 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[7:25pm] nkallen_: [7:18pm] nkallen_: but my point is conceptual and not about ruby | |
[7:25pm] nkallen_: [7:18pm] nkallen_: it applies to every oo language and also I might argue to functional languages | |
[7:25pm] nkallen_: [7:18pm] nkallen_: which is to structure a program around the ability to layer on enhanced functionality and ensure that no assumptions are hardcoded by abstracting over the manufacture of objects | |
[7:25pm] nkallen_: [7:19pm] nkallen_: in the literature, these techniques are called DI, decorators, and factories. | |
[7:25pm] nkallen_: [7:20pm] nkallen_: i like these terms because they reflect the concepts that are at work. because ruby might have little ceremony (you don't ever need to name a thing "Factory") doesn't mean the concept of "any object that responds to #new and returns an object that obeys such-and-such ducktype" | |
[7:25pm] nkallen_: [7:20pm] nkallen_: is not a real and useful concept to think about. | |
[7:26pm] wycats_: My concern is about adoption | |
[7:27pm] wycats_: By calling these things ceremony-laden terms we reduce adoption | |
[7:28pm] wycats_: I think the jargon mainly exists because of the complexity in java | |
[7:29pm] nkallen_: to me it's important to synthesize that there is basically one set of tools for making OO code modular, but there are several concrete ways to implement those tools | |
[7:29pm] nkallen_: and the several ways exist not only within a language but across languages | |
[7:29pm] nkallen_: and so speaking conceptually about these is important if one wants to understand the essential unity of these ideas. | |
[7:31pm] wycats_: People dislike java not because of these concepts, but because of the need to have a lot of chrome | |
[7:32pm] nkallen_: many ruby program[mers] write little scripts or write MVC apps. they are unfamiliar with straight up OO software. | |
[7:32pm] wycats_: Agree | |
[7:33pm] nkallen_: so it's unusual to see these techniques in Ruby code despite that they're easy to do in Ruby, easier than Java for sure, and comparable to Scala. | |
[7:33pm] wycats_: See rails 2.3 megafails | |
[7:34pm] nkallen_: to echo your point, the structure of Rails 2.x is unmodular. | |
[7:33pm] nkallen_: you can use inheritance more flexibly in Ruby than in Scala, that is for sure | |
[7:34pm] wycats_: that's the benefit of dynamism | |
[7:34pm] wycats_: Not alias_method_chain | |
[7:34pm] nkallen_: it is unmodular because it does not use sound techniques of modularity. | |
[7:34pm] wycats_: Agree | |
[7:35pm] nkallen_: and a consequence of that is that it is totally unsurprising that gems and plugins break totally at even minor version upgrades | |
[7:35pm] nkallen_: because the "vector of modularity" is alias_method_chain-ing private methods | |
[7:36pm] wycats_: Yeah... And failure to obey LSP once done | |
[7:37pm] nkallen_: i'd like to see examples of lsp violations that you're thinking of | |
[7:38pm] nkallen_: but let's do that some other time. | |
[7:39pm] wycats_: Injection sounds "hard" | |
[7:39pm] wycats_: Not hard difficult | |
[7:39pm] nkallen_: listen wycats: use whatever didactic techniques you want | |
[7:40pm] nkallen_: i'm interested in broad patterns and concepts more than introducing beginner programmers to things they're going to love when they get the hang of them. | |
[7:40pm] wycats_: You misunderstand | |
[7:40pm] wycats_: I don't feel | |
[7:40pm] wycats_: Injections describes it well in ruby | |
[7:40pm] nkallen_: since, in ruby, you can still inject dependencies using several techniques: | |
[7:40pm] wycats_: I'm boring you with my fart applications | |
[7:40pm] nkallen_: def initialize(something_factory); end | |
[7:41pm] nkallen_: def set_something_factory(something_factory); end | |
[7:41pm] nkallen_: and even ... | |
[7:41pm] wycats_: But why are these parameters special | |
[7:41pm] nkallen_: acts_as_something :something_factory => ... | |
[7:41pm] wycats_: Why are they injection vs. Everything else? | |
[7:41pm] nkallen_: no those other things are injection too | |
[7:42pm] nkallen_: if we were programming in Pascal, there'd be only two ways of managing dependencies. | |
[7:42pm] nkallen_: 1. global variables; and 2. parameters to functions | |
[7:42pm] wycats_: puts "hello" <- injection? | |
[7:43pm] nkallen_: passing a parameter is a kind of injecting | |
[7:43pm] nkallen_: does that sound too bullshit? | |
[7:43pm] wycats_: "hello" is a factory activated with #to_s | |
[7:43pm] wycats_: No | |
[7:43pm] nkallen_: i would not say "hello" is a factory activated with #to_s | |
[7:43pm] wycats_: But why is it useful to talk about it this way? | |
[7:44pm] nkallen_: because you can speak about structural techniques without overspecifying the implementation. | |
[7:44pm] nkallen_: also, and maybe more honestly, | |
[7:44pm] wycats_: What I'm asking is why these parameters are special? | |
[7:44pm] nkallen_: because Dependency Injection is a widely accepted term when passing in factories as parameters to constructors and setters | |
[7:46pm] wycats_: A recent alias_method_chain oriented post | |
[7:46pm] wycats_: The entire problem could be solved with this pattern | |
[7:46pm] wycats_: It makes me cry | |
[7:46pm] nkallen_: well, i think we agree about a lot of stuff. | |
[7:47pm] nkallen_: we cry hot tears for unmodular code. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment