Your Code: OOP or POO?

Thank you, gentlemen. I am not a programmer, although I want to learn to do so, and I detest jargon that obfuscates and stands as a barrier to learning how to program, and that is exactly how I see all OOP discussions. I got an ‘A’ in a college VB6 class, but my gut reaction to even the mention or thought of VB6 for years was the deepest and most profound hate that I have ever experienced towards anything in my life.

I pride myself in being able to take the very complex and to accurately reduce it to the very simple. I learned the skill in law where I would address complex arguments and take them apart and recast them into their simple, accurate substance. (See, e.g., Pratt v. Sumner, 807 F.2d 817 (9th Cir. 1987).)

VB6 is unintuitive garbage. Only an utterly artless soul would call it intuitive. Think Apple iPod, and you have intuitive, think of a digital watch that needs to be reset after the instructions are lost, and you’ll realize why I never wear one. If I could tie Bill Gates to a chair and torture him for a week or so, it would not be about his unfair monopolizations, it would be about VB6.

Since then, I’ve had a softening after learning and using a little VBA to write text in Word for an HTML file rather than writing every line in HTML by hand.

However, the language I’ve actually been able to do things with has been javascript, and, but for the browser-specific quirks, I like it. It’s relatively easy to understand and relatively easy to use creatively. From what I’ve read, it can be used OOP style, though I wouldn’t know an OOP if it hit me in the eye. My intended strategy was to use javascript and the browser for rapid application development, and then to learn a real language when I’ve got the logic down and want to create apps.

However, with the learning curve of using any of the so-called real languages, I’d prefer to choose narrowly and well, and so I enjoyed reading your posts, all of your posts. You showed a lot of variety and a natural use of your jargon rather than the stiltified text blobs of nonsense that I simply cannot read.

Although you have not helped me choose a language to study (I’m leaning towards Python), you have helped me see some of the problems with OOP thinking in general.

Thank you.

OOP is an excursion into futility.

It is oversold, anbd rarely are the benfits worth the costs.

Far from making code clearer it generally adds to obfuscation.

A methodology or tool, adopted with religious fervour, cannot substitute for good design and high quality coding.

What is required is clear thought, clear structure, well chosen names, and precise, accurate, and pertinent commenting.

There is nothing that can be done in C++ or Java that could not be done quicker, more clearly and just as effectively in C, and in other problem domains completely different languages such as LISP and Prolog are in any case more appropriate tools.

The drawbacks of OOP become most apparent when trying to maintain an OOP-horror. The sequence of procedure calls and values of variables was easily tracked in old-fashioned C. Troubleshooting is an order of magnitude more difficult in C++ or Java.

IMHO, OOP is awesome.

Not because of inheritance, or interfaces, or any of the other feature-candy. OOP is awesome because it’s a great tool to describe things.

To make OOP easy, here are a few concepts to add to POO.

OOP IS procedural:
…as long as you want it to be. Every OOP program starts from static int main() (or the equivalent). Until you actually instantiate a class, this is still a purely procedural program because it is going from line 0-n.

OOP IS modular:
Don’t mash all the parts of the program into one massive class. Create utility classes to move the implementation of the parts out if the main program. IE. The static int main() is just a an executive function that calls the shots, where separate static utility classes are the departments that handle the details and resources of the requests. The executive’s time (amount of code) is too important to worry about the menial details of the rest of the organization. OOP programs usually take fewer lines of code overall to handle everything but at the sacrifice of becoming more complex so they need to be managed appropriately. IE. chew before you swallow.

Most abstracts are Scholars and Artists not Inventors:
Unless you’re trying to prove you’re smart (and like wasting other people’s time) abstracting parts of an OOP program is a waste if time. 95% of the time, anything in life can be described in simple terms. Apples are red. Dogs bark. Traffic light colors are red, green, and yellow, a Car’s acceleration can be described by… s***. Too complex to be described in simple terms so it needs to be broken down to finer levels of granularity before it can be addressed. Maybe throw a little inheritance-foo, a physics utility class (for reuse-ability) with static functions describing the fundamental math, and it becomes do-able. IE. Don’t create a Pollack painting and expect enlightenment. Create technical drawings/models first when you’re designing an aircraft.

I think that the issue with OOP (and why so many people hate it) is not technical, it’s sociological. I learned OOP on my own out of the classroom, but I could imagine professors getting their panties wet contemplating all the possibilities of uses for all the constructs built into modern OOP languages. Of course all of features sound great in a theoretical aspect but realistically, most are useless the majority of the time. Use OOP for it’s intended purpose, to describe things, properties of things, and characteristics of things. Don’t inherit a human class from a cell class or you’ll have a lot of unnecessary crap to explain in between.

I went from a self-taught web dev background (HTML/CSS/JavaScript/PHP/SQL) to C# and it took me less than 6 months to get comfortable with all the fundamental constructs of OOP (Except interfaces which IMHO think are pretty useless so far). I understand why most people are frustrated with OOP. Most study materials are full of abject theory and poorly written examples. If you’re learning C# check out http://www.blackwasp.co.uk/CSharpFundamentals.aspx. I’m not affiliated with this site but I couldn’t begin to explain how much it has helped me. It’s like the w3schools of C# (but written better).

For the procedural programming purists out there who don’t benefit from OOP, do one thing and do it well. Procedural no doubt has superior benefits of performance and simplicity for back-ends like servers, kernels, console apps, and services. But, for event driven applications like GUI front-ends, file system tools, database ORM, and operating system components I’d much rather use OOP.

If I’d studied rhetoric, I’m sure I could have named the device used in this sentence: I’m not a fan of object orientation for the sake of object orientation. Regardless of the appropriate label, though, isn’t it so that the opposite position is clearly impossible to hold on to? Everything we do is a means to an end.

Sadley many programmers do abuse objects, but this just sounds like a bunch of old time procedural programmers that are having a hard time catching up.

  1. Be organized classes and write the application to allow load and display all kinds of image files with the extensions in the following categories. Jpg,. Bmp,. Dib,. Gif. Programs that change the image as horizontal turn, vertical (mirror), dial 900, the gray level to get the sound, get the wrong picture of the two special functions and stored into different (but still one of the significantly above).
    Requirements: The thought by the audience. Can be programmed in the Windows environment. Do not use static function as eg in the theory, does not switch, in the case.
  2. An input directory is a folder or a file, a directory of many input folder. Drive is a special case of the directory. Be organized classes to perform concept computer, disk drive, folder, file with the relationship as over. Write the application for permission to view the content of the object type as similar functions of the software Tree NC.
  3. For the types: circle, ellipse image, the polygon, crescent,'s wings, rhombus, parallelogram, trapezium, rectangle, square, triangle, triangle square, square triangle needed. Write a program that allows applications to create (or enter) the two pictures in one of the above. Notice in two pictures that are not intersecting, if any color to the bowl and the dark sea of the interface. The user can press the arrow keys to move one of two pictures, the +, - to zoom out one of the two pictures. Programs can work with all kinds of equipment in different graphics modes, text mode (each a ‘*’ is a moral pixels). Program can zoom to pixel morally, from the graphics mode to text or vice versa, users do not see the object to be exhaustive
  4. A road of many road Polyline (line), each line can be a straight section (Strait line), and (ARC), or a bezier polyline. Organization of classes necessary, establish the relationship between class and write a program that allows to create polyline, create a copy of the polyline, zoom in, zoom out, turn polyline, polyline separation (separation of the polyline in the a polyline into the road (line, arc, bezier), define two functions have polyline cross or not?

That’s a very nice post! I’m french and I googled this php poo best practice logical class which brought me here… That was a very interesting experience to read this, and the comments extended the object of debate, which is even better :wink:

Many people think tend to believe that (I’m talking about PHP but it can be true for various languages) OOP in PHP is best practice. It’s not properly thinking, because OOP itself brings its own set of best practices to have in mind when using it. Though when you start mastering it, you win some time, I ensure… This leads me to speak about frameworks, which is out of topic, but I learned OOP thanks to a PHP framework, and I wouldn’t revert back to no-framework. Or I’d need Ritaline.

i love OO programing i am 12 and i am already working on threads, networking, encryption (jsse[java secure socket extension]) and i am just about to start data structures. I know my sight is a little pathetic but i really don’t know what to do with it. for suggestions email me personally at kitten_elrer@yahoo.com

OOP is for humans, not for the machine. Does the machine care if your if you have implemented inheritance? Not really. If your code is perfect OOP does it run faster?

Pentium Processor: “I just love running OOP code, it feels so good!”

OOP is best for organization of code and should be used as such. When using OOP, ask yourself, do I really need a interface or abstract class, do I really need a base class. Sometimes it is just better to write just to write the damn class.

OOP can simplify but it can also abstract and obscure.

The problem I have with many arguments against OO is that they seldom are specific, but usually very generic, and hence they become hard to evaluate. Take the first comment by Paul Graham:

“Object-oriented programming generates a lot of what looks like work. Back in the
days of fanfold, there was a type of programmer who would only put five or ten
lines of code on a page, preceded by twenty lines of elaborately formatted
comments. Object-oriented programming is like crack for these people: it lets you
incorporate all this scaffolding right into your source code. Something that a Lisp
hacker might handle by pushing a symbol onto a list becomes a whole file of
classes and methods. So it is a good tool if you want to convince yourself, or
someone else, that you are doing a lot of work.”

Concerning the first part of this comment: is it a problem to write:

class Math {

}

around your math functions?

Second, he says:

"Something that a Lisp hacker might handle by pushing a symbol onto a list
becomes a whole file of classes and methods. "

what? - what could he possibly mean here? Lists is a library class in Java.

Allright. So much for that comment.

The next comment is that of Eric Lippert:

“What I sometimes see when I interview people and review code is symptoms of a
disease I call Object Happiness. Object Happy people feel the need to apply
principles of OO design to small, trivial, throwaway projects. They invest lots of
unnecessary time making pure virtual abstract base classes – writing programs
where IFoos talk to IBars but there is only one implementation of each interface! I
suspect that early exposure to OO design principles divorced from any practical
context that motivates those principles leads to object happiness. People come
away as OO True Believers rather than OO pragmatists.”

No, you don’t need to write abstract classes and interfaces. In fact, most programmers don’t do that even for big programs.

I have this impression that people arguing against OO do not program OO themselves, and observe fragments of code, to which they react as if these fragments were proper representations of how OO code is normally written.
Their arguments are based on existence proofs: there is exists a bad OO program,
hence OO is bad.

If there is a “good” way to do OOP and most are doing it the bad way in practice, then perhaps OOP needs to be redefined. The practices and techniques that make the “good way” need to be isolated and renamed something else. It’s not OOP that’s good, but apparently a sub-set of it, but nobody can define and document “it”; only say, “I’ll recognize it when I see it”. That’s not good enough in the age of openness and science. That’s Alchemy-Oriented-Programming.

I personally find set-theory, or some variation of it more promising. Associations don’t have to be hard-wired that way, meaning you don’t have to get the design perfect up-front in order to use it effectively. OOP’s associations are too hard-wired, and not searchable and query-able in a meta kind of way, except with spaghetti class browsers. Perhaps the “fight” over OOP is graphs (pointers) versus sets.

The Functional Programming people are giving OOP a run for it’s money. In my opinion they are just as zealotic as the OOP crowd, but it’s nice to see visible competition to OOP out there, even if it is run by other zealots. Fight zealots with zealots? IT is so not science.

I learned C in 1992, never liked it . In 1998 i programmed an extensive algorithm, that grew a neural network using genetic algorithm and really fast regression…I programmed it in C++. I was new to OO. It took 6 weeks of reading up on C++, 6 weeks of design and 6 weeks of implementation. it worked, it performed really well and fast on any data I threw at it. I think if i had to write it in C or structured programming language, it would take 6 months min…and would have 0 reusability. I dont even want to think about it…

I have an estimate of the structured time, because I wrote parts in Matlab and had to piece the things together , so i have an idea of how long things took in an interpreted envirnoment…which is fast… but not powerful.

Amongst other, I used a composite design pattern, going 4 levels deep. Try and do this in structured programming… is like a recursive function , where you would have to pass whole trees of data down.and each element would need to know which part of the tree data it can change…would be a nightmare…not that it can’t be done…and with powerful libraries should be possible…but back then the internet had only just begun and such libaries were few in between and the best ones were all written in C++ in any case…probably for the same reason. Now I would use C# because of garbage collection etc…

Yes horrible OO is probably like structured code with GOTO, but good OO is sometimes like magic compared to structured.

Functions. Look at the source for Apache or nmap. :stuck_out_tongue: