Live data from Hacker News

Classes vs. Data Structures

blog.cleancoder.com

91–100 of 184 posts

Re: Classes vs. Data Structures

#91
post #52

Whenever I hear "Socratic dialog", I reach for my revolver. Is there any other form of teaching so irritating and patronising? You might have a brilliant store of insight to impart, but if you insist on trying to do so via a twee, affected and unbelievable conversation with a Mary Sue wise professor, I'm going to write you off as insufferable before the fawning moron you have as proxy for your audience utters their f…

Could it really be that bad? I followed the link, it's so much worse. Worse? Yes. How much worse? So much.

[deleted]

Re: Classes vs. Data Structures

#92
post #67
post #62

Earlier quoted context omitted.

I don't think I understand pointers. Maybe we can help each other. My mental model of pointers is a map: lat/long identify the object of interest (the local coffee shop), but not what is interesting about it (their menu and hours).

Hmmm. Interesting. I'm going to have to roll that around in my brain for a day-or-so to see if I can make that compute for me. (Which means I may be back here in a day to check back in!) Maybe it's because I started in assembly language, but to me, data exists at an address in memory. Or starting at an address in memory. That data might be on integer, a float, a character, the beginning of a string, the head of an ob…

So, I'd like to point out that some of your assumptions about performance may no longer be true. Optimizing compilers are REALLY good now-a-days, but one thing you can do to really trip them up is introduce a bunch of pointers.

It takes very little time to allocate space on the stack and not too much time to copy data from one register to the stack or another register. Very often, if you don't use pointers, the compiler will take your data and throw it into a register and reference that register directly in the method you just called (free).

Now, if you are going to allocate on the heap anyways, then sure, it makes sense to start looking into things like object pools. But that wouldn't be a baseline I'd start with.

Objects with a few ints or longs in them can be passed around free or nearly free with modern compilers.

Here is an example of that concept in action

https://godbolt.org/z/G6r0X6

You really don't get much faster than that.

Re: Classes vs. Data Structures

#93
post #57
post #49

Earlier quoted context omitted.

Is there any other form of teaching so irritating and patronising? It's only patronizing to people who are motivated self-learners, such as you. To people who are unmotivated and/or struggling with the concepts (such as high school students), it works better than most other styles I've tried. I've spent a lot of time tutoring high school and elementary school students. Many of them are so frustrated that they just wa…

The problem here is that this is a piece of opinion, presented as a lesson, implying that the author is the master and the readers the apprentices.

Can author imply anything else? If reader knows better, why reader reads at all? Actually, before reading nobody can know what's in the writing, so author is naturally more knowledgeable.

Lesson is just a transfer of knowledge - which may turn out to be useless, but only after the fact.

Re: Classes vs. Data Structures

#95
post #46

Earlier quoted context omitted.

I completely understand and almost always share your reaction. Socratic CAN be done well - The novel Starship Troopers is actually like that...the arguments may not be your first pick, but you consider them all reasonable, and then you discover you're supporting fascism! It requires you to back up and find where you made a false connection. Unfortunately, the most common usage is at best ineffective, for as you say,…

Socratic method is supposed to be done in person, between professor and students, with professor choosing next question based on student's answers that typically reveal gaps in their knowledge. Doing it in form of made-up conversation in a book is a travesty.

Have you read Starship Troopers? It's one of Heinlein's finest novels.

Re: Classes vs. Data Structures

#96
post #84

Earlier quoted context omitted.

Honestly, I think the answer to "Pointers, WTF?" is simply describing how data is stored in memory. This concept is important not only for how pointers work but even how data is stored on a hard drive. You don't have to go into great detail. All you need to do is say this is a number, it takes n number of bytes to store (Most people who haven't been living under a rock have a knowledge of bytes, just explain it to th…

Honestly, I think the answer to "Pointers, WTF?" is simply describing how data is stored in memory. So is this not how it's explained nowadays? No wonder there's people that doesn't get it. So many concepts, not only about programming, I have learnt in my life first with "this is what happens", then with the precise definition...

At least in my college days, it didn't seem like it. It felt like a lot of professors jumped straight to the analogies rather than taking a second to just draw things out.

edit that being said, after your comment I went out and looked up "What's a pointer" to see how it is taught. Pretty much every web page I hit does exactly what I described, so, awesome :).

Re: Classes vs. Data Structures

#97

Whenever I hear "Socratic dialog", I reach for my revolver. Is there any other form of teaching so irritating and patronising? You might have a brilliant store of insight to impart, but if you insist on trying to do so via a twee, affected and unbelievable conversation with a Mary Sue wise professor, I'm going to write you off as insufferable before the fawning moron you have as proxy for your audience utters their f…

To be fair, actual Socratic dialogue can be very effective and rewarding, without being patronizing. What you're describing there -- what the blog post is like -- that's just as awful as you said, or worse. I couldn't get much further past this: What is an object? An object is a set of functions that operate upon encapsulated data elements. ...what?

Maybe we should try to be patient here and assume some valid point of view - even if possibly unusual for a personal experience. That is, can we try to justify this approach?

It's like HN guidelines - "assume good intent".

Re: Classes vs. Data Structures

#98
post #93
post #57

Earlier quoted context omitted.

The problem here is that this is a piece of opinion, presented as a lesson, implying that the author is the master and the readers the apprentices.

Can author imply anything else? If reader knows better, why reader reads at all? Actually, before reading nobody can know what's in the writing, so author is naturally more knowledgeable. Lesson is just a transfer of knowledge - which may turn out to be useless, but only after the fact.

The author could acknowledge the trade-offs between their preference and anothers.

Re: Classes vs. Data Structures

#99

Whenever I hear "Socratic dialog", I reach for my revolver. Is there any other form of teaching so irritating and patronising? You might have a brilliant store of insight to impart, but if you insist on trying to do so via a twee, affected and unbelievable conversation with a Mary Sue wise professor, I'm going to write you off as insufferable before the fawning moron you have as proxy for your audience utters their f…

I got a few lines down and couldn't keep going. It's such an irritating way of making an argument.

I've read all, and got both interesting points - useful to me angles of view - and certain statements and conclusions from then which I don't agree with.

1) Author says object and data structure are different things basing on stated difference, but doesn't explain why this couldn't be a different point of view on the same thing.

2) When author says "adding a class is easy when you need a new entity, while adding a function is easy when you deal with data structures" he doesn't mention that only "packaging" of code - into switch cases or separate methods - is different. To add Triangle, one still has to add both fields which contain Triangle data and all the methods which work with that data - area, perimeter, center. Similarly, adding data structure "Triangle" also needs all those additions - and only them - but in a different form.

And many derivations from this perceived difference are, um, questionable.

Yet I like author's explanation of impedance mismatch. True, data storage has to satisfy many needs (roughly, we don't want to copy data - normalization), while logic may focus on specific goal at hand.

Post reply on HN