Live data from Hacker News

Write code like a human will maintain it

unstack.io

141–150 of 325 posts

Re: Write code like a human will maintain it

#141
post #88

Or we start writing code without LLMs.

Cat is out of the bag. Other than recreational programming I doubt many will write code without any form of LLM.

If everyone is using LLMs then nobody has advantage

In that case, humans with superior skills who can write code become the advantage.

That is important for companies that compete with each other.

Re: Write code like a human will maintain it

#142
post #133

Write yourself a /review command. That is an empty markdown file at `.claude/commands/review.md`. In it, put a checklist of things the agent should look for. When you’re ready to have your agent review the code, type `/review`. The checklist will be examined and it’ll plan out some findings to ask you if you want them fixed. Mine starts with “Enter plan mode. Examine the differences on this branch vs. main. Consider:…

Why wouldn't it already just do this though?

Unless prompted to do so, why would it? From the article: "Every shortcut you merge into your codebase is a signal about how things are done here."

Re: Write code like a human will maintain it

#143
post #125

## HARD RULE - design scope must always be maintained and no function should ever be longer than XXX lines and no class should have more than Y methods. Create new classes and subclasses and refactor until the criteria are met. You'd be surprised how readable this makes the code when XXX is about the size of your vertical screen and Y is relatively small.

but then you end up with a clusterfuck of classes?

Re: Write code like a human will maintain it

#145
post #88

Or we start writing code without LLMs.

Cat is out of the bag. Other than recreational programming I doubt many will write code without any form of LLM.

There are plenty of us. I have slowed down because I'm reviewing more PRs. That might sound like productivity but the LLM ones take more rounds of feedback.

Re: Write code like a human will maintain it

#146

In a similar vein, here's my favorite prompt: "Please review the tests you've written. Will the tests actually test what they're meant to? If the code breaks, will the test fail?" It's amazing how often LLMs will write tests that don't test anything.

I've seen a lot of human-written tests that wind up testing the testing framework and not the actual code.

Re: Write code like a human will maintain it

#147
post #139

Earlier quoted context omitted.

No one is stopping you. It's only if you want someone to pay you for hand writing code that you might feel a certain competitive pressure that makes it economically difficult, let's say.

One reason to write by hand is to have intellectual property, since it was ruled that AI generated code is in the public domain by default, so licensing is hard. Another thing is competitive edge, if you use claude and your competitors use claude then nothing really gives you an edge. AI is a commodity, not competitive edge. The competitive pressure should drive human work because it's unique.

The competitive edge lies with the higher attraction layer, not the nitty gritty implementation detail (any more). Is that still software programming? The human work lies in the what and why and in broad strokes how

Re: Write code like a human will maintain it

#148
> There's a much cleaner way to do this - a shared helper

disagree, then you end up with something this this

function checkAll(target, conditions) { return Object.entries(conditions).every(([path, expected]) => { const value = path.split('.').reduce((o, k) => o?.[k], target); return typeof expected === 'function' ? expected(value, target) : value === expected; }); }

and const ok = checkAll({ user, account }, { 'user.isActive': true, 'user.isSuspended': false, 'account.status': 'open', 'user': u => u.hasPermission('read'), // predicate for the trickier bit });

how is that better?

Re: Write code like a human will maintain it

#149
post #64

I have good results with this prompt after every larger change: Now do a final code check. Is everything tidy and do the components adhere to the principle of separations-of-concerns. Is everything in an understandable and maintainable state? Do we make any assumptions that may not be true anymore? Is any code left over from previous edits or experiments that does not belong into the codebase? Is the documentation st…

Just pull the slot machine lever

Yeah, I miss the days of having perfectly deterministic humans writing our code.
Post reply on HN