Live data from Hacker News

Ask HN: What change in your programming technique has been most transformative?

news.ycombinator.com

51–60 of 215 posts

Re: Ask HN: What change in your programming technique has been most transformative?

#51
post #38

Writing simple functions which take an A and return B in any context. Then, composing those simple functions together to build up more complex functionality.

I would mention generics also. It has forced me to a clean architecture from the start without throwing away code.

Although sometimes the domain is not clear enough before you start, that's shitty.

Re: Ask HN: What change in your programming technique has been most transformative?

#52
Something not mentioned yet. I find programming is the task of last resort and I spend a good deal of my time talking with the product person to help them refine their product idea into something that is mechanically sympathetic with how computers work and the general problem domain. It often adds 10% time for the initial work and -90% of the time for iterations.

For example once we had a project that wanted to add Role Based Access Control and some juniorish engnineer suggested adding boolean columns to the table for each of the user's roles.. Nope. Instead we created a document store w/ roles and defining new roles was as simple as adding a const to a set in the service's code. Good thing too because the number of roles grew from the initially requested ~3 to almost 100. That would have been too wide of a table.

Re: Ask HN: What change in your programming technique has been most transformative?

#54

Something not mentioned yet. I find programming is the task of last resort and I spend a good deal of my time talking with the product person to help them refine their product idea into something that is mechanically sympathetic with how computers work and the general problem domain. It often adds 10% time for the initial work and -90% of the time for iterations. For example once we had a project that wanted to add R…

I would have used flags if roles aren't dynamic

Re: Ask HN: What change in your programming technique has been most transformative?

#55

Avoiding cleverness at all costs. Simple code that is easy to both read and write without strong efforts to follow senseless DYI or take on abstraction for the sake of abstraction.

Amen! Developers spend their first decade learning how to write complex code, and be clever, and compress everything into the fewest and hardest-to-read smallest amount of code possible.

Their second decade they learn that simplicity and readability is always better, even if it does require more code.

It's better to have 300 lines of simple, straight-forward, easy-to-read code than to have a 30 line version of the same code that's difficult to understand, and difficult to debug.

Always code for your future-self and future-others who really don't want to spend an hour figuring out what the hell you did in that awesome looking 30 lines of entropy.

Re: Ask HN: What change in your programming technique has been most transformative?

#56

If you have to run your code to understand it. Try again.

This is so true for beginning developers. They tend to have a mindset that once they run something and it appears to work, then that means they likely got it right.

In reality the code might be right for 90% of use cases, but once you multiply this over a whole project, you end up with total dogsh*t, and mainly because of laziness too. This is the biggest reason the inexperienced developers create such horrendously buggy code.

Re: Ask HN: What change in your programming technique has been most transformative?

#58
"Premature optimization" was happening a lot more in my head than on the screen. By that I mean I would waste time struggling to succinctly generalize a function instead of making something work the easy and ugly way FIRST. It is far easier to copy paste working code in 4 places and leave a nice comment on each about what could be probably consolidated... without actually doing the work at least until you come back to the code to make a minor change in those 4 places. Half the time you never come back, most other times you end up merging them within a week. And for outliers... good commenting saves the day.
Post reply on HN