Live data from Hacker News

Ask HN: can you summarize OO for me in 64 words or less?

news.ycombinator.com

71–76 of 76 posts

Re: Ask HN: can you summarize OO for me in 64 words or less?

#72
You make objects out of a directed graph of simpler objects, recursively. To answer a message they can ask their acquaintances for help, make new objects, or change their state. To an object, all that matters about other objects is how they respond to messages.

This is more cohesive than parallel hierarchies of data structures and code that must be kept in sync.

(63 words)

Re: Ask HN: can you summarize OO for me in 64 words or less?

#73
Other commenters here have covered the theory well so I'll take the practical angle. OO in practice means Java and C#: procedural languages that make you organize your code as a collection of "classes", which means files. A class is a collection of related functions that you get to use after calling a "constructor", unless they're "static". Also a class can contain some data that's easily accessible to functions in this class; other classes can access it with "getters and setters", which is called "encapsulation". One class can "inherit" from another, giving you a more convenient syntax for calling functions in the "parent" class at the price of a little confusion for everyone reading the code.

People with advanced OO skills use clever techniques to write interesting programs. For example, sometimes we want to give a class (technically, "an object of the class") to other programmers without letting them know which class we gave them. To achieve this goal, we give them another class with a function to generate objects of the first class without telling them which one. If you have trouble following, don't miss the helpful diagram: http://en.wikipedia.org/wiki/Image:Abstract_Factory_in_LePUS... An award-winning book of twenty-three such techniques is required reading for good OO programmers.

So your gut feeling is right.

Re: Ask HN: can you summarize OO for me in 64 words or less?

#74

Earlier quoted context omitted.

Likening objects to things like refrigerators and toasters is where I get lost. Perhaps those examples work well in the classroom to help kids wrap their heads around the concept of OO ... I have sometimes thought the same thing. There are ample explanations of the use of OOP put in terms of stuff like, poodle inherits from dog, which inherits from mammal etc. or a car could be represented as a series of objects inte…

Try to go through the articles at: http://www.objectmentor.com/resources/publishedArticles.html Most articles carry some example to go with the concept being explained.

Thanks for this and the other above replies.

Regarding inheritance, I once had a conversation with a "application architect" who advised staying away from inheritance until you fully grok it, because it's easy to paint yourself into a corner with it (he then disappeared before I could question him further). The only issues I could think of at the time was stuff like say you have a bird class which contains a "fly" method, with duck and emu child classes (now I'm using the dodgy animal examples :P), the duck and most other birds should be able to fly, but the emu and some others should not. What is the better practice way of dealing with this issue? And what other adverse issues can arise when using inheritance?

It has been recommended to me in the past that when it comes to systems that require more abstract objects, this is where researching design patterns would assist. However, pretty much all the design pattern literature I can find is not directly related to my current language of choice, Ruby. I can find lots of stuff talking about design patterns in Java and whatever else, which still provides some utility, but is there any books/articles that anyone can recommend on design patterns etc. using Ruby?

Re: Ask HN: can you summarize OO for me in 64 words or less?

#75
post #33

What is Object Oriented programming? I wrestled with this one in school for a while, because the name is so screwy. What is an object? It's a blob of code. It's a walled off place in your computer's RAM that has variables and functions. It's just a bit of reusable code. Why is that special? If you've spent your programming life copying and pasting code in a text editor, it's probably not going to be readily apparent.…

So, you mean, "no". ;)

64 words... bah!

Re: Ask HN: can you summarize OO for me in 64 words or less?

#76
• Imperialism is a business policy, in it; it has produced small, bad, unsafe increase of market, and has jeopardized the entire wealth of the nation. It is irrational from the standpoint of the whole nation, and it is rational enough from the standpoint of certain classes in the nation. A state which kept good balance-sheet of expenditures and assets would soon discard imperialism.
Post reply on HN