D'Arcy from Winnipeg

# OO Basics - What would YOU want to have been taught?

Friday, December 28, 2007 5:21 PM

Further on my last post, I'm putting together my teachings around the basics of OO programming...and realizing that there are many things that could be considered must-know for developing in the OO paradigm:

Classes and Objects (duh)
Polymorphism
Inheritance
Interfaces
Encapsulation
Coupling and Cohesion
Single Responsibility Principle

I played around with the idea of including Dependency Injection, but later on in the course we're going to cover patterns and I decided to move it there...that plus I don't know that its a "must know" for getting started.

I'm sure these cover the basics of OO development, but is there anything you look back on now and wish would have been included in your intro college course?

D

## Feedback

#### #re: OO Basics - What would YOU want to have been taught?

I wouldn't include DI on that list of fundamental OO skills. Try adding:
- Separation of Concerns
- Law of Demeter
- Abstraction
- Open Close Principle

If I were teaching the course I'd try to get my mitts onto a copy of Patrick Sammachia's nDepend so that I could demonstrate how coupling and cohesion changed with different coding styles.

If time permitted I'd start getting into patterns like DI, IoC, Singleton (*gag*), monostate, visitor, etc. Even if it were just to plant the seed that people should go out and read on these things, that's a good start and certainly way more knowledge than most grads have. 12/28/2007 5:51 PM | Donald Belcham

#### #re: OO Basics - What would YOU want to have been taught?

This kind of adds a bit to what Donald is saying regarding dependecnies. It would be good to include the "Main Sequence" diagram.

Plotting a class on this graph demonstrates a class's stability vs instability and responsibility vs irresponsibility. Ideally, you would like your .Net assemblies to fall somwhere close to the top left or bottom right of the graph.

There's a bit of theory behind this and some metrics to calculate ( I believe NDepend can do this for you, but not sure). The main thing to know here is not the graph itself, but more importantly why it is important to have your items fall onto the top left or lower right sections of the graph.

Anyway, here's a link to Uncle Bob's published article.
http://www.objectmentor.com/resources/articles/stability.pdf
12/29/2007 10:01 AM | Shaneo

#### #re: OO Basics - What would YOU want to have been taught?

The single most valuable piece of knowledge I have is how to work with messy legacy code. My abilities to wade through and reverse-engineer and fix this stuff have landed me several jobs and contracts throughout my life and I owe it all to the ass-tastic graphics library that was provided to me to use in cse 143 at the university of washington.

Anyway, I'd like to see someone teach all this stuff by taking some relatively simple legacy code that sucks and refactoring it, teaching OO basics and patterns and whatnot as you go. That way, instead of just telling someone how to write good code, you can actually show them both how to write it and why it's better. You could introduce unit tests into this easily as well. 12/31/2007 2:42 PM | Jeff Tucker