Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Has OOP failed?

Author
Message
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 6th May 2010 04:15 Edited at: 6th May 2010 04:18
Check out this article:

http://www.4js.com/en/fichiers/b_genero/pourquoi/Has_OOP_Failed_Sept_2005.pdf

I've been reading a bunch of OOP stuff lately to wrap my head around OOP for PHP.

It's interesting his thoughts on OOP. In PHP, I think for the most part it's a fantastic way to program. I tend to use Classes the way I used to create functions (to make sections of code reusable throughout a program and throughout other projects I may create in the future), but classes are far more powerful than a single function.

Some things he nails, like polymorphism being hard to follow. It's sucky going through various pages of code to figure out where to enter code to execute a parent function properly.




At the same time, it sure beats littering my code with switch or if/then statements.

What's your opinion?

BiggAdd
Retired Moderator
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 6th May 2010 09:05
I think OOP makes a hell of a lot of sense, especially when it comes to Game design.

I find it hard to not think of "things" as objects when programming.

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 6th May 2010 14:26
OOP has definitely not failed. It's incredibly useful with large projects.

"everyone forgets a semi-colon sometimes." - Phaelax
David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 6th May 2010 15:10 Edited at: 6th May 2010 15:36
OOP is brilliant

It can be abused and mis-applied, but that's precisely why 'anti patterns' exist: To explain stupid things and why not to do them

EDIT:

I'm guessing this article is written by a non-programmer that thinks they're "in the know"?

For example:

Quote: "When the Java language was first designed, a choice had to be made. Should they mimic the complicated, counter-intuitive punctuation, diction, and syntax used in C++, or should they create an understandable, clear language--as much as possible like English? A “natural language.”

They apparently decided to deliberately avoid straightforward, clear syntax because many professional programmers wouldn’t take such a language seriously. Why? Job protection"


Well how about:

- A true 'natural language' is almost impossible. And if not done perfectly it places massive limitations on what you can do

- This article is complaining about efficiency and then advocates natural language...? As in, the most verbose long winded way you could possibly write code?

Quote: "(OOP’s polymorphism and inheritance features are often so damaging, bug-inducing, and unnecessarily complex that it’s generally sensible to avoid them whenever possible.)"


What!?

I can understand if we're talking about maintaining massive enterprise systems, where small changes can have nasty side effects if not thought through enough. But just as a general rule, this statement is pretty stupid.

Quote: "OOP encourages writing code that behaves differently in different contexts (polymorphism)."


That's a really bad description of polymorphism. You're doing the same thing to multiple types of object. So if anything, you're making sure difference objects respond to the same context

Quote: "The true alternative to OOP is procedure-based programming and 4GL (fourth-generation) languages that are deliberately constructed to resemble natural human language as much as possible. "


So he's effectively after C or BASIC, but in natural language? How is this an alternative to OOP exactly?

EDIT2:

OK this whole thing is bogus. He blames slow execution speeds on inheritance. Whilst inheritance obviously has an overhead it is not the same as 'slow'. And slow relative to what?

I think this all boils down to a misunderstanding on the author's behalf. OOP is not a de facto way to program as such. It is a de facto way to abstract away the complexity. I know of many things that would many many times more difficult to do without OOP. Not because the code is harder to read, but because it's harder to conceptualise and manage in your head. OOP fixes this because it lets you see 'things' as separate components. Not a massive mess of functions

09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th May 2010 20:22
His whole argument seems to be flawed

For a start, the .net framework is by no means the perfect implementation of OOP techniques, and yes, sometimes it is not well designed.

Secondly, there is a reason why computer languages are not very similar english, and that's because english is not specific, and is not a good way to describe logic.

Also, the fact that people use OOP badly does not mean that OOP itself is bad. People use structured code badly all the time as well, it just means they are not very good programmers!

Finally, the OOP model provides a sensible way to manage resources such as memory. When you create an object (such as a font) you know that you are using memory resources to create the object, and when you delete it, you know the resources are being freed. If you just set a property which determines a font attribute, you have no idea when the old resources will be freed and the new ones allocated. Allocation often incurs a high performance cost, so it is useful to know when it actually occurs. And often you have only a few different fonts which you want to use. Using the procedural method you must set every property every time you switch fonts, using OOP you can simply assign the whole font at once.

bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 6th May 2010 20:34
Quote: "And often you have only a few different fonts which you want to use. Using the procedural method you must set every property every time you switch fonts, using OOP you can simply assign the whole font at once."


I think his point was you can do this just as easily by creating a function in a procedural language. Then you don't have to worry about all the extra burden that oop requires.

David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 6th May 2010 20:38 Edited at: 6th May 2010 20:38
Quote: "I think his point was you can do this just as easily by creating a function in a procedural language. Then you don't have to worry about all the extra burden that oop requires."


His point is still really badly flawed though - if everything that had a changeable font had this member function (i.e. every GUI component) that's a lot of duplicated library code - something that OOP could directly fix (abstract base would fit the bill)

09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th May 2010 20:38 Edited at: 6th May 2010 20:41
@Jerico2day
Yes, but that doesn't help with the efficiency. You still have to assign to every single property.

Take DBPro's font commands for example. The reason they are so slow is because every time you change a property the whole font must be recreated. Cloggy's d3d dll solves this by simulating OOP, and letting you control the lifetime of the font. You then 'assign' your font by specifying its number whenever you draw some text. You can't deny that there is a very significant speed difference between the two methods.

Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 6th May 2010 20:46
I don't understand OOP, why not just use functions...

Rawwrr. Sig Fail.
Newcastle is awesome
BiggAdd
Retired Moderator
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 6th May 2010 20:46 Edited at: 6th May 2010 20:47
Quote: "I think his point was you can do this just as easily by creating a function in a procedural language. Then you don't have to worry about all the extra burden that oop requires."


Well you can't really. Because that function would require a whole load of variables to be declared before hand to become usable.

For instance (ho ho), imagine wanting to create your own set of commands to deal with Vectors.

In OOP, this is easy as you just create a Vector class with all of it's methods built in and its properties.

So to Add two vectors together, you would simply say "vec1.add(vec2)". Easy.

If you were doing the same thing with functions, you would be carrying around all the data for the vector through the program.

So your function would look like this:

arr[] = add( VecX , VecY , Vec2X , Vec2Y );
VecX = arr[0];
VecY = arr[1];

And even if you were to use User defined types, that is still like OOP in a way.

David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 6th May 2010 21:31 Edited at: 6th May 2010 21:35
Quote: "I don't understand OOP, why not just use functions..."


Objects give context to something.

If you have a function (on its own) it either operates on global information, or information you feed to it. BigAdd's example is a good display of this - the functions can only add the vectors if you feed them from somewhere else

Whereas, if the vector were an object the data it needs would be inside of itself. The add() would only be available in the context of the vector (i.e. you could only call a vector add with a vector)

"OOP is evil / OOP has failed" etc. is all well and good until you look at some common use cases for OOP. Then you realise that the procedural/function equivalent is downright stupid or more prone to error

Another vector example is that you could, foreseeably, have the Vec variables as globals (or statics in the CPP of the Vec definitions). That could work if you want to avoid OOP. But then you have the problem that you have to explicitly set the X/Y/Z, and make sure you only do one operation on vectors at a time. Basically, doing it procedurally like this is horrible

Or I suppose you could have each vector as a pointer to a block of memory which you've malloc()ed (and pass that to vector functions). But that is, in essence, a very bare-metal OOP implementation (from a C++ perspective). Which is a loose equivalent of a very famous anti-pattern: "The platform effect".

09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 6th May 2010 21:44
Another big advantage for OOP (other than object's having identity, performing operations on objects, rather than passing object to operations, etc), is that it actually cuts out a lot of work you need to do.

Lets say you have a Player class that performs all the operations that any ordinary player in a game would do. You can 'extend' this class into a, say, Enemy class, using inheritance. This means that you can do everything with an enemy that you can with a player, with literally no work at all. Then, you can work on adding extra functionality only to enemies, and, if you want to do something differently with enemies than for players, you can 'override' those actions.

This means you can work on massive pieces of software and make it appear like no work at all. Procedural programming doesn't do this for you, and there's no way any 4GL will for a long time.

"everyone forgets a semi-colon sometimes." - Phaelax
BearCDP
15
Years of Service
User Offline
Joined: 7th Sep 2009
Location: NYC
Posted: 6th May 2010 22:51
Structured programming has its uses, but ultimately is rather irritating.

I tried to write library code for DBP, and found that the safest way to reduce errors from name duplication is to invent awkward prefix acronyms. Thus, every function and variable not contained in a type was prefaced with ABC, CDP, BPJ, whatever.

Looking back at a lot of larger examples of C and non-oop C++ I code I now realize why I had such a difficult time understanding it, it was full of this crap. Encapsulation of both data and procedures by itself--with no inheritance or interfaces or anything--is more than enough to convince me of the usefulness of OOP.

It's true that there are some issues with OOP and how it's been developed over the years, but this article doesn't address of any of those issues particularly well. And it's possible to recover from bad OOP--have you guys ever read Game Coding Complete? Before the "interface" concept became really popular, the multiple inheritance at Origin Systems got so convoluted that they reached a point where they started exceeding the total amount of member fields that the compiler allowed. At this point they'd take a single variable like an integer, use the first 4 bits to store one value and the second group of 4 bits to store another value. Fortunately, we've moved on from this.

Check out this WIP flash game from the Global Game Jam!
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 6th May 2010 23:56 Edited at: 6th May 2010 23:57
OMG! That guy (from the article) is not a .NET developer for sure.

Why would anyone write:



Instead of


????

Okay, maybe it he wants to change color for a bunch of controls, but even then if it was not OOP it would still be the same.

[center][center]
BearCDP
15
Years of Service
User Offline
Joined: 7th Sep 2009
Location: NYC
Posted: 7th May 2010 03:40
I THOUGHT that was a weird line of code, but I haven't used any XNA classes outside of the generic collections and XNA stuff. Thanks for clarifying that.

Check out this WIP flash game from the Global Game Jam!
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 7th May 2010 04:06
I feel like I should argue a point... but I've never been in a professional programming environment, or worked on a large project, so I would be speaking with no experience.

I'll just say... I agree that object oriented code seems to be very redundant sometimes (Like when several objects share a similar calculated value, and it ends up being calculated multiple times, or a similar object is created multiple times), and it can be bloated. I think that the main issue is not to let code flow restrictions get in the way of the algorithm / task at hand.


bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 7th May 2010 04:24
Quote: "I think that the main issue is not to let code flow restrictions get in the way of the algorithm / task at hand."


I agree. That's what fascinates me with PHP. I can use both OOP and procedural programming

Interplanetary Funk
15
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 7th May 2010 04:34 Edited at: 7th May 2010 04:36
I'm not an expert programmer, but I do find OOP a lot easier to get my head around, especially when managing big chunks of code, sometimes it seems pointless, but to say it's failed is just plain moronic.
I can't think of anything that is not written in C++ or some other OOP language full stop.
Having a quick look through the article, the writer seems either very ignorant towards programming, or is completely incompetent at it and is blaming the tools.

some thing that annoyed me about this article:

Quote: "There’s no evidence that the OOP approach is efficient for most programming jobs"

sorry, but almost everything I've read by professional programmers state that OOP is brilliant for big projects as it is more efficient than having tens, maybe hundreds of functions and is a lot easier to maintain. Plus, if it was so inefficient, why are almost all games written in C++ or other OOP languages? BECAUSE THEY ARE FAST. duh.

Quote: "And once the OOP takeover starts, it can become difficult, sometimes
impossible, to replace those OOP people."

Another point from my readings, OOP makes the code a lot easier to understand so when the original programmer leaves the project and a new one replaces them, they can quickly understand what the code is doing and where it's doing it.

Quote: "sloppy taxonomic naming practices"

It's my understanding that most places have a programming standard so all the developers can understand one anothers code.?

Quote: "programming is fundamentally linguistic,
an act of communication."

programming also requires a very logical mind as well. Its not simply as if you can go "Hello. Make a player that has an AK-47 and can shoot lasers with some very smart enemys" etc. (http://www.somethingawful.com/d/news/game-program-code.php)

Quote: "Database systems embedded
within successful companies often must be highly adaptable--responsive to the ever-changing
needs of a dynamic, effective corporate culture. OOP database management by contrast often
results in relatively inflexible schema,"

That's completely wrong IMHO. With OOP it's simply a matter of changing the code in one place or just adding a new object, which makes OOP incredibly flexible.

Quote: "the idea that with OOP you can easily reuse objects you’ve
previously written for other programs, or more easily update programs if they need modification
later on.
This, too, is a largely bogus claim."

Actually, I do that quite frequently.

and when he complains about OOP scoping, I personally find that very useful.

this bit made me LOL however:
Quote: "Computer programming today
is in serious difficulty. It is
controlled by what amounts to a
quasi-religious cult--Object
Oriented Programming (OOP)."


Anyway, as I said earlier, I think the writer is either incompetent at programming, or completely ignorant.

That's just my two cents though (maybe a bit more than two, but y'know =])
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 7th May 2010 07:11 Edited at: 7th May 2010 07:12
Quote: "I agree that object oriented code seems to be very redundant sometimes (Like when several objects share a similar calculated value, and it ends up being calculated multiple times, or a similar object is created multiple times"


That's the whole point of having objects. You can create an object and have it instanced multiple times. Can you tell me why this is more inefficient than regular procedural programming where you have multiple identical things being calculated? For example if you had a game like Mario with a dozen baddies on the screen. How would the procedural way of handling this be "better" than the OOP way?


Senior Web Developer - Nokia
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 7th May 2010 07:37
Quote: ""How would the procedural way of handling this be "better" than the OOP way?"


or vice versa

Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 7th May 2010 08:35
Quote: "That's the whole point of having objects. You can create an object and have it instanced multiple times. Can you tell me why this is more inefficient than regular procedural programming where you have multiple identical things being calculated? For example if you had a game like Mario with a dozen baddies on the screen. How would the procedural way of handling this be "better" than the OOP way?"


I meant more like... Looking up a function or variable. Say... each baddie had an unnormalized direction vector, and you needed the normalized vector for several different, mostly unrelated things (maybe updating the background, calculating other units' AI, etc.) If the vector object has a function that returns the normalized vector, and recalculates it each time, with object oriented programming, it's very very easy to just want to call vec.get_normalized() every time, and can result in redundant calculations.

Not saying that it necessarily slows down code, but it can make it easier to do stuff like that. (again, disclaimer, coming from someone with zilch professional experience )


BiggAdd
Retired Moderator
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 7th May 2010 09:40 Edited at: 7th May 2010 09:41
Quote: "or vice versa"


Because the OOP way is quicker and easier in the long run for the programmer and it makes the code much neater.

Michael P
19
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 7th May 2010 13:57
OOP is very important, the person who wrote this article definitely does not understand OOP and most of what he is saying is completely wrong!

OOP reduces development time but the main benefit is improvements in reusability, testability, maintainability and understandability.

You can easily extract a module and use it outside of the system it was originally designed for (if that module is written properly). You can localize testing and maintenance to a single module which is much more practical. Objects are naturally easier for humans to understand, they make sense in most software systems.

There are some cases where procedural programming is better but most of the time OOP is a much faster way of developing software.

The performance overhead is very minor in most cases so it doesn't make sense to bring it up as a negative point of OOP. In terms of costs the biggest cost is usually the software by a large margin. Thus it is cheaper to upgrade the hardware than optimize the code. Well written code is more important than fast code.

Darth Vader
20
Years of Service
User Offline
Joined: 10th May 2005
Location: Adelaide SA, I am the only DB user here!
Posted: 7th May 2010 16:54
This is awesome! I can actually for once in my time on this forum understand this conversation because I've been studying Java!

Yay I need a badge...

Interplanetary Funk
15
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 7th May 2010 20:30
*gives darth a badge*
BearCDP
15
Years of Service
User Offline
Joined: 7th Sep 2009
Location: NYC
Posted: 8th May 2010 00:36
Quote: "I meant more like... Looking up a function or variable. Say... each baddie had an unnormalized direction vector, and you needed the normalized vector for several different, mostly unrelated things (maybe updating the background, calculating other units' AI, etc.) If the vector object has a function that returns the normalized vector, and recalculates it each time, with object oriented programming, it's very very easy to just want to call vec.get_normalized() every time, and can result in redundant calculations."


Why recalculate it every time? Just recalculate it every time it changes. You have to provide your own getters and setters for it anyway, so each time you change the value, recalculate the normalized vector and store it in a field. Yes, you add an extra few bytes to your vector class, but that's the trade-off: size vs. speed.

Check out this WIP flash game from the Global Game Jam!
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 8th May 2010 01:17
Quote: "Why recalculate it every time? Just recalculate it every time it changes. You have to provide your own getters and setters for it anyway, so each time you change the value, recalculate the normalized vector and store it in a field. Yes, you add an extra few bytes to your vector class, but that's the trade-off: size vs. speed."


That was a very obvious slow-down, but it's not always like that. It might be engrained in other code, and storing stuff in an extra variable might seem highly redundant. Combine this with the more black-box programming, where someone may have let a value be recalculated because it would seem too redundant to create an extra variable, and it's easy to get a situation like the one above.

But still, I realize it's not that big of a deal, it's just a thing that kinda bugs me about highly OOProgramming.


Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 8th May 2010 03:20
Quote: "where someone may have let a value be recalculated because it would seem too redundant to create an extra variable"


When you write a part of a program, you can save memory or save CPU cycles, and there's always a situation for either. If you need to save memory for other purposes, you will have to calculate those numbers every tick (easy on memory, hard on CPU). If you have a slow processor you may choose to pre-calculate the numbers and store them as variables for lookup (hard on memory, easy on CPU).

I'm not sure your examples are pointing out anything that's specific to OOP. This kind of decision making would occur in a procedural program too.


Senior Web Developer - Nokia
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 8th May 2010 10:41
Quote: "Because the OOP way is quicker and easier in the long run for the programmer and it makes the code much neater."



Really ? http://www.csm.ornl.gov/~v8q/Homepage/Projects/Papers/spetep04.doc

Michael P
19
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 8th May 2010 14:33
That article focuses on initial development time and states that there is no difference. I agree with this, the real advantage is primarily in reusability and maintenance. The article talks about how reusability improved by 2-3 times. Most devlopment time is spent in maintenance so initial devlopment time is comparitively unimportant.

BiggAdd
Retired Moderator
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 8th May 2010 16:11 Edited at: 8th May 2010 16:13
Quote: "Really ? http://www.csm.ornl.gov/~v8q/Homepage/Projects/Papers/spetep04.doc"


Do you believe all the 28 page long documents you read on the internet?

Quote: "reusability and maintenance"


Exactly.

David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 8th May 2010 16:17
Quote: "Really ? http://www.csm.ornl.gov/~v8q/Homepage/Projects/Papers/spetep04.doc"


So are you genuinely convinced OOP is worthless, or are you playing devil's advocate here? Or do you have preference for neither proc/OOP?

09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 8th May 2010 21:57
Quote: "Really ? http://www.csm.ornl.gov/~v8q/Homepage/Projects/Papers/spetep04.doc"


By that argument I would argue procedural projects take longer to make in the long run, because you don't have reusable objects and there will be by definition code duplication.


Senior Web Developer - Nokia

Login to post a reply

Server time is: 2025-05-12 14:33:21
Your offset time is: 2025-05-12 14:33:21