views:

227

answers:

10

I am trying to get a couple team-members on to the OOP mindset, who currently think in terms of procedural programming.

However I am having a hard time putting into terms the "why" all this is good, and "why" they should want to benefit from it.

They use a different language than I do, and I am lacking the communication skills to explain this to them in a way that makes them "want" to learn the OOP way of doing things.

What are some good language independent books, articles, or arguments anyone can give or point to?

+1  A: 

Abstraction helps manage the complexity of an application: only the information that's required is exposed.

There are many ways to go about this: OOP is not the only discipline to promote this strategy.

Of course, it is not because one claims to do OOP that one builds an application without abundant "abstraction leaks" thereby defeating the strategy...

jldupont
+2  A: 

Comparing procedural to OOP, the biggest winner by far is encapsulation. OOP doesn't mean that you get encapsulation automatically, but the process of doing it is free compared with procedural code.

plinth
+1 Encapsulation is the Cinderella of OOP - pretty, but often ignored. I'd go ahead and call inheritance the wicked stepmother.
MusiGenesis
@MusiGenesis, yes and what of polymorphism and multiple inheritance?
Earlz
@Earlz: wicked stepsisters, of course (although I'm not sure they were formally "wicked" like their mother).
MusiGenesis
A: 

OOP didn't make sense to me until I was working on an application that connected to two different databases. I needed a function called getEmployeeName() for both databases. I decided to create two objects, one for each database, to encapsulate the functions that ran against each one (there were no functions that ran against both simultaneously). Not the epitomy of OOP, but a good start for me.

Most of my code is still procedural, but I'm more aware of situations where objects would make sense in my code. I'm not of the mindset that everything needs to be one way or the other.

Scott
+2  A: 

The killer phrase: With OOP you can model the world "as it is" *cough*.

aefxx
That the reason I use. The world works like that. The world is not a series of tubes
Pierre-Alain Vigeant
I've always argued that the world is procedural. I can only do one thing at a time.
Scott
It's difficult to say what the world is like. If you can't even define how the world is then how can you say that you can model it?
Brian T Hannan
I \*coughed\* at the end - didn't you hear it? :D
aefxx
No, we do not model the world as it is. We model abstractions of the world. Moreover, OOP is not necessary to produce models of abstractions of the world.
Jason
I know, that's why I head to cough ^^
aefxx
However OOP works exactly as humans try to *classify* everything in the world. So I think this phrase still holds quite a lot truth.
poke
I disagree. Are you interested in modeling the world or solving a problem? If your problem domain is full of objects and events, yes, OOP works well. If your problem domain is solving piles of equations in sequence, well, then....
Paul Nathan
A: 

Re-use of existing code through hierarchies.

SP
A: 

The killer argument is IMHO that it takes much less time to re-design your code. Here is a similar question explaining why.

soulmerge
+1  A: 

I have a bit strange thought. I don't know but there probably some areas exist where OOP is unnecessary or even bad (very-very IMHO: javascript programming).

You and your team probably work in one of these areas. In other case you'd failed many years ago due to teams which use oop and all its benefits (like different frameworks, UML and so on) would simply do their job more efficiently.

I mean that if you still work well without oop then, maybe, just leave it.

Roman
if you think OOP in javascript is unnecessary or even bad, you obviously haven't tried jQuery. I would encourage you to treat yourself. :]
matt lohkamp
I used jQuery and found lots of functional programming features there. I don't know how does it provide OOP, but I heard that ExtJS has some good OOP support. But now I really didn't use Ext.
Roman
A: 

Having the ability to pass an entire object around that has a bunch of methods/functions you can call using that object. For example, let's say you have want to pass a message around you only need to pass one object and everyone who gets that object will have access to all it's functions.

Also, you can declare some objects' functions as public and some as private. There is also the concept of a friend function where only objects that are related through OO hierarchies have access to their friend's functions.

Objects help keep functions near the data they use and encapsulates it all into one entity that can be easily passed around.

Brian T Hannan
+4  A: 

OOP is good for a multi-developer team because it easily allows abstraction, encapsulation, inheritance and polymorphism. These are the big buzz words of OOP and they are the big buzz words for good reasons.

Abstraction: Allows other members of your team to use code that you write without having to understand the implementation details. This reduces the amount of necessary communication. Think of The Mythical Man Month wherein it is detailed that communication is one of the highest costs facing a development team.

Encapsulation: Allows you to change your implementation details without impacting users of your code. As such, it reduces code maintenance costs.

Inheritance: Allows your team to reuse and extend your implementations with reduced costs.

Polymorphism: Allows your team to use different implementations of a given abstraction. If your team is writing code to read and parse data from a Stream, because of polymorphism it can now work with FileStreams, MemoryStreams and PigeonStreams seamlessly and with significantly reduced costs.

OOP is not a holy grail. It is inappropriate for some teams because the costs of using it could be higher than the costs of not using it. For example, if you try to design for polymorphism but never have multiple implementations of a given abstraction then you have probably increased your costs.

Jason
+1 this is the kind of responses I was looking for
John Isaacks
Good answer. A comment: Abstraction and encapsulation work together, the goal being the separation of interface and implementation. One extension is formalizing the interface with design by contract.
David Thornley
+2  A: 

Always give examples.

Take a bit of their code you think is bad. Re-write it to be better. Explain why it is better. Your colleagues will either agree or disagree.

Nobody uses (or should use) techniques because they're good techniques, they (should) use them because they produce good results. The advantages of very simple use of classes and objects are usually fairly easy to see, for instance when you have an array of objects with n properties instead of n arrays, one for each field you care about, and so on.

Steve Jessop