Live data from Hacker News

Coding Skill and the Decline of Stagnation

notch.tumblr.com

91–100 of 206 posts

Re: Coding Skill and the Decline of Stagnation

#91

Earlier quoted context omitted.

The way current C# does accessors / properties is just about perfect, I wish more languages would adopt it.

> The way current C# does accessors / properties is just about perfect As far as I'm concerned it's quite far from it, because C# still allows public fields, properties and fields are incompatible, properties and methods are separate and Microsoft specifies different naming conventions for fields on one hand and properties & methods on the other. Perfection is Smalltalk's way of doing it. And in a syntactic line clos…

What is wrong with different naming conventions for fields vs. properties, and methods? It makes it immediately obvious what is what at a glance.

*Honest question - I first learned programming with C#, and so those conventions seem 'correct' to me.

Re: Coding Skill and the Decline of Stagnation

#92
post #59

Earlier quoted context omitted.

"In Java, it's considered best to just go ahead and add the getters and setters first" I don't think this is true. I'll concede that it may be a requirement for certain things like an ORM API, but in the general case, it's bad practice. The mere act of adding a getter violates immutability.

> The mere act of adding a getter violates immutability. Uh what? No it does not. Writing stupid getters (or classes) might, but writing getters does not "violate immutability". Naturally, getters are not of much use if all your fields are final and hold immutable objects , but the latter can be tricky in many OO languages. Getters significantly improve the situation there, by providing a point at which you can clone…

Oops, meant to say "adding a setter violates immutability"

Re: Coding Skill and the Decline of Stagnation

#93
post #25
post #13

Earlier quoted context omitted.

Controversial might be too strong a word, but there is a counterargument to be made. Suppose you have a member named "x." Someday, you might want to stop storing x, and instead make it a calculated value. At which point you'll need a method. Or, when setting x, you may someday want to increment a counter, or transform the input data, or take some other action. Again, you'll need a method. Yes, it's very easy to add a…

No. C# and Objective-C (And I assume similar languages too) can have public accessors which are not used like function. No need to add ()'s everywhere.

I should have been more clear--I was referring to Java, which seems to be what the OP was talking about.

Re: Coding Skill and the Decline of Stagnation

#94
post #80
post #59

Earlier quoted context omitted.

"In Java, it's considered best to just go ahead and add the getters and setters first" I don't think this is true. I'll concede that it may be a requirement for certain things like an ORM API, but in the general case, it's bad practice. The mere act of adding a getter violates immutability.

All of your objects are immutable? Besides that's hardly an argument for having public members, being able to remove the setter or getter (or conditionally throw exceptions in them) is one of the exact reasons why you write them. The intent of the comment you are replying to "best practice is if you would add a public member, instead add a private member and a setter & getter" which is generally correct.

Yep, I think I misread his comment, which was probably a misread of my original post, which I'll admit wasn't stated very clearly.

Re: Coding Skill and the Decline of Stagnation

#95
post #88

I honestly don't see what about this post is Hacker News worthy. Is it just the fact that the post was written by the Minecraft developer? Or it it the (somewhat questionable) display of humility? It's sort of like posting a long list of your accomplishments and then saying "but I don't consider myself special, and I have much more to learn". If the sentiment was true, you probably wouldn't say it, and almost certain…

There is definitely a star power associated with someone like Notch which automatically gets more views. Same goes for a lot of the people you see get submitted here and voted up.

Is that the only reason? Probably not, but when someone famous says something it will get a lot more attention than if a nobody says it. Cet par.

Re: Coding Skill and the Decline of Stagnation

#96

Earlier quoted context omitted.

Eh, using protected/private members is one of those things that makes sense only insofar as you are paranoid that you can't just access internals directly. That said, consider the following. I've got a renderer that accepts a sprite to draw. Version 1: I pass the sprite object to the renderer, and the renderer gets the texture contained in the sprite and draws it, scaling it according to the sprite's size and positio…

Oh, and for good measure--everytime you force yourself to use an accessor, you are providing the opportunity for somebody down the line to add debug and validation code. Or to add locking and critical sections. Or replace a dumb get and recalculation with caching. Or replace caching with a dumb get. Or a database access. This flexibility is not something you might think you need. You might also never need to debug yo…

For that I prefer the ActionScript3.0 solution: methods that imitate attributes.

You replace

  public var myAttribute:int;
with

  public function get myAttribute():int;
The caller uses both with the same "object.myAttribute", so you can just replace one with the other when the need arrives, without changing any other code.

This allows you to use all sort of syntactic sugar ("object.myAttribute++", "+=" and other assignments), and for dynamic languages you can get and set values just from a reference to the object and the attribute's name. This last part is invaluable for animation engines.

Re: Coding Skill and the Decline of Stagnation

#97
post #57

Does anybody know if Notch is self taught? I thought he had a CS Degree from somewhere? I can fluctuate between thinking I am a fairly competent developer to thinking that I am possibly the worst programmer there is. I'm not sure which is a better attitude to have, hopefully I am somewhere in the middle. I think the issue with reading some of the discussion on HN is that you get people talking in detail about things…

Does anybody know if Notch is self taught? I thought he had a CS Degree from somewhere? I can't say with any degree of authority, but based on what I've read of his code, I'd guess he's self-taught. My bigoted preconception is that when it comes to abstraction in code, people with CS degrees err on the side of doing too much, creating extremely elaborate object frameworks that close down options as much as they help…

> Based on what I've read from decompiled Minecraft, I'd guess Notch is self-taught. The abstraction is just barely enough to get the job done

How can you tell from decompiled optimized code? Not saying you can't, just interested. Haven't read much decompiled.

Re: Coding Skill and the Decline of Stagnation

#98

Does anybody know if Notch is self taught? I thought he had a CS Degree from somewhere? I can fluctuate between thinking I am a fairly competent developer to thinking that I am possibly the worst programmer there is. I'm not sure which is a better attitude to have, hopefully I am somewhere in the middle. I think the issue with reading some of the discussion on HN is that you get people talking in detail about things…

> Does anybody know if Notch is self taught? I thought he had a CS Degree from somewhere?

I have a CS degree, and I'm 99% self-taught.

Re: Coding Skill and the Decline of Stagnation

#99
post #78

Earlier quoted context omitted.

C# allows it but but Java doesn't have this. Hence why it's standard operating procedure to just use setters from the beginning, because it might be nontrivial to update all references.

Play! framework allows you to use getters and setters with public members as you would in C#. Not sure how this is implemented.

Spring Roo does the same through the use of aspect programming (code generation, essentially - it generates the boilerplate behind the scenes).

Re: Coding Skill and the Decline of Stagnation

#100
post #64

Earlier quoted context omitted.

> I think that's because university teaches abstractions and pretty much nothing else. Maybe my CS degree was unique (I don't think it was), but at the 400 level we had specialization choices including security, graphics, web development, databases, operating systems, embedded, software engineering, etc. > A project that is done in the average CS class will be presented as a way to teach a design pattern rather than…

That's not quite what I meant, most CS classes cover many other things than design patterns. The problem is more that in an undergrad degree you are unlikely to need to do any large scale (by industry standards) project. So the way that they teach you good design is largely forced and the most academic way to do that is through a "design patterns" type class where the project that you are building is small enough not…

On the other hand someone who is more taught by experience will start by writing awful code like putting their whole program into 1 or 2 functions , they will then experience pain points because of this and realise certain re-occuring problems and either come up with their own solutions to them or read "gang of 4" , this will teach them design patterns the natural way.

This is exactly how I taught myself. The transition from unorganized to organized (patterns) happened for me pretty naturally. For me, it was learn how to organize, or quit. Now-a-days, patterns are everywhere (and probably have been, but I didn't get it until I got it :)

Post reply on HN