Live data from Hacker News

Ask HN: How to Learn OOP

news.ycombinator.com

31–40 of 78 posts

Re: Ask HN: How to Learn OOP

#31

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…

This is actually a really good summary. I also agree on learning Smalltalk to learn OOP since it has a really easy syntax, you can deep dive into implementation details if you want to easily and it enforces some best practices like setter and getter instead of giving you the ability to just declare members public. I learned Java in University and switched soon to Objective-C and it took me a while to see reasons behind getters and setters especially since I worked only in small teams on short living projects at that time. Also s Smalltalk is purely OOP so you won't get distracted by numbers and bools behaving differently. And finally it gets you to think in data structures thanks to the collection methods.

Re: Ask HN: How to Learn OOP

#32

Earlier quoted context omitted.

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

I actually watched that talk twice. The technique of introducing a seam set off light bulbs in my head that didn't go off the first time I watched it.

Re: Ask HN: How to Learn OOP

#33
post #13

Bertrand Meyer Object Oriented Software Construction is excellent. It details the concepts of OOP and remains very independent of the programming language.

How would you develop the language specific skills?

The hope behind learning paradigms, like OO or functional, is that you can transfer what you learned in one language to another. So if you're just looking to level up your OO, your best bet is to pick up the most interesting OO book you can find and just follow along. I like Practical Object-Oriented Design in Ruby by Sandi Metz.

It's going to be difficult to find excellent OO resources for every conceivable language and stack.

Re: Ask HN: How to Learn OOP

#35
I remember stumbling across this book in my university library back in 2000, that really helped me understand the principles when all the other books were talking far more about syntax and functionality without really explaining the "why" part.

https://www.amazon.com/Introduction-Object-Oriented-Programm...

Re: Ask HN: How to Learn OOP

#36
I'd highly recommend Dr. David West's "Object Thinking" book. It does an excellent job of (1) describing how most programmers who use an OO language fall into writing "small Cobol" programs and (2) how to avoid this.

Re: Ask HN: How to Learn OOP

#37
I didn't learn OOP very well in school, but once I wrote enough code I started to see that it was becoming a massive cluster fuck and I couldn't remember what I wrote half the time. So I broke it down into functions, but then I was passing huge amounts of arguments into some of the functions. Then I realized I had a lot of functions where the 90% of same thing was happening so I passed a keyword into the function to make it do something slightly differently in an if else. Then I realized I could create a class, store the variables in the class and call the class methods without passing the arguments, which was much cleaner. Then I realized that I could create a class that inherits and overrides the 10% difference of the other class, which was again much cleaner. Those are the basic two problems that OOP solved for me and I've taken it many steps further a couple of times, but it can definitely be abused. If you get to that point, you should start looking at design patterns to learn how OOP is used correctly. Lynda.com has some good videos on OOP design patterns you can use their free trial for. They're by the author of one of the highest rated books on design patterns and pretty short.

Re: Ask HN: How to Learn OOP

#38

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

Seconded. As a self taught generalist ruby/python/java guy, I read POODR two years ago and it stands out as a great investment of time. Lots of "a-ha, that's what I should be doing" moments. Has anyone checked out her new 99 Bottles book?

Re: Ask HN: How to Learn OOP

#40
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.

To be a better programmer?

I don't think I'll ever work in a purely functional language, but I still took an online course to learn something about functional approaches. It was great; it has definitely changed how I program for the better.

Post reply on HN