tags:

views:

380

answers:

13

I asked a question previously about Dataset vs Business Objects http://stackoverflow.com/questions/1248470/net-dataset-vs-business-object-why-the-debate-why-not-combine-the-two

and I want to generalize the question here: where is the proof that OOP is really suitable for very complex problems ? Let's take a MMO Game Engine for example. I'm not specialist at all but as I read this article, it clearly stands that OOP is far from being enough:

http://t-machine.org/index.php/2007/11/11/entity-systems-are-the-future-of-mmog-development-part-2/

It concludes: Programming well with Entity Systems is very close to programming with a Relational Database. It would not be unreasonable to call ES’s a form of “Relation Oriented Programming”.

So isn't OOP trying to get rid off something that is here to stay ?

OOP is non-linear, Relational is linear, both are necessary depending on the part of a system so why try to eliminate Relational just because it isn't "pure" Object. Is OOP an end by itself ?

+4  A: 

Systems of any notable complexity are not linear. Even if you worked really hard to make a system one linear process, you're still relying on things like disks, memory and network connections that can be flaky, so you'll need to work around that.

I don't know that anyone thinks OOP is the final answer. It's just a way of dealing with complexity by trying to keep various problems confined to the smallest possible sphere so the damage they do when they blow up is minimized. My problem with your question is that it assumes perfection is possible. If it were, I could agree OOP isn't necessary. It is for me until someone comes up with a better way for me to minimize the number of mistakes I make.

Tom
always linear, I agree, nor can they be. complex apps certainly aren't
Eric
+3  A: 

What we try to do is put an OO style on top of a relational system. In C# land this gets us a strongly typed system so that everything from end to end can be compiled and tested. The database has a hard time being tested, refactored, etc. OOP allows us to organize our application into layers and hiearchies which relational doesn't allow.

Andrew Siemer
+1  A: 

Well you've got a theoretical question.

Firstly let me agree with you that OOP is not a solve-all solution. It's good for somethings, it's not good for others. But that doesn't mean it doesn't scale up. Some horribly complex and huge systems have been designed using OOP.

I think OOP is so popular because it deserves to be. It solves some problems rather wonderfully, it is easy to think in terms of Objects because we can do that without re-programming ourselves.

So until we can all come up with a better alternatives that actually works in practical life, I think OOP is a pretty good idea and so are relational databases.

Cyril Gupta
Popularity is not a proof, in fact it may even be like in stock market : the majority is wrong :) Why did people stay with EJB so long without seeing they were rotten ? Today frameworks have such steep learning curve that there are now some voices like Martin Fowler who tells it and pretends DSL would solve the problem.Yeah may be but that's it dsl is going back to functional programming, which ressembles sequential Unix Pipe, so here we are back again to linearity !
programmernovice
+1  A: 

There is really no limit to what OOP can deal with - just as there is no real limit to what C can deal with, or assembler for that matter. All are Turing-complete, which is all you really need.

OOP simply gives you a higher-level way of breaking down the program, just as C is a higher-level than assembler.

The article about entity systems does not say that OO cannot do this - in fact, it sounds like they are using OOP to implement their Entities, Components, etc. In any complex domain there will be different ways of breaking it down, and using OOP you can break it down to the object/class level at some point. This does not preclude having higher-level conceptual frameworks which are used to design the OOP system.

Larry Watanabe
+1  A: 

The problem isn't the object oriented approach in most situations, the problem is performance and actual development of the underlying hardware.

The OO paradigm approach software development by providing us with a metaphor of the real world, were we have concepts which defines the common accepted and expected properties and behaivour of real objects in the world. Is the way that humans model things and we're able to solve most of the problems with it.

In theory you can define every aspect of a game, system or whatever using OO. In practice if you do, your program will simply behave too slow so the paradigm is messed up by optimizations which trade the simplicity of the model from performance.

In that way, relational databases are not object oriented so we build an object oriented layer between our code and the database... by doing so you lost some of the performance of the database and some of its expressiveness because, from the point of view of OO paradigm a relational database is a full class, is an very complex object that provides information.

From my point of view OO is an almost perfect approach in the theoretical sense of the word, as it maps closely to the way we, humans, think, but it doesn't fit well with the limited resources of the computational development... so we take shortcuts. At the and, performance is far more important than theoretical organization or clearness so this shortcuts become standards or usual practices.

That is, we are adapting the theoretical model to our current limitations. In the times of cobol in the late 70's object oriented was simply impossible... it would imply to many aspects and too little performance so we used a simplified approach, so simplified you didn't have objects or class, you had variables ... but the concept was, in that time, the same. Groups of variables described related concepts, properties that today will feet into an object. Control sequences based on a variable value where used to replace class hierarchies and so on.

I think we've been using OOP for a long time and that we'll continue using it for a long time. As hardware capabilities improve we'll be able to unsimplify the model so that it becomes more adaptable. If I describe perfectly (almost) the concept of a cat (which involves a lot of describing for a lot of concepts involved) that concept will be able to be reused everywhere... the problem here is not, as I've said, with the paradigm itself but with our limitations to implement it.

EDIT: To answer the question about why use pure OO. Every "science" wants to have a complete model to represent things. We have two physic models to describe nature, one at the microscopic level and one for the macroscopic one, and we want to have just one because it simplifies things it provides us with a better way to prove, test and develop things. With OO the same process applies. You can't analytically test and prove a system if the system doesn't follow a precise set of rules. If you are changing between paradigms in a program then your program cannot be properly analized, it has to be disected in each one, analized and then analized again to see that the interactions are correct. It makes a lot more difficult to understand a system because in fact you have two or three system that interact in different ways.

Jorge Córdoba
A: 

My question is not is OOP usefull. OOP is usefull, my question is rather why the purists want to do "pure" OOP ?

programmernovice
What do you mean by "pure OOP"?
Ray
For example saying Datasets is evil or no SQL in an Object.
programmernovice
surely "pure" OO would use a true object database, not a kludge on top of SQL?
anon
By Datasets you mean .NET FW 2.0 DataSet? Oh yes, those are evil because they are extremely poorly designed and implemented.
Ray
The purists want to do pure OOP for the same reason they always want to do something purist...They are purists. But it's a little bit like insisting on using a flat-bladed screwdriver for everything. Eventually you are going to need a Philips, or a Torx.
Robert Harvey
+1  A: 

Could you clarify what exactly you are trying to compare and prove here? OOP is a programming paradigm, one of the many. It's not perfect. It's not a silver bullet.

What does "Relation Oriented Programming" mean? Data-centric? Well, Microsoft was moving towards more data-centric style of programming until they given up on Linq2Sql and fully focused on their O/RM EntityFramework.

Also relational databases isn't everything. There is many different kinds of database architectures: hierarchical databases, network databases, object databases ect. And those can be even more efficient than relational. Relational are so popular for nearly the same reasons why OOP is so popular: it's simple, very easy to understand and most often efficient enough.

Ray
+1  A: 

Guys, isn't the question more about ORM than OOP? OOP is a style of programming - the thing that actually gets compared is a Relational Database mapped onto objects.

OOP is actually more than just the ORM! It's also not just the inheritance and polymorphism! It's an extremly wide range of design patterns and above all it's the way we think about programming itself.

Jorge: it's ok that you've pointed out the opitimization part - what you didn't add is that this step should be done last and in 99% cases the slow part is not the OOP.

Now plain and simple: the OOP style with all the principals added to it (clean code, use of design patterns, not to deep inheritance structures and let's not forget unit testing!) it a way to make more people understand what you wrote. That in turn is needed for companies to keep their bussiness secure. That's also a recepie for small teams to have better understanding with the community. It's like a common meta language on top of the programming language itself.

Matthias Hryniszak
Agree Matthias. Question is asked in a very confusing way.
Ray
A: 

Let me ask you one more question: how did you figure that OOP is non-linear and relational databases are? What's the point?

Matthias Hryniszak
My point is it's just 2 viewpoint of the same reality, sometimes it's easier to treat the problem from one or the other viewpoint, like in mathematics when you use a mathematical transformation to be in a more linear space because it's easier.
programmernovice
How to treat a problem is more of a functional vs imperative question.
Ray
Excellent observation Ray. The comparison programmernovice gave is inadequate in this case.
Matthias Hryniszak
+3  A: 

Just read yr article about Entity Systems, which compares ES to OOP, and it is flagrantly wrong about several aspects of OOP. for e.g., When there are 100 instances of a class, there are not 100 copies of the classes methods loaded in memory, there is only one. Everything that ES purports to be able to do "better" than OOP because it has "Components", and "Systems", OOP supports as well using interfaces and static classes, (and/or Singletons).

And OOP more naturally fits with the real-world, as any real or imagined Problem Domain, consisting of multiple physical and/or non-physical items and abstractions, and the relationships between them, can be modeled with an appropriately designed hiearchical OOP class structure.

Charles Bretana
Also with objects its much easier to maintain hierarchical data structures.
Ray
+1  A: 

It's always easier to talk about concepts from a purists point of view. Once you're faced with a real life problem things get trickier and the world is no longer just black and white. Just like the author of the article is very thorough in pointing out that they're not doing OOP the "OOP purist" tells you that OOP is the only way to go. The truth is somewhere in between.

There is no single answer, as long as you understand the different ways (OOP, entity systems, functional programming and many more) of doing things and can give good reason for why you're choosing one over the other in any given situation you're more likely to succeed.

henrik
+1  A: 

About Entity Systems. It's an interesting conception but it brings nothing really new. For example it states:

OOP style would be for each Component to have zero or more methods, that some external thing has to invoke at some point. ES style is for each Component to have no methods but instead for the continuously running system to run it’s own internal methods against different Components one at a time.

But isn't it same as Martin Fowler's anti-pattern called "Anemic Domain Model" (which is extensively used nowadays, in fact) link ?

So basically ES is an "idea on the paper". For people to accept it, it MUST be proven with working code examples. There is not a single word in the article on how to implement this idea on practice. Nothing said about scalability concerns. Nothing said about fault tolerance...

As for your actual question I don't see how Entity Systems described in article can be similar to relational databases. Relational databases have no such thing as "aspects" that are described in the article. In fact, relational - based on tables data structure - is very limited when it comes to working with hierarchical data, for example. More limited than for example object databases...

Ray
I agree with you about the antipattern stuff.
programmernovice
+4  A: 

As the author of the linked post, I thought I'd throw in a couple of thoughts.

FYI: I started seriously (i.e. for commercial work) using OOP / ORM / UML in 1997, and it took me about 5 years of day to day usage to get really good at it IMHO. I'd been programming in ASM and non-OOP languages for about 5 years by that point.

The question may be imperfectly phrased, but I think it's a good question to be asking yourself and investigating - once you understand how to phrase it better, you'll have learnt a lot useful about how this all hangs together.

"So isn't OOP trying to get rid off something that is here to stay ?"

First, read Bjarne's paper here: http://www.research.att.com/~bs/oopsla.pdf

IMHO, no-one should be taught any OOP without reading that paper (and re-reading after they've "learnt" OOP). So many many people misunderstand what they're dealing with.

IME, many university courses don't teach OOP well; they teach people how to write methods, and classes, and how to use objects. They teach poorly why you would do these things, where the ideas come from, etc. I think much of the mis-usage comes from that: almost a case of the blind leading the blind (they aren't blind in "how" to use OOP, they're just blind in "why" to use OOP).

To quote from the final paragraphs of the paper:

"how you support good programming techniques and good design techniques matters more than labels and buzz words. The fundamental idea is simply to improve design and programming through abstraction. You want to hide details, you want to exploit any commonality in a system, and you want to make this affordable.

I would like to encourage you not to make object-oriented a meaningless term. The notion of ‘‘object-oriented’’ is too frequently debased: – by equating it with good, – by equating it with a single language, or – by accepting everything as object-oriented.

I have argued that there are–and must be–useful techniques beyond object-oriented programming and design. However, to avoid being totally misunderstood, I would like to emphasize that I wouldn’t attempt a serious project using a programming lan- guage that didn’t at least support the classical notion of object-oriented programming. In addition to facilities that support object-oriented programming, I want –and C++ provides features that go beyond those in their support for direct expression of concepts and relationships."

Now ... I'd ask you ... of all the OOP programmers and OOP projects you've seen, how many of them can honestly claim to have adhered to what Bjarne requests there?

IME, less than the majority.

Bjarne states that:

"The fundamental idea is simply to improve design and programming through abstraction"

...and yet many people invent for themselves a different meaning, something like:

"The fundamental idea is that OOP is good, and everything-not-OOP is inferior"

Programmers who have programmed sequentially with ASM, then later ASM's, then pascal, then C, then C++, and have been exposed to the chaos that was programming pre-encapsulation etc tend to have better understanding of this stuff. They know why OOP came about, what it was trying to solve.

Funnily enough, OOP was not trying to solve every programming problem. Who'd have htought it, to say how it's talked about today?

It was aimed at a small number of problems that were hugely dangerous the bigger your project got, and which it turned out to be somewhere between "good" and "very good" at solving.

But even some of them it isn't any better than merely "good" at solving; there are other paradigms that are better...

All IMHO, of course ;)

Adam
Great answer, I'm honored, thanks a lot :)By the way I don't dismiss OOP at all, I'm just saying there seem to be a lot of fashionable stuff around that are throwned without proof. Is Programming a Science or Not ? If it is Science, then it should be proved.
programmernovice
FWIW I recently wrote a quick-n-dirty ES for an Android game - most of the source is in the blog post: http://t-machine.org/index.php/2010/05/09/entity-system-1-javaandroid/
Adam