How to Write Less Code and Build Better Apps
How to Write Less Code and Build Better Apps - Photo by Safar Safarov on Unsplash
Something I wanted to share is that it’s not because it’s longer. It’s not because you write a huge report. It’s not because you code this 1,000 plus lines of code in each file and the function looks giant. That is better. Of course not. And usually the simpler solution is the ideal one. The ideal one and it’s the same for UX. It’s the same for an app. It’s the same in our day-to-day life. The simpler, the less, it’s more.
So when you need to write a report, when you need to write something even for your performance review, what you have done, it’s good to summarize. Writing too much, your manager will not read everything, but you have to mention everything you have done. You don’t have to end up with 10 or 20 pages because then it will not be great.
And when we have to write code, an application, a program to solve a problem, it’s not because it’s more complex. It’s not because it does so many, it handles so many cases, edge cases that will usually never happen, that it is better. No, the simpler solution is easier to maintain. It’s easier to read. It’s easier in the longer term. So yes, less is always more.
When we know, finally, that at school we were taught that a longer essay, something longer, when I need to write a capstone, when I need to write a paper, it has to be at least 2,000 words. But in our life as an adult and when we work, we finally realize that the less stories, the better, because people don’t have the time to read everything. And complexity, it’s very hard to maintain. Complexity will not end up well.
So when you end up with something super simple, very easy to maintain, it’s also scalable. So less is always more. Learning how to decrease the complexity, learning how to make it smaller, it’s actually something very important. The same when we refactor codebase, not having more code to handle more things. Of course, we do have to handle the things that happen quite often.
Practical Example: Refactoring for Simplicity
How to Write Less Code and Build Better Apps - Photo by Ferenc Almasi on Unsplash
Let me give you a quick code example. Imagine you have a function that checks if a user is allowed to access a resource. The “complex” way might look like this:
1function canAccess(user, resource) {
2 if (user && user.role) {
3 if (user.role === 'admin') {
4 return true;
5 } else if (user.role === 'editor' && resource.type !== 'restricted') {
6 return true;
7 } else if (user.role === 'viewer' && resource.type === 'public') {
8 return true;
9 } else {
10 return false;
11 }
12 } else {
13 return false;
14 }
15}
But you can make it much simpler and easier to maintain:
1function canAccess(user, resource) {
2 if (!user || !user.role) return false;
3 if (user.role === 'admin') return true;
4 if (user.role === 'editor') return resource.type !== 'restricted';
5 if (user.role === 'viewer') return resource.type === 'public';
6 return false;
7}
See? Same logic, but way easier to read and update later. That’s what I mean by “simpler always win.”
Why Simplicity Matters
When you keep things simple, you make your life easier. You make your teammates’ lives easier. You make your future self’s life easier. And honestly, you make your users happier, too. Whether it’s code, documentation, or just explaining what you did in a project, less is more.
“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.”
— Antoine de Saint-Exupéry
How to Write Less Code and Build Better Apps - Photo by Bernd 📷 Dittrich on Unsplash
So next time you’re tempted to add more, write more, or make something more complicated, ask yourself: can I make this simpler? Can I cut out the noise and just deliver what matters?
Key Takeaways
- Simpler solutions are easier to maintain, read, and scale.
- Writing more code or longer reports doesn’t make your work better.
- Focus on what matters and cut out unnecessary complexity.
- Refactoring is about reducing, not increasing, code.
- “Less is more” applies to code, UX, documentation, and communication.
Pierre-Henry Soria
#Code Efficiency #Occams Razor #Problem Solving #Productivity #Simplicity #Software Development #Tech