Live data from Hacker News

Ask HN: How to Learn OOP

news.ycombinator.com

71–78 of 78 posts

Re: Ask HN: How to Learn OOP

#72

Earlier quoted context omitted.

Which really does not reflect reality at all. Outside of research/education, and stuff hobbyists are doing, FP typically isn't typically used alone. Some ideas are just borrowed from it and sprinkled onto OO languages to make things a bit nicer. FP has a lot of good ideas, but that doesn't make it reasonable to assume that it's all you need to know, or even the most important thing for you to know.

I didn't say it was an accurate reflection of reality.

I didn't think you did, was just commenting on what you'd mentioned.

Re: Ask HN: How to Learn OOP

#73
post #40

Earlier quoted context omitted.

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.

Yeah, I was going to say, OO is brutally overused and seems to be fading quite quickly in the new world of highly scalable systems, e.g. Spark, CouchDB and so on. Objects still have a place in widget sets, datetimes, etc. Overall though they were often used by default where there were better ways and just as often abused to allow a ton of shared state (globals in disguise), which almost always makes code harder to fo…

That's definitely true. I think classic OO works a lot better in a context where objects are relatively long-lived.

The problem is that the way most modern systems are scaled, they are very short lived. When the purpose of a code base is to turn HTTP requests into SQL queries and SQL results into HTML responses, then the objects end up being a thin layer between function calls.

That's not a necessary outcome; in a parallel universe something like Prevayler would have given us long-lived object graphs in a lot of the places where we now use OO languages on top of external databases. But that's sure not the world we live in.

Another factor that I think made things worse was the massive increase in the number of programmers during the Internet boom. I love working with code from master OO developers, especialy those of the test-driven, domain-driven sort. But OO approaches allow so many degrees of freedom that it's easy for relatively junior developers to make giant messes. Messes that I don't even think of really as OO, just snarls that happen to be in OO languages. Regardless, I think the September That Never Ended kept the average OO code base in a state much worse than the best ones.

Anyhow, I'm excited to see the state of practice moving forward, inch by inch.

Re: Ask HN: How to Learn OOP

#74
post #59

- Read SICP - Understand how all programs can be written as lists of lists of lists... and so on - Pick up the language that you work in. Identify what construct of that language allows you to approximate scheme/lisp lists. For me this is objects in java & php, and functions in javascript - Code your program as a list of lists of lists... in the language of your choice. - Congrats, you got OOP

Doesn't SICP stress closures more than lists? (And this list-heavy approach only really works in a dynamically typed language.)

Re: Ask HN: How to Learn OOP

#75

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…

Out of curiosity, why Java is not best language for reading OO? Any reason?

Re: Ask HN: How to Learn OOP

#76
post #74
post #59

- Read SICP - Understand how all programs can be written as lists of lists of lists... and so on - Pick up the language that you work in. Identify what construct of that language allows you to approximate scheme/lisp lists. For me this is objects in java & php, and functions in javascript - Code your program as a list of lists of lists... in the language of your choice. - Congrats, you got OOP

Doesn't SICP stress closures more than lists? (And this list-heavy approach only really works in a dynamically typed language.)

I have used it just fine in Java. "dependency injection" looks a lot like lists-of-lists...

And SICP talks about a lot more than any particular constructs. Its the sort of book you can come back to, and take what you need to go further.

Re: Ask HN: How to Learn OOP

#77
post #76
post #74

Earlier quoted context omitted.

Doesn't SICP stress closures more than lists? (And this list-heavy approach only really works in a dynamically typed language.)

I have used it just fine in Java. "dependency injection" looks a lot like lists-of-lists... And SICP talks about a lot more than any particular constructs. Its the sort of book you can come back to, and take what you need to go further.

I've recently actually done the latter, and gone back to SICP. Alas, it shows its age badly: it's too untyped for my tastes these days.

Yes, you can emulate dynamic typing in statically typed languages---but why would you want to if the static type system is expressive enough? (I can see how in Java dynamic typing might be the smaller hassle.)

Re: Ask HN: How to Learn OOP

#78

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…

Out of curiosity, why Java is not best language for reading OO? Any reason?

Because Java uses strong typing and largely early binding, which are almost always The Wrong Thing in OO.

Actually, by the Alan Kay definition, Java isn't even really OO at all. It just kind of looks like OO. You can apply OO techniques to it, but it's better to learn real OO than the bastardized version that's taught to Java programmers.

Post reply on HN