Live data from Hacker News

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

news.ycombinator.com

161–170 of 215 posts

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

#161

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.

Can anyone give a specific example of code they've worked with that was "too clever"? Based on my experience, if a coworker wanted to "avoid cleverness" I imagine we'd end up arguing over something like a for-loop versus a map, but such small code decision matter very very little in comparison to overall architecture, and where you place the "seams" in your system. So I ask, when you have felt that code is "too cleve…

I was working on a pipeline that took data in, did a bunch of work concurrently, then decorated the original data and shuttled it off elsewhere.

I spent a whole sprint building out "the RAD" - a rooted acyclic digraph - that ensured all sorts of correct behavior and powerful options for working with the graph. It felt awesome building what I thought was this super elegant thing that, to me, made total sense since I had been working with it for 3 weeks.

The other devs were confused by it and we're afraid to touch the code. I admitted failure and worked with them to rewrite it. It ended up being an adjacency list (i.e. a graph) with breadth-first traversal, but as long as I didn't call it that, they understood it and liked it.

And in hindsight, we didn't need all the guarantees that it provided, so they were right.

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

#162
Logger as an anonymous function.

I think literally every logger let's you log at a certain point as a single line that does not cover the context of the log.

  logger.info('Doing this and that',  function () {
    do_this()
    if(maybe) do_that()
  })
This way you know how much the log comment is supposed to cover as well as take a benchmark on the said context.

I can never think to just add a single line logger anymore.

This is much better than inserting comments in a code as comments can have no context except the line below.

You can add a function like,

logger.comment

and don't let it log anything to be comment syntax replacement.

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

#164

Logger as an anonymous function. I think literally every logger let's you log at a certain point as a single line that does not cover the context of the log. logger.info('Doing this and that', function () { do_this() if(maybe) do_that() }) This way you know how much the log comment is supposed to cover as well as take a benchmark on the said context. I can never think to just add a single line logger anymore. This is…

Not an active HN user. There doesn't seem to be a downvote function..

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

#165

Logger as an anonymous function. I think literally every logger let's you log at a certain point as a single line that does not cover the context of the log. logger.info('Doing this and that', function () { do_this() if(maybe) do_that() }) This way you know how much the log comment is supposed to cover as well as take a benchmark on the said context. I can never think to just add a single line logger anymore. This is…

Not an active HN user. There doesn't seem to be a downvote function..

I guess you can't downvote having below 500 points for yourself.

You can certainly add a comment on how you don't like it.

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

#166
post #90

Voraciously eliminating unnecessary whitespace, especially vertical whitespace, was a trick I learned early. Most monitors are wide, not tall. When you can see a whole function without scrolling it's much easier to understand. I'll collapse 'if' statements to a single line in most cases to make it readable left-right instead of up-down. 1TB bracketing is my default unless style guidelines prohibit it. End-of-line com…

I would no longer put much in a line, even if it meant using a single use variable.

Monitors may be wide but your eye sight will never change and moving your eye sight left and right, worse, moving your neck left and right is tiring and vertically is easier to follow as the code is the one that moves around instead of you.

Same as sibling comment but I keep my apps' window size at about 70% of the display's width starting near the mid to right end, so I don't have to look way to the left when pretty much everything is leaned on the left side. This brings most of the text, be it code or web page that you read close to mid, which is easier on your neck.

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

#167
post #123

Touch typing. There was a huge difference in speed between the my brain and my fingers. Once removed, it was much easier to make the code flow.

You realize you never need anything printed on the keyboard and that's what I use for 10 years now.

Good way to make non programmers laugh too.

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

#168
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…

If I don't commit often enough, then I would forget which part was stably written or not by seeing the lines changed in the editor when I come back to a certain part of the code.

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

#169

two things 1) leading commas in SQL 2) RAISE an EXCEPTION or RETURN --no more `else` statements in code SELECT this , that , something FROM table takes a while to get used to

What is the point of selecting specific columns unless some include large text or blob to consume unnecessary IO?

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

#170
post #149

Earlier quoted context omitted.

> in-app event sourcing What's the difference between in-app and not?

Event sourcing is already widely used as app to app communication. But few realize that it is plausible to take that paradigm and use it for module to module communication in-app. That line serves as reminder to utilize that, not to exclude non in-app event sourcing

I'd love to see a good example of in-app module-to-module event sourcing.

By module to module, do you mean between very loosely decoupled systems such as microservices, or closely associated things like queues and method calls in a single-process process?

Post reply on HN