I'm not a Ruby programmer, so maybe I'm misunderstanding the article -- are we talking about changing an object's class hierarchy after it's already been instantiated and then complaining that it's the performance aspect that is pathological? That sounds like a completely insane way of writing software to me.
"DCI" in Ruby is completely broken
21–30 of 67 posts
Re: "DCI" in Ruby is completely broken
#22If DCI helps to keep your code maintainable, readable, and less buggy, is that a better tradeoff? I would think that 95-99% of the time, the answer is yes.
On a side note, if speed is mission critical, then would ruby really be the language of choice to use?
Re: "DCI" in Ruby is completely broken
#23The title of the post is unnecessarily inflammatory. It should be "Using extend to do DCI in Ruby is completely broken." The author even admits this in the article, and points out other ways of doing DCI in Ruby.
Re: "DCI" in Ruby is completely broken
#24I'm not a Ruby programmer, so maybe I'm misunderstanding the article -- are we talking about changing an object's class hierarchy after it's already been instantiated and then complaining that it's the performance aspect that is pathological? That sounds like a completely insane way of writing software to me.
Re: "DCI" in Ruby is completely broken
#25I'm not a Ruby programmer, so maybe I'm misunderstanding the article -- are we talking about changing an object's class hierarchy after it's already been instantiated and then complaining that it's the performance aspect that is pathological? That sounds like a completely insane way of writing software to me.
Is your app CPU-bound? If so, then DCI probably isn't a great idea for you. In fact, building it in Ruby may not be the best idea.
But if your app is IO-bound (like most Rails apps), huge and it takes new developers weeks to get up to speed, then the gains from having a simple, modular code-base should save you developer-time (and hence salaries), which are much more expensive than CPUs.
Having said that, I tend to use SimpleDelegator instead of dynamically injecting stuff into objects.
EDIT: added 'ruby not being the best idea if CPU bound'
Re: "DCI" in Ruby is completely broken
#26I was curious what Tony's graph would look like using a SimpleDelegator as he suggested. (using ruby 1.9.3p194) Calculating ------------------------------------- without dci 68507 i/100ms with dci 24409 i/100ms with delegator 46945 i/100ms ------------------------------------------------- without dci 2240202.4 (±3.2%) i/s - 11235148 in 5.020463s with dci 412445.3 (±3.7%) i/s - 2074765 in 5.037113s with delegator 1018…
Subtracting the results of different runs like this is pretty questionable, though (the errors accumulate), so the above is to be taken with a pinch of salt.
Re: "DCI" in Ruby is completely broken
#27I'm not a Ruby programmer, so maybe I'm misunderstanding the article -- are we talking about changing an object's class hierarchy after it's already been instantiated and then complaining that it's the performance aspect that is pathological? That sounds like a completely insane way of writing software to me.
There's even a protocol for notifying instances that their class has changed so they can make any necessary adjustments: http://clhs.lisp.se/Body/07_bb.htm
Re: "DCI" in Ruby is completely broken
#28I do something slightly different. I create a class directly for the context and then fire an object into it.
class TheContext def initialize # ... end
def execute(the_object)
# ...
end
endRe: "DCI" in Ruby is completely broken
#29Imagine a language where a call looked like this:
user.doSomething(1, 2, 3)
But it's just syntax sugar for this function application: doSomething(user, 1, 2, 3)
("user" would be just the data..like a struct type thing)That way you get the flexibility of loose functions but you get the (imo) superior aesthetics of oop languages.