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

Another 20 year veteran here. (though don't picture a greybeard, I started professionally at 15)

The big lesson for me over the last 5 years now that I also operate my code is design patterns. I think most Software people start with hating design patterns, then some fall in love with them, then eventually some of us fall out of love again.

The advice would be:

"Optimize code cleanliness and readability for reading at 2am in the middle of a production issue when you're trying to understand just exactly how the system got into that state that you didn't think was possible."

That means every jump to another class and every jump to an interface with multiple implementations is a distraction. You should still of course create modular separations for testability and clarity. But that line is way higher than the Uncle Bob "If a function is more than 4 lines long you should refactor it".

For complex mission critical pieces of logic, overindex on procedural execution, with paragraphs of comments explaining why each line is doing what it's doing.

Actually, another wisdom about comments:

I went from thinking "Comments are great!" to "Comments are terrible, and are liars, write self-documenting code" to "Comments are literally an opportunity for you to speak directly to the person coming after you, and explain in clear plain english WHY you made the choices you did, what tradeoffs you considered and dismissed, what compromises you made, and what external factors led to those decisions."

Comments don't need to be passive voice professional corporate speak. Nor do they need to make you sound smart or clever. Speak directly to your audience of future more junior engineers.

Exception messages too (sanitize all exceptions before they get to the customer, of course)



> I went from thinking "Comments are great!" to "Comments are terrible, and are liars, write self-documenting code" to "Comments are literally an opportunity for you to speak directly to the person coming after you, and explain in clear plain english WHY you made the choices you did, what tradeoffs you considered and dismissed, what compromises you made, and what external factors led to those decisions."

Wholeheartedly agree. Also, debugging logs for that same purpose can be great.

> Speak directly to your audience of future more junior engineers.

Often enough, that person might be yourself. I've been very grateful about my own comments in code areas that handled some obscure edge cases.

> That means every jump to another class and every jump to an interface with multiple implementations is a distraction.

Not to mention multiple layers of abstract base classes. I'd say „write your code such that you'll only ever need one IDE jump out of the current scope (and back in) to figure out what's going on“




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

Search: