Andy Hunt and Dave Thomas have hit another home run in their article entitled: "OO In One Sentence".
Here are some of my fave tidbits:
- "The best code is very shy. Like a
four-year old hiding behind a mother’s
skirt, code shouldn’t reveal too much
of itself and shouldn’t be too nosy into
AMEN! I see too much code where they are data structures and everything is accessible. It makes for very messy code. With that said, I also think you should always have accessors for your instance variables, but I don't think those methods should be considerd public by any means. Encapsulation is your friend!
- "Always plan on writing concurrent code
because the odds are good that it will
end up that way anyhow, and you’ll get
a better design as a fringe benefit. Your
code shouldn’t care about what else
might be happening at the same time; it
should just work regardless."
Again, I can not stress this enough. I actually had someone ask me why I thought this was good. Now, I have an article to support my claim. Also, if you plan for concurrency, you will avoid all global variable and class variables (at least stateful class variables). Again, your code will be all the better for it. It also forces you to make your code more modular as well. It just has so many benefits. It just makes your design better. It's like writing tests for your code. Testing always shows defiencies in my code and where I can improve the API.
What do I need to say? Don't Repeat Yourself! AMEN!
- “Sending a message” to an object
conveys an air of apathy. I’ve just sent
you an order (or a request), and I don’t
really care who or what you are or (especially)
how you do it. Just get it
done. This service-oriented, operationcentric
viewpoint is critical to good
code. Apathy toward the details, in this
case, is just the right approach. You tell
an object what to do; you don’t ask it
for data (too many details) and attempt
to do the work yourself.
What all of us Smalltalkers have known for years and years. But, damn, it's good to hear it again! I'm surprised how many developers that claim to be OO, just don't get this.
Anyway, the article has a lot of good stuff (and it's only 3 pages!) and you have no excuse not to read it. I love their talk on coupling too. I'm not going to say to much more because I didn't want to quote the entire article...=) But, I'm going to be making multiple copies of this articles and keeping it around me.