Live data from Hacker News

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

news.ycombinator.com

41–50 of 215 posts

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

#41
post #21

I stopped doing small commits. In the past as soon as I was "done" with something I would commit, even if one line. What would end up happening sometimes later in the day I would decide revert or modify the change, so my commit history ends up flooded with bunch of small commits. I ended up writing a script that checks my current work, and if enough changes or time has past, then a commit is recommended: https://gith…

You can have your cake and eat it too by initially generating a series of small commits and then going back later to reorder them and squash them into a much shorter series of logically coherent commits. This makes it way easier for someone (possibly you) looking later to understand what was done and why. (I once almost took a job where the repo was just a series of huge commits taken at more or less regular interval…

[deleted]

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

#42

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.

"Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?"

http://www.linusakesson.net/programming/kernighans-lever/

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

#43
When working on most things, I ask two basic questions: how does it fail? how does it scale? I picked that up years and years ago.

Any line, function, workflow, etc can fail. You need to have worked through all the failure cases and know how you are going to handle them.

Somethings don't need to scale, ever. But most things I work on do. If I don't know the story on how I can ramp up an implementation a few orders of magnitude, then I can't say I've designed it well.

Aside from that, measure everything. Metrics, telemetry, structured logging. Design for failure and design for understanding what happened to cause the failure. Data will tell you what you are doing, not what you think you are doing.

There was a post here yesterday about a neat map thing. I hit a bug and the author could only rely on their experience with it being potentially slow at times but saying it should work. If there were proper metrics in place, they would know that N% of calls exceed M seconds and cause a timeout. He could then relate this to the underlying API and its performance as the service experiences it. With proper logging, they see what the cache hit ratio is and determine if new cache entries should be added.

Build, measure, learn.

Oh, and automated tests. So much to be written on that.

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

#44
Realizing that I can roll my own framework.

Why? Because I’ve tried to actually think about my underlying data structure instead of defaulting to convention but reflex.

The best example? Marcel Weiher Ch 13 in “iOS and MacOS Performance Tuning” explains how to improve lookups in a public transport app by 1000x.

What more? The description of the the data (the code) and the the application (the intended use) are probably way better because thinking about performance is similar to thinking about your data. You want answers fast. Fast answers, fast code.

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

#45
Many developers think of themselves as abstraction masters. "Moar abstraction is moar better!" Abstractions have a cost in readability and maintainability. It is very hard to make the abstraction that improves both. I'm tempted to say that pre-abstraction is a larger problem than pre-optimization.

Make your code easy to read at the expense of easy to write. Don't abstract unless you know exactly the use case. If the use case is not immediately forthcoming, YAGNI (you aint gonna need it). Related, don't be clever. Clever is cute and all. It does not belong in production code.

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

#47

I can think of 4 things: 1. Not being afraid to look at the code of the libraries that my main project depends on. It's a slow, deliberate process to develop this habit and skill. But more importantly, as you keep doing this, you will develop your own tactics of understanding a library's code and design, in a short amount of time. 2. Not worrying about deadlines all the time. Not a programming technique as such, but…

What would be some fundamentals to practice for a software developer?

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

#48
I've been doing a lot of Python lately and using type annotations strictly and a decent IDE like VS Code or PyCharm. If you screw up, passing a foo instead of a bar, both almost immediately highlight the error. Don't even have to run the script to see it blow up. Huge time saver.

Also doesn't hurt that it improves Intellisense/Autocomplete, gives better hints/help as you're calling a method, and improves on "self documenting" code.

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

#49
Using static typing to make changes slightly bigger than intended.

But with a better architecture and nearly zero mistakes. Through using OO correctly ( please read the word correctly)

One step at a time.

Ps. This is mostly when a code-base is detected where a part of the code is sensitive for bugs. Eg. From today: handling better payment providers and payments.

I thought it was important enough to make the change bigger, but with the intention of removing recurring/similar errors in someone else his code-base.

Afterwards, go to him and explain why. Developers can be proud of their code, although it's just shitty code ( eg. Long functions, loops, if else, switch, by reference, ... Is mostly an example of bad code) and never say it's shitty..

Post reply on HN