by Curtis Poe
I was discussing object oriented (OO) programming with someone who was working on a horrible piece of software with class names like StartSession. I'll call him "Alice". Naturally, when wading through these classes, he finds 400 line "methods" in classes which are merely OO façades around procedural modules. This is disappointing, but it's all too common. If you think that StartSession is a good name for a class, someone has done a poor job of teaching OO to you.
I think part of the problem is that while there are some excellent university professors who do a fantastic job of teaching OO, many professors I took classes from had little to no real experience outside of the classroom, or those with experience clearly went back to teaching due to the old adage "those who can't, teach". Surprisingly, two of the best instructors I had were teaching COBOL. Both of them clearly had decades of real-world experience under their belts and it showed in the classroom. They understood their material, they understood the pitfalls, and taught us how to work within the constraints of the language.
Getting back to Alice, he told me about an idea he once implemented to make it clear to other programmers that OO classes can be thought of as responsible agents. One of the first classes he wrote for his work was named the AuthenticationFairy.
|I agree on the object relational mappers with you 100%. That's why I chose iBatis. It works with result sets, not tables. New field name or moved field. Only change the underlying queries, code stays the same.|
You mention a dog class is bad because it really isn't real world and so I did "perldoc perlboot" and what do I find:
Now, I understand why but I thought it a little funny.
|I want to follow up and say...yes I agree with you as well.|
was working on a horrible piece of software with class names like
|I completely disagree with you about ORMs, of course, I don't believe in Enterprise databases (that is to say, I think they are magical creatures, quite unlike AuthenticationFairies), so it's not a problem in my world.|
|Danno: for the record (no pun intended), I do like ORMs and I find them extremely beneficial. However, there are some pretty serious trade-offs with many of them and regrettably, since most developers don't understand databases, they don't understand the trade-offs. It's only in understanding the limitations of ORMs can we make reasonable decisions about their use.|
|Nice article but tell me that you don't take yourself seriously enough to type the cedilla in façades.|
|I would argue that puppy is not an instance of dog, but it is a class of its own, preferably a subclass of dog. (house_broken = false; cuteness += 10;) Fido would be an instance.|
|See also: The Tell, Don't Ask principle|
|If we couldn't map a table to an object how could we work with database and objects?|