News for hackers. Stuff that matters.
Re:Ask HN: What change in your programming technique has bee... by muzani on Friday January 24, 2020 @01:46AM (#22135935)
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 people make this mistake of assuming that because some messes are very dangerous, all of it is too.

Most messes will slow you down, but cost more to clean up. Overall, I've seen documentation do more harm than help - it's often faster to interrupt a colleague doing something than for that colleague to spend weeks documenting and updating documentation on something that gets thrown away.

Some will take more time to fix later than now - this is what people mean by tech debt. But it's less common than it seems.

With a lot of mess piles, the important parts float to the top and the less important ones sink at the bottom. God classes are mess piles.

Once the mess becomes a burden, it's a good time to clean up.

You may need a few janitors and landscapers, especially for a large code base.

Some people place much higher priority on cleanliness than others. Be respectful of them but you don't have to be like them.

Re:Ask HN: What change in your programming technique has bee... by femto113 on Friday January 24, 2020 @03:29AM (#22136400)
I've got a slightly different take on messes, and using another RL analogy I call it "don't put your dirty dishes in the sink." If you have a couple dishes you can't wash right away it is tempting to put them in the sink instead of on the counter: from a distance it looks neater, any spills are contained, etc. Where this falls apart is if you add a few more dishes, and then more, and now your sink can't serve its main function because it's full of dishes, and some of them are full of dirty water so you can't just move them back to the counter, so washing just the one dish you need requires you to either undertaking cleaning the whole sink or delicately juggling the thing under the faucet while water sprays everywhere, and washing all the dishes now requires a mop.

Code messes are similar. Sweep them under a rug or toss them in a closet and your code will look clean, just like your counter looked clean while those two dishes were in the sink. And like the sink you can quickly get to the point where those closets are scary to open and no one wants to walk on that rug because it makes weird crunchy noises.

So how does one leave ones messy code "on the counter"? Well in my "writing C with vi" days I actually outdented any code that I didn't consider clean/good/permanent. Like all the way to the left, regardless of where it would naturally be indented at. It stuck out like a dirty mug on clean granite, and no one (importantly including me) failed to notice it.

With modern IDEs and auto-formatting and the somehow unavoidable use of Python I no longer use that technique, but I will comment any such code liberally with #HACK or #TODO or similar

Re:Ask HN: What change in your programming technique has bee... by nouveaux on Friday January 24, 2020 @01:17PM (#22140948)
I think this is a great analogy because both code and cleanliness carry similar social consequences.

If you live by yourself, you can be as messy as you want. It's only a problem if your mess becomes a biohazard for your neighbors that you have to take care of it. Otherwise, if you're happy with your mess, that's fine.

If you live with other people, your mess in the common area becomes their mess. That's a problem if other people do not like your mess. There needs to be agreed upon standard by those living together.

Eventually, the mess will inhibit your ability to work productively regardless of the situation. I guess you can always throw out dirty dishes and buy new ones, but there is a cost to bear.

Re:Ask HN: What change in your programming technique has bee... by wewake on Friday January 24, 2020 @03:36AM (#22136444)
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 of people with this knowledge is very small in most teams and sometimes there's none.

Also, it's not okay to be messy unless you are working on a school/university project.

Re:Ask HN: What change in your programming technique has bee... by dynamite-ready on Friday January 24, 2020 @03:45AM (#22136493)
You're not quite disagreeing with the analogy, you're actually re-enforcing it. What you've really taken exception to, is the OP's perceived standards of 'hygiene'.

And between say 'medicine' and 'refuse collection', standards of hygiene and priorities can and will be wildly different.

Re:Ask HN: What change in your programming technique has bee... by easytiger on Friday January 24, 2020 @02:54PM (#22141836)
> 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.

Let me put it this way. I've seen no relationship with code purity and a happy client

Re:Ask HN: What change in your programming technique has bee... by afarrell on Sunday January 26, 2020 @01:47PM (#22153840)
Have you ever walked into a restaurant and asked to see how they refrigerate or organize their ingredients?

No? Would you say then that you don't care if your food comes out slowly or gives you food poisoning?

You care about the result, but you trust it to someone else.

It is a Chef's responsibility to maintain the mise-en-place and food safety to a degree which enables him or her to keep delivering meals quickly and without salmonella.

It is an Engineers's responsibility to maintain the code clarity and tests to a degree which enables him or her to keep delivering improvements on business needs quickly and securely.

Re:Ask HN: What change in your programming technique has bee... by easytiger on Sunday January 26, 2020 @02:04PM (#22153960)
That analogy would work if I hadn't worked for companies who made $400m+ with code and processes that would be at home in a 14 year olds hobby project. Oh and 0 tests.

I find a lot of a certain kind of sw person who need analogies to make their mental model work. It never did for me

Re:Ask HN: What change in your programming technique has bee... by muzani on Saturday January 25, 2020 @12:01AM (#22144811)
> 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 bee... by thu2111 on Friday January 24, 2020 @05:11AM (#22136834)
That's true in a way but with the huge caveat that cleanliness of a home is very objective. Everyone recognises and agrees when a home is very clean or very dirty.

Software architecture isn't like that at all. Developers routinely have massive fights and disagreements over whether something is clean or not. One person's clean is another person's over-engineered monstrosity.

This changes the equation quite a bit. In any sufficiently big team either one person has to be top dog and enforce their personal perception of clean on a perhaps unwilling team. Or you have to flex and tolerate multiple competing definitions in a codebase, which if you have "clean freaks" in the team can lead to constant pointless refactoring and rewriting.

Re:Ask HN: What change in your programming technique has bee... by speedplane on Friday January 24, 2020 @02:05AM (#22136020)
> Once the mess becomes a burden, it's a good time to clean up.

Definitely the way to go. It's not a problem until it's a problem.

Re:Ask HN: What change in your programming technique has bee... by akavel on Friday January 24, 2020 @03:34AM (#22136434)
Still, you may want to be careful with this attitude, as some people have... let's call it, high tolerance to mess. When you stumble over something every time you enter your room, but proudly proclaim "not a burden, works for me, all under control!", then you "suddenly" need to add a huge feature quickly, having a clean room can help to do it in shorter timeframe.
Re:Ask HN: What change in your programming technique has bee... by phonebucket on Friday January 24, 2020 @05:49AM (#22137005)
> It's not a problem until it's a problem.

I see it as a problem waiting to happen until it happens.

Re:Ask HN: What change in your programming technique has bee... by muzani on Friday January 24, 2020 @11:46AM (#22139904)
A part of engineering is evaluating the damage of the problem happening vs risk vs cost of preventing the problem.
Re:Ask HN: What change in your programming technique has bee... by tadhgds on Friday January 24, 2020 @06:21AM (#22137165)
Can you elaborate on why this was transformative?

The dropping of standards is always going to make things a bit easier on yourself but if there isn't really much more to it than that, is proclaiming "It's okay to be messy" really a good thing?

I don't think(I might be wrong) other engineering fields can get away so lightly with such attitudes, why do you think we can? Particularly in light of so many security disasters unfolding around us. How can you justify an attitude that seems to move in the opposite direction of where many believe we should be heading, i.e. tighter control, more strongly enforced standards and a distancing from the 'move fast, break stuff' ethos

Re:Ask HN: What change in your programming technique has bee... by muzani on Friday January 24, 2020 @09:46AM (#22138699)
Order has as many flaws as disorder. There's a balance in between.

Many of us are familiar with that balance in our daily lives; e.g. we don't mop the floor so clean we can eat off it. But code is often continually polished, refactored, documented as soon as there is the slightest smell.

We do keep tidy enough. The standards for office cleanliness never qualifies to surgery standards, and yet a lot of people like to compare their code to medical device safety levels.

Besides that, there is a clear structure to mess. Too much or too little order and you lose control. The right amount will give you the correct structure.

Re:Ask HN: What change in your programming technique has bee... by forgotmypw on Friday January 24, 2020 @04:49AM (#22136754)
This. Do it the stupid way first, I've heard it said.
Re:Ask HN: What change in your programming technique has bee... by dynamite-ready on Friday January 24, 2020 @02:04AM (#22136017)
That's an excellent analogy.