Live data from Hacker News

Ask HN: How to Learn OOP

news.ycombinator.com

21–30 of 78 posts

Re: Ask HN: How to Learn OOP

#21

Practical Object-Oriented Design in Ruby (POODR) by Sandi Metz opened doors for me - http://www.poodr.com/

If you only get one book, get this one. It is more about 'why' than about 'how' and shows what tradeofs are involved in one or another design, what problems you can run into with different solutions. Also, there is a new book by Sandi coming out: http://www.sandimetz.com/99bottles/ Her talks are highly recommended too.

Sandi Metz is great.

This talk is such an amazing example of clear thinking:

https://www.youtube.com/watch?v=8bZh5LMaSmE

Re: Ask HN: How to Learn OOP

#24
post #11

If you’re going to learn OOP, you need a larger project to go along with it so that you can understand ASAP that it only makes you write more code, over-complicate problems, and makes your applications hard to understand, and debug. It’s going to save you from spiralling into the typical “OOP is fine, i’m just not doing it right, i should’ve designed that differently” loop that most college graduates go through durin…

(Over)using inheritance hierarchies can have negative effects, but if you think that in general OOP results in more code then you need to go and develop some serious C. You spend a lot of time manually accounting for multiple instances of things, in a way that you get for free in an OOP language like C++.

Re: Ask HN: How to Learn OOP

#25
post #5

May I ask why you want to learn OOP? You don't need it at work right now, and you'll probably never need it. Not even in interviews.

What? http://githut.info/ 5 out of the 6 top languages on Github are OOP(not counting CSS). And PHP still supports OOP. Pretty much if you want to create an app for web/mobile/desktop with one of the most common languages you are going to end up using OOP. How can you "never need it"?

Re: Ask HN: How to Learn OOP

#26

You can always check out Object Oriented Analysis and Design by Head First ( http://www.headfirstlabs.com/books/hfooad/ ). Their books are more about learning the concepts than the theory so they employ a lot of games and learning activities. They are a lot more interesting than a textbook on OO, even if the format seems a little juvenile at time (I mean they have word-searches and crosswords with key terms).

That's a terrible book (and series) to learn from, the level of visual clutter on each page distracts from the actual task of learning anything. I had a copy of "Head First Design Patterns" and after only a few pages I thought my eyes were going to fall out.

I found Bruce Eckel's "Thinking In Java" useful back in day to learn OO programming and concepts. Much of what you learn is transferable to other languages.

Re: Ask HN: How to Learn OOP

#27
post #24
post #11

If you’re going to learn OOP, you need a larger project to go along with it so that you can understand ASAP that it only makes you write more code, over-complicate problems, and makes your applications hard to understand, and debug. It’s going to save you from spiralling into the typical “OOP is fine, i’m just not doing it right, i should’ve designed that differently” loop that most college graduates go through durin…

(Over)using inheritance hierarchies can have negative effects, but if you think that in general OOP results in more code then you need to go and develop some serious C. You spend a lot of time manually accounting for multiple instances of things, in a way that you get for free in an OOP language like C++.

Right now i do iOS development mostly in pure C, outside of the unavoidable Objective-C. So i do have the right experience.

The issue with OOP is that as soon as you introduce inheritance, and things like virtual functions, you’re introducing variable program behaviour based on context. And most of the time you end up having to special-case things up in the hierarchy because nothing ever goes as you envisioned it.

Structuring your code so that you have simple data and code that operates on the data means that what’s happening in the code at a particular time is always explicit, and any deviations based on objects the code operates on are right there in front of you, not hidden in 4 virtual function implementations in different files.

It’s all special-case code you have to write anyway, but if written in OOP fashion, the complexity of it is most of the time unclear, and it’s hard to judge what code will actually be doing just by glancing at it.

Re: Ask HN: How to Learn OOP

#28
post #11

If you’re going to learn OOP, you need a larger project to go along with it so that you can understand ASAP that it only makes you write more code, over-complicate problems, and makes your applications hard to understand, and debug. It’s going to save you from spiralling into the typical “OOP is fine, i’m just not doing it right, i should’ve designed that differently” loop that most college graduates go through durin…

More code, more complexity? See this: https://www.youtube.com/watch?v=8bZh5LMaSmE

The speaker just introduces more OOP complexity into already complex OOP code. All that’s going to do is make the code even harder to modify or step through.

Re: Ask HN: How to Learn OOP

#29

Here's the OOP model: A program can be modelled as a set of communicating black-box objects, with their own state. The idea is to separate concerns, abstracting away implementation behind well-defined interfaces, which can in turn be implemented by other objects to cleanly replace parts of the application. The rest of OO is pretty much just understanding Design Patterns (a set of names for common interactions between…

In addition to what you said, OO to me is all about things sending messages back and forth between black boxes, such that the message contains everything the recipient needs to either do its job or find the information needs to do its job. Alan Kay (since you brought up Smalltalk) has said that he wishes he called it Message Oriented Programming instead, because people took the wrong message out of the name. In this line, Erlang and Smalltalk, and to a slightly lesser extent Objective-C more fit in with this. But you can code that way in Java or whatever, if you just think about the message between entities being an actual first order thing in your system.

Re: Ask HN: How to Learn OOP

#30

As soon as you know a little bit, I would start as soon as possible to learn by copying existing code. Learn by using different frameworks, which show you how to do things. The classic OOP examples ("This class is a car, this Mercedes class inherits from the car class, it also has a method to move, and this Mercedes object is an instance of a Mercedes") are pretty easy to grasp for a person of normal intelligence. Th…

If you think inheritance is central to OOP, then you are mistaken. The most important aspect of OOP is dynamic dispatch (e.g. objects accessed through Java interfaces), and that's closely related to the idea of messaging. Have a read of what other people are writing here.
Post reply on HN