Joao Pedrosa
1/29/2005 6:23:00 AM
Hi,
On Sat, 29 Jan 2005 14:55:51 +0900, Trans <transfire@gmail.com> wrote:
> Nice. I look forward to the next installment.
>
> Of course I had basically figured the jist of this out already, but
> this post states it very nicely and quite clearly. I think alot of what
> makes OOP popular is that people actually like a certain amount of
> complexity --it gives them something to do and to "know". That's not
> to say it doesn't have some merits --it does help code reuse a little,
> but I don't know how well it really offsets the added hoops it creates.
> I recently rewrote a program something like 15 times before I felt like
> I got the "object model" right.
I'm working with about 16k LoC of Ruby and I had to do some drastic
improvements to it and I think that the general OOness of it was
enough to keep it all working while I messed with it. I wouldn't
recommend doing it on production code that you need ready by the next
week, but it definitely helps when you are still in the development
process.
I feel like I can break Ruby code knowing that I will be able to fix
it. The only exception is the "end" keyword which if missing is
terrible, but if you kept the file small enough you can handle that,
even without the right tools.
It's a nice feeling to know that we can hack several scripts, merge
them, create new ones, mess with the old ones, etc, without everything
falling apart.
Basically, code should be inside modules. Don't "include AModule"
outside of a module, or you may hit some conflicts. Split your code
evenly among files. "Reopen" the same modules in different files, if
needed.
That said, I even used some Polymorphism, so OO in Ruby is really
useful. I found that I could avoid many copy/pastes by using OO
properly.
If I had to fight with Static Typing while doing so many changes to
the code, many "ideas" would be lost while I would be trying to make
it compile to verify the changes. It's really a different process. We
do get errors, but not in the Static Typing sense and there isn't a
debugger with breakpoints, only "p"s and "puts"s here and there. :-)
It's a different mindset. When I used Delphi, I would often get angry
at Delphi for making me repeat some unwanted steps prior to doing
something else, or when it would simply say "Insufficient Memory"
declaring end of the programming session for me.
I prefer Ruby. :-)
Cheers,
Joao