tags:

views:

290

answers:

7

I've read a lot of people saying that some things shouldn't be written in an object orientated style - as a person learning the OO style coming from a C background, what do they mean by this?

What shouldn't be OO, why do some things fit this design better, and how do we know when it's best to do what?

A: 

Just a tip: you should tag this question as "subjective" as everyone seems to have a different opinion on things like this.

dguaraglia
And you should put that kind of note in the comments and not as an answer to the question... No it wasn't me that voted you down, but somone did and I assume thats why.
Omar Kooheji
Why didn't you do it yourself, you've got the rep.
Rik
+4  A: 

The real world is full of objects.

It's helpful to make the software world match the real world.

"What about 'system utilities'? They just deal with abstractions like sockets and processes and file systems." They sound like things to me. They have attributes and behaviors, they have associations.

If you're looking for proof that OO is better, there isn't any. Nothing is better because better is a gloriously vague term. Anyone who's clever can write any program in any style. You could adopt functional, procedural, object-oriented, or anything you feel like.

I use OO because I have a very small brain and must learn to live within its limits. OO is a crutch to help me struggle through programming. If I was smarter, richer and better-looking, I wouldn't need the help, and I could write non-OO programs. Sadly, I'm not smart. Without class definitions to isolate responsibility and structure an architecture, I'd still be writing single-file "hello world" variants.

S.Lott
Everything said here is valid and true, OO allows for a greater control over the use of code without having to write code to do so, just try to ignore the derisive and arrogant tone of the response ;) (im sure it was in jest)
RAGNO
@RAGNO: I'll assume you're talking about 3rd paragraph which is intended to be factual -- better is undefined and most questions (like this one) don't have a concrete qualifier. Just vague terms like "better". I'm not sure how else to state it. Advice?
S.Lott
+2  A: 

Object Oriented design is all about managing complexity as your system grows. Therefore OO design can be overkill for smaller less complex systems, or for systems that you know will never grow.

Of course the problem is that we rarely know with certainty that a system is not going to grow.

Ash
A: 

I can't think of anything other than stored procedures. Get yourself a copy of Reflector and use it to look at the .NET framework dll's as a good learning lesson. Alternately there are a ton of books on C++ and OO on the market since thats been around a while.

Thomas Wagner
+2  A: 

I agree with most of the above (or below?) that OO exists to simplify complex problems and software design.

However, there are many times where it is extremely overdone. I can't tell you the number of times where I wish there was a Visual Studio Unrefactor button just to make sense of the code and put all base classes in one file for readability.

JTA
yes, precisely! Like denormalization for oo code!
alchemical
+3  A: 
The Wicked Flea
A: 

If you're writing mobile applications (at least I can speak for .NET mobile), then you should try to be as non-OO as possible. As much as mobile has advanced, you don't want to waste system memory because you've tied up processing with abstraction layers, large datasets in memory, or other entities that will slow things down. You'll want to write things as straightforward as possible.

Anjisan