The Art of Being Right (Learning OO)

Hey all. I’m back, and I’d like to officially apologize for going all “Bermuda Triangle” on you in the middle of the “Going OO” series. I’d like to take a few minutes and reflect on some of what happened, because some of it is actually relevant.

First… the non-relevant bits. we moved (again). I thought it would be a fairly easy thing to do this time around… because unlike the last 2 times it wasn’t a cross-country move (from AZ to FL, and then from FL to CA). This time it was from CA (southern) to CA (East Bay)… but it still really really sucked. It was just a very draining experience (both physically and mentally) and I never ever want to do it again (but I will).

Factor in starting the new job (which is going great so far, thankyouverymuch) and I just haven’t even had time to keep up with reading blogs, let alone writing an entry.

But things have settled down (somewhat) so I’m going to try and get back into the swing of things.

So the $64,000 question is… where’m I at with all of this OO stuff? Hell of a question. Sorta wish you hadn’t asked. *sigh* but you did, so…

To be perfectly honest, I’m where I was afraid I’d be. I got so hung up on trying to do things "right" that my brain exploded (just a little, I’m ok, thanks for asking). But I did learn something, and I think it’s something valuable. I’d love to share it with you.

Ready? This is big…

"Right" is, in many cases, subjective.

OK, so maybe that’s not earth shattering news to many of you… but it tripped me up, and it’s pretty friggin’ important to understand in the world of OO (and other places as well, I figure. Like marriage.).

Interestingly enough, it wasn’t really the OO journey that led me to understand this. Oh sure, that sort of planted the seed in my brain (in the part that hadn’t yet exploded), but it was actually learning Model-Glue that got that seed to sprout.

Learning Model-Glue is something that I’m still undertaking for the new job. There’s currently not a framework (or anything beyond the most rudimentary of coding standards) in place, and we wanted to change that. For a couple of different reasons (that I may discuss in greater detail in a subsequent post), we chose to pursue Model-Glue.

So one of my very first assignments on the new job is to learn Model-Glue. For the most part I think it’s going pretty well. I really like the framework, and I’ve got about 90% of one of our sites re-written in it already. Fact of the matter is, though, that 90% of that particular site is just presenting data. It’s a marketing web site… not by any means a "web application". I’m now at the 10% that requires little things like database interaction, session management, and the like.

Let’s focus for the moment on the session management aspect.

After a bit of googling, I came across some sample code that showed one particular implementation of referencing session data in Model-Glue. The session was referenced directly from a CFC within a controller. Was that "right"? One of the first things that I learned about CFCs was that they shouldn’t reference outside scopes. Yet, it seems to be "right" to reference the session from a CFC within a controller… at least, in this instance.

Back to Google. Hmm… some people use a session façade. Sounds interesting… OK I see what they’re doing there. So is that the "right" way? And if it is, was the previous way not the right way?

Back to Google. Oops… looks like there are people out there that don’t like the session façade. They go about accessing session data a whole ‘nother way. Is that the "right" way?

My brain started to throb. I knew this feeling. Explosion imminent. Must stop thinking. I’m feeling like a confused baby bird asking "are you my mother?" (Dr. Seuss reference).

Then it hit me.

In a manner of speaking, they’re all "right", aren’t they? Their applications work (presumably). They understand what they did. More importantly, they understand why they did it that way. What’s "wrong" with that?

So for those of you who, like me, have been running around in circles trying to find the ever elusive one "right" way… stop it. Just stop. Don’t make me pull this blog over.

What you need to do is understand the underlying concepts. With that understanding, you can choose the way that works best for you. That particular way might not work for others, but that’s OK. As long as you truly understand why you did it that way, and you can justify it (to yourself… not to anybody else unless you choose to engage in that debate), and it works when you run it… then congratulations. You have achieved "right". Or at least "right enough"… but sometimes that’s gotta be ok.

Bottom line? if you want to learn "right", you first have to define "right". You can’t possibly do that without understanding the underlying concepts that make up the particular discipline that you’re trying to learn.

So I’m going to basically reboot this series. It’s not going to be "how to go OO in ColdFusion". It’s going to be about learning OO. That means starting at the beginning (yes, the first entry in the reboot will likely talk about what an object is… what a class is… etc). I’ll tie it into ColdFusion when applicable and appropriate (e.g. a CFC is similar to a class… an instance of a CFC is an object… etc). That might be too basic for many of you, but it’s where I need to be right now. If that’s you, go on ahead. I’ll catch up. Everybody else… let’s try and do this thing once and for all.