Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What's wrong with this?


Over 150 lines of code in a simple method?

C-style declaration of all the variables in the beginning? (Yes, I know what Carmack said about how he written the project; this explains it, but doesn't make it good C++ code.)

Unclear flow with just one comment, which doesn't really explain anything?


Why do you say it's a simple method, if it is 150 lines long? Are some lines not necessary?

There is a logic to keeping logic together if it is isolated: http://number-none.com/blow/john_carmack_on_inlined_code.htm...

Context is important, to anyone developing D3 code, this code might be obvious and comments would be unnecessary. Considering 'geterdone' attitude of many game projects, with high levels hackery, this is very nice code.


Thanks for the link, it's a very fascinating read! By the way, I discussed this issue on Programmers stack exchange a while back, you might find this interesting: http://programmers.stackexchange.com/questions/277098/method...


It's a "simple method", but it's responsible for a bunch of initialization, so yeah, it's kind of expected to be long.

Notice, though, that each section is pretty straightforward in what it does...basically forEach's.

You could make the argument for greater polymorphism in types, or something like a visitor pattern over collections or something, but honestly this is readable and maintainable code.

More comments at the function declaration would've been nice, but the implementation is pretty straightforward.


You should try a Perl codebase. In just this one module I'm looking at, there's methods with 505, 880, and 995 lines.


A popular VoIP product has switch statements that are in the thousands.


Is it automatically generated?


No, hand written.


I found no difficulty understanding what it does. Perhaps you need to acquire greater proficiency at reading code.

Well, some familiarity with the game helps, too. This is the code that runs when a certain pick-up item's effect activates.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: