Live data from Hacker News

How to Design Classes (in Ruby, Python, Java or any OOP)

ccs.neu.edu

11–20 of 26 posts

Re: How to Design Classes (in Ruby, Python, Java or any OOP)

#11
post #6
post #3

Earlier quoted context omitted.

I shamelessly clicked away as soon as I realized it was Java. Well, not completely shamelessly. I kind of feel like a "rassa-frackin' whippersnapper" disgustedly changing the radio station when stumbling on classical orchestral music. Then again I also feel a little dirty for comparing the likes of Tchaikovsky and Beethoven to Java...

No, this is quite right. Classical music is as bloated, heavy-handed, and decadent as Java. Good music is found in the 16th century and earlier, and in the 20th century and later. We can see this maps to software: good ideas are to be found in the 70s and earlier, and in some hoped-for new era yet to come . . .

You need to go get yourself a recording of Rubinstein playing Chopin's Nocturnes. Hurry!

EDIT: I seek no arguments. Wikipedia says nocturnes are generally thought of as "expressive and lyrical". Surely that should be of interest to hackers...

Re: How to Design Classes (in Ruby, Python, Java or any OOP)

#12
post #6
post #3

Earlier quoted context omitted.

I shamelessly clicked away as soon as I realized it was Java. Well, not completely shamelessly. I kind of feel like a "rassa-frackin' whippersnapper" disgustedly changing the radio station when stumbling on classical orchestral music. Then again I also feel a little dirty for comparing the likes of Tchaikovsky and Beethoven to Java...

No, this is quite right. Classical music is as bloated, heavy-handed, and decadent as Java. Good music is found in the 16th century and earlier, and in the 20th century and later. We can see this maps to software: good ideas are to be found in the 70s and earlier, and in some hoped-for new era yet to come . . .

Check out Haydn's "Lord Nelson" mass, specifically the recording by Banchetto Musicale (it's very light and clear). For the antithesis of heavy-handedness, pay attention to movements 2, 4, 5, 7, and 12. But the whole thing is only about 40 minutes and really easy enjoy start to finish, especially since those movements I mentioned are meant to contrast with the slower ones.

Movement 5, while not my favorite, is especially notable for being a canon at the 5th. It's quick, fun, the imitative counterpoint is very easy to hear, and at a minute-forty, hardly overstays its welcome.

Overall though, Western music between Bach's death in 1750 and Beethoven was anything BUT bloated and heavy-handed. Balance, taste, and clarity were highly valued.

Re: How to Design Classes (in Ruby, Python, Java or any OOP)

#13
This is the textbook for one of my classes at Northeastern. The prerequisite class used HtDP (http://www.ccs.neu.edu/home/matthias/HtDP2e/) and Racket (http://racket-lang.org/), and the focus was on design principles and writing good code more than it was on the actual language we were using. I'm expecting the same from this class, but I'm not against becoming more experienced with Java either.

Re: How to Design Classes (in Ruby, Python, Java or any OOP)

#14
post #5

Earlier quoted context omitted.

This book takes a theoretical approach to OOP. As the author said, this book is NOT about Java. Similarly, SICP is NOT about Scheme. Interestingly, It's the same author who teaches how to design programs with Racket, a lisp dialect. http://www.ccs.neu.edu/home/matthias/HtDP2e/index.html

The book opens with "What you'll learn: Java."

It actually says "What you won't learn: Java."

Re: How to Design Classes (in Ruby, Python, Java or any OOP)

#15
post #14
post #5

Earlier quoted context omitted.

The book opens with "What you'll learn: Java."

It actually says "What you won't learn: Java."

In my defense, this is what shows up on my screen:

  What you will learn
  What you won't learn
  Java.
Weird!

Re: How to Design Classes (in Ruby, Python, Java or any OOP)

#16
post #15
post #14

Earlier quoted context omitted.

It actually says "What you won't learn: Java."

In my defense, this is what shows up on my screen: What you will learn What you won't learn Java. Weird!

Your defense is that you badly misquoted what shows up on your screen?

That is weird...

Re: How to Design Classes (in Ruby, Python, Java or any OOP)

#17
post #10

Earlier quoted context omitted.

This book takes a theoretical approach to OOP. As the author said, this book is NOT about Java. Similarly, SICP is NOT about Scheme. Interestingly, It's the same author who teaches how to design programs with Racket, a lisp dialect. http://www.ccs.neu.edu/home/matthias/HtDP2e/index.html

> As the author said, this book is NOT about Java. That's what it says, but the concepts covered are so java-oriented it may as well be. It uses generic language to describe most of the concepts, but the underlying assumption seems to be that you need to understand these concepts because you need to program in Java, C#, C++, or some other closely-related language with no dynamic typing, no first-class functions, and…

I think this is where a lot of Rubyists/Pythonistas get lost. Just because the languages hide ideas like "interface" and "abstract base class" doesn't mean that those concepts aren't useful. Particularly in Ruby-land there's been a push to have common interfaces. They're only enforced by contract. And if you think about it, having "interface" explicitly in the language just means that the contract is enforced at compile time. Even so, you have to be careful. You could implement an interface and still just return null.

Re: How to Design Classes (in Ruby, Python, Java or any OOP)

#18
post #15

Earlier quoted context omitted.

In my defense, this is what shows up on my screen: What you will learn What you won't learn Java. Weird!

Your defense is that you badly misquoted what shows up on your screen? That is weird...

Honest question: Is that really what you thought? It seems obvious to me that I was implying a defense that the phrase I quoted also appears on the page, directly next to the phrase ekiru quoted, which makes the mixup a little more understandable, because it means I didn't see something that simply didn't exist. Did you get that and post your reply anyway, or did I just express myself poorly?

Re: How to Design Classes (in Ruby, Python, Java or any OOP)

#19
post #17
post #10

Earlier quoted context omitted.

> As the author said, this book is NOT about Java. That's what it says, but the concepts covered are so java-oriented it may as well be. It uses generic language to describe most of the concepts, but the underlying assumption seems to be that you need to understand these concepts because you need to program in Java, C#, C++, or some other closely-related language with no dynamic typing, no first-class functions, and…

I think this is where a lot of Rubyists/Pythonistas get lost. Just because the languages hide ideas like "interface" and "abstract base class" doesn't mean that those concepts aren't useful. Particularly in Ruby-land there's been a push to have common interfaces. They're only enforced by contract. And if you think about it, having "interface" explicitly in the language just means that the contract is enforced at comp…

> I think this is where a lot of Rubyists/Pythonistas get lost. Just because the languages hide ideas like "interface" and "abstract base class" doesn't mean that those concepts aren't useful.

I agree, somewhat. The problem is that HtDC seems to spends so much time on vocabulary and describing how to construct classes that very little is left over for discussion of actual design. Here's an excerpt:

This first section on classes suggests that the design of a class proceeds in three steps:

1. Read the problem statement. Look for statements that mention or list the attributes of the objects in your problem space. This tells you how many fields you need for the class definition and what information they represent.

That is probably quite reasonable from a java-perspective. But in Python the best answer might be to use the built-in data structures, define a bunch of functions to operate on that data, which are automatically encapsulated in a namespace based on the name of the file. But it might not, sometimes you would want to define a class with explicit fields.

The question is, how do you know which technique to use? This book doesn't seem to help with that. We've jumped from a data-driven approach using scheme to a java-style object-oriented approach for no apparent reason and very little explanation of the benefits of this approach.

Even if the part about interfaces might help a bit with designing a Python module, in order to get that out of this book you're going to have to wade through a lot of other stuff.

Re: How to Design Classes (in Ruby, Python, Java or any OOP)

#20
This book is too long for the subject it purports to impart.

Good coding is not a craft of many secrets; rather it is an art of a few core principles. Mastering them is a matter of direct experience. I believe a good book can point a programmer in the right general direction, but it is up to her to go the distance.

Post reply on HN