TRANSCODE Explorations into the Code Transcendental.

Frustration with Object Orientation

Frustration with Object-Orientation

I’ve spent more weeks than I care to count going around in circles.

You see the problem is I have “tools” that are in essence methods. But the are generally complicated enough to warrent using state and being broken into many smaller supporting methods. That’s fine and dandy until I try to tie a bunch of these tools together under the same class. Name clashes become a huge problem, to the point that it is simply unworkable. The need for local instance variables and methods becomes a big deal. The only way to currently achieve that is to use lambdas and define_method. Not ideal, and RDocs become all but useless. To avoid this I tried going in the opposite direction, defining the tools as their own classes instead. This works great until the tool needs to take part in a more complex structure. For example I have hosting service classes that provide releasing and publishing tools. Well, if ‘release’ and ‘publish’ are classes rather then methods how are they going to call the hosting service’s login method? I’m forced into using delegation, passing them the instance of the Host class to which they are supposed to belong. At that point the result is worse than the original problem. So in either case I’m finding it neccessary to to write and maintain hacky code. And I’m just fet up with it.

Over the last five years I’ve spent a great deal of time working with Ruby and learning Object-Oriented programming practices it’s associated design patterns. It all seemed very logical at first. But as time wore on I found myself again and again feeling hemmed in. I assumed it was just that I did not understand it all well enough yet to use it well so I kept at it. Certainly my skills improved, but in retorsect it wasn’t some great understanding as much it was “don’t do that”. And even so, I still ran into these walls.

And this is waht I think it is. OOP requires you to first design the encapsulating structure of your project. And your whole edifice depends on that supporting design. If for some reason any bit of that should change, you may well find yourself tearing down whole walls in order to build them up again. And this can happen over and over if you weren’t sure of the original edifice from the start. For a large project that’s a lot to ask –knowing how the whole outward structure should be before you even know the materials involved.