![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#41 | |
|
Hobbyist Programmer
|
Quote:
Please don't misunderstand. OOP can be a huge benefit to developers if you realize what features are sane and which aren't. Grouping together data with methods and being able to create multiple instances of a class is pure genius. Everything else... not such much, except maybe in a few isolated cases (hell, even goto is acceptable once in a rare while if you know what you are doing). |
|
|
|
|
|
|
#42 | ||
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
With a sufficiently large codebase, it's often difficult to hold the complete layout in your mind at once. But if the system uses a sane amount of inheritance, you can get a good idea of what a class does by looking at what classes it inherits from. There have been times when I've come across an unknown class, but been able to infer it's general purpose from its ancestors. Also, inheritance reduces repetition, which is always a good thing to have. I think that you don't really have enough experience to judge the merits of OOP. If your sole experience of OOP is C++ and Java, then I suspect that you don't really have a complete understanding of OOP. In Alan Kay's words: Quote:
|
||
|
|
|
|
|
#43 | |
|
Hobbyist Programmer
|
Quote:
My overall point is that OOP has a lot of features that promote bad practice. If one were to take OOP and strip it of all these flaws, then it would be quite nice to write code for. If you say that C++ sucks at OOP then I'll take your word for it. Maybe one of these days I'll pick Python up since I've heard so many good things about it. Until then, I'll stick with good, old fashioned C. Besides, OOP isn't the second coming. You really aren't going to be *that* much more productive than in a non-OOP language. Again, I realize OOP is more than just in the language, but in non-OOP languages, the syntax causes you to think about objects in a proper manner and not like a kid in a candy store with dozens of new keywords that are just begging the programmer to do something stupid like multiple inheritance. Also it is never acceptable to put everything under the sun in a class {...}. Anyone who thinks that it is necessary for all code to be inside a class needs a good hard slap across the face. Strong words, yes, and I realize I sound border-line douche-bagish, but you have to wonder who the hell taught this kids programming when they come out of college thinking OOP is a religion. |
|
|
|
|
|
|
#44 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
I still can't quite see why you object so strongly to inheritance, as in many situations it provides a much cleaner solution than the procedural approach. For instance, take the following code:
python Syntax (Toggle Plain Text)
If I wanted to modify the above code to support multiple players, that wouldn't be too hard, either. I could have Player.message send the message to a TCP socket, rather than to STDOUT. I could even leave out the definition of the message method altogether, and have subclasses inheriting from it for single and multiplayer modes. I'm curious as to how you'd write the above in a procedural style, and yet still retain the future flexibility that inheritance allows. For instance, let's say I wanted to have a squeaky toy: python Syntax (Toggle Plain Text)
python Syntax (Toggle Plain Text)
|
|
|
|
|
|
#45 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 243
Rep Power: 3
![]() |
Re: Why OOP?
Being much more inexperienced than possibly all of you, I didn't know that C++ is not to be taken as an example of OOP. However, allow me to disagree with Darkhack.
At first, programming concepts in general require much thinking before adopting any of them. Not all programming concepts are suitable for every situation. In some cases, utilizing procedural programming is all that one needs to solve a specific problem, if the project is small. But I find it hard to imagine that one could not use OOP for a larger project. As for inheritance, I think it's god sent. I am programming in OBJC for 1,5 years and I find the way the language is organized brilliant. It is strongly based on inheritance. Apple is using ObjC as the main language for the Cocoa environment, and one thing it's being praised for is that the resulting code is clear, efficient, and projects from other languages can be stripped down to 5 times fewer the lines of the original size. And inheritance contributes a lot to that. OOP and every OOP feature have been created for a reason. Thinks became more complicated at one point, and the programmers needed something new. The fact that OOP is the leading concept in any big (and most small) project nowadays is not a matter of luck.
__________________
Project::Soulstorm (personal homepage) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Learning old languages | Wizard1988 | Coder's Corner Lounge | 26 | Sep 16th, 2007 10:10 PM |
| OOP design question | rwm | C++ | 7 | May 28th, 2007 2:46 AM |