Live data from Hacker News

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

news.ycombinator.com

191–200 of 215 posts

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

#191

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…

One example would be anything called a "validation framework", hand rolled or as a library. They add so much complication for something easily handled by a validate function and a bunch of linear if statements in the "not clever" version.

One I deal with at work is someone trying to be "clever" and coming up with some annotation based tool to automatically serialize and deserialize objects to a third party system. It's got complex class heirarchies, interception points, etc and I regularly have to crawl through this code. The "not clever" way would be a function that translates the objects to the very simple csv format. In fact I've done that to test interacting with it and when the bash version is simpler to read than the c# version you know it's over complicated.

Another frequent one is "this code is repeated, better move it to a function", problem is you then need to make a change and you have to go through every code path to check it's relevency or add optional parameters, then next time it needs to change you have to check all code paths and inspect which ones are using which paramters. The "not clever" way is to leave the repetitive code, this can have it's own downsides like fixing one place and missing another, but those are much easier to deal with.

Basically use the least level of abstraction that can reasonably get the job done. Your php example probably could have used a little more abstraction like functions and structures but most "enterprisy" code I see could use a lot less.

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

#192
post #32

Functional Programming fundamentally changed the way that I solve problems. It also changed my expectations for how code should be designed. The concepts that influenced me the most were immutability and the power of mapping+filtering. Whenever I read a for/while loop now, I’ll attempt to convert it to the FP equivalent in my head so that I can understand it better.

I’d do the complete opposite. Instead of using mapping and filters I’d prefer for loops.

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

#193
post #173

Earlier quoted context omitted.

The point of "just writing enough to make the test pass" is to get you to the point where you have working software (proven by the test, even if the code is "bad") This is the _only_ point where you can safely refactor, if your tests are failing how do you know you haven't broken something? So long as you keep things "green" you know you're ok > The danger seems to be when you have to walk away from some code and you…

I need to get this book now too ;)

Well it's open source so just go take a look

https://github.com/quii/learn-go-with-tests

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

#195
post #149

Earlier quoted context omitted.

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?

Both in-process, inter-process, and inter-machine. The event sourcing technique really helps decouple components, reduce the need for higher order state.

I work with TypeScript on daily basis and I'm in the middle of building this library to help with event sourcing and other stuffs. https://github.com/Kelerchian/florcky

I'll be working with rust, C++, and C# in a few weeks due to professional demand and I might get somewhere with event-sourcing using those language.

In the long run we might be utilizing wasm and ffi to introduce universal protocol for event sourcing.

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

#196
post #191

Earlier quoted context omitted.

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…

One example would be anything called a "validation framework", hand rolled or as a library. They add so much complication for something easily handled by a validate function and a bunch of linear if statements in the "not clever" version. One I deal with at work is someone trying to be "clever" and coming up with some annotation based tool to automatically serialize and deserialize objects to a third party system. It…

>Basically use the least level of abstraction that can reasonably get the job done.

There is a great section of John Ousterhout's "A Philosophy of Software Design" that goes into this. He mentions that moving code to functions / methods doesn't eliminate complexity, it nuat kind of shifts it: it adds complexity to the "interface" of the module.

Sometimes leaving code inline with its original context is better.

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

#197
post #116
post #82

It's okay to be messy. Treat code mess with the same techniques you would treat RL mess. Sometimes you sweep it under the rug. You can toss it in a closet or attic. You can buy a shelf or box and toss everything in there. You can clean it up seasonally, like set aside a sprint for it. Some kinds of messes are hazardous and absolutely should not be tolerated - this is similar to leaving milk out or trash piling. Many…

Wrong. Absolutely wrong analogy. You can't discount people who keep code clean, modular and simple. It's not an easy thing to do unlike cleaning your house. It just takes one's will to clean the house but when it comes to keeping your codebase clean, it's much more than just will. Sound knowledge of software architecture and design principles is required to write and keep your code clean and unfortunately, the number…

> the number of people with this knowledge is very small in most teams and sometimes there's none.

This is just it. It's expensive to organize things.

Bad architecture is worse than no architecture. It take time to build, then more time to tear down.

How do you organize with no experience? A mess already holds a structure. It can be evolved into the right structure. But if you adopt the wrong structure too early, you're stuck with a bad system that has to be destroyed and rebuilt.

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

#198

Earlier quoted context omitted.

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

Here's a few reasons why when you finalize a query, you select only the necessary columns (non-exhaustive list): - Reduce uneccessary IO / resource strain, as you said - Predictability; consuming program receives data in the same order, every time - If the DBA adds additional columns to the table, it doesn't hose downstream consumer processes - Easier to debug if some problem does arise. - Clarity, if you are only us…

I understand how clarity may provide the programmer's intention of the query but I'd rather just pick all, so that change in code below doesn't suddenly break because you didn't sync the columns to be fetched.

> - Predictability; consuming program receives data in the same order, every time

For any joined table, you can specify table name for each '*' or add an alias last to keep the column you need instead of writing it all.

Seems specifying each column name isn't in any way crtitically bad when you can't select all but a column in SQL, which is a deficiency in the language.

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

#199
To begin with, If you’re trying to find where to shop for Hydrocodone Online, Then I assume you’ve got a few questions like the best place to shop for hydrocodone online, where to shop for Hydrocodone. Also, buy hydrocodone, hydrocodone purchasable. Our shop will proceed with your details on the way to Buy Hydrocodone Online. From 24hrsonlinestore https://24hrsonlinestore.com/product-category/buy-hydrocodon...

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

#200
Buy oxycodone online, Oxy, sold under name OxyContin among others, is an opioid medication used for the treatment of moderate to severe pain. it’s usually taken orally, and is out there in immediate release and controlled release formulations From 24hrsonlinestore https://24hrsonlinestore.com/product-category/buy-oxycodone-...
Post reply on HN