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

Interesting how my experience has led me in a different direction:

https://dlang.org/blog/2023/10/02/crafting-self-evident-code...

(The article is crafted around D, but the principles apply to C as well.)



Fun read.

    What happened to the conditional expressions? Move them to the interiors of doX() and doZ().
That was an interesting point. Not sure that it's always valid but I guess it depends where you want the abstraction to lay, and how it affects the mental construct around the code.

e.g.

    deleteRecords();
is not better than

    if let x = deadRecords()
       deleteRecords(x);
Sure, it looks messier but there is value is showing upfront that you're pruning and not wiping.

If the author wisely renames his function e.g. pruneDeadProjects(), yes. But merely moving the the condition within the function can be dangerous for context and be a leaky abstraction.


Finding the right abstraction isn't always easy. Sometimes if I just put it down and let it slosh around in my brain for a few days, it comes to me.

Like your idea of pruneDeadProjects()!


The programming strategy of "less typing, more thinking", it's a good one for avoiding RSI.




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

Search: