Clean code is important, clean code helps others understand your code, but clean code is also pretty subjective!

I want to give you my perspective on it, drawing from years of experience leading teams of developers as a tech lead and working in teams.

🧵
1️⃣ Clean code is important

Clean code helps people understand code.

The more your code is structured according to the opinion of the majority of developers, the more likely it is that other developers will understand your code!
A few principles of clean code are:

- Use meaningful and understandable identifiers
- Use functions and keep them as short as possible
- You don’t need comments most of the time when your code is human readable
- Don’t repeat yourself (DRY)
- Keep it Simple, Stupid! (KISS)
- Premature optimization is the root of all evil
- Tell, dont ask (TDA)
- Law of Demeter
- Separation of concerns
- Single responsibility Principle (SRP)
- Open Closed Principle (OCP)
- Liskov Substitution Principle (LSP)
- Interface Segregation Principle (ISP)
- Dependency Inversion Principle (DIP)

👇🏼
2️⃣ Clean code helps others understand your code

Each developer has their own style of coding.

There are things they like, and things they don’t.

They prefer doing things in a certain way, because it works best for them.
By leveraging well-known principles and integrating them into our own work, we open up the possibility to others, who are themselves aware of those principles, to find their way into our code base easier.
It’s like using standardized technology!

Take a Dockerfile for example. The syntax is mostly standardized nowadays. If you can write a Dockerfile to use with Docker, you could also create a container with podman because even most commands are standardized and the same!
Now transfer this over to how we write code.

You can surely imagine that understanding becomes easier when many developers leverage the same principles to write and structure their code!

👇🏼
3️⃣ Clean code is subjective

As you’ve seen above, clean code leverages a lot of principles. But principles are what their name states.

It’s almost impossible to give everyone a strict way to do things in certain situations.

This leads to a lot of interpretations of clean code.
Take a readable identifier for example.

function getDogs(ctx) {
[...]
}

vs.

function getDogs(context) {
[...]
}

Could you tell which one is more readable?

If you ask 5 developers you’d receive 10 different answers.

This is one example of the subjective part.
For some developers, the abbreviation ctx is well-known, for others it’s simply not, and they’d prefer the identifier context.

The same goes for the length of methods, or how much interface is too much, or not enough.

👇🏼
4️⃣ Dealing with it

Discuss clean code with your peers and translate every principle into a certain ruleset for your team.

Decide, together as a team, how you want your code to look.
Discuss again if someone changes their mind.
Build yourself a set of rules and best-practices which all team members can agree on.

This way acceptance rises significantly and people will be more willing to follow the given rules.

Whenever possible, leverage automation, like linters and such!
As long as tools are configured according to what your team decided upon, there is no need for manual work or lengthy discussions in reviews.

If the tool says you’re doing it wrong, you have to adjust.

If you think the rule sucks, discuss it as a team!

👇🏼
4️⃣ Clean code as a beginner

Many beginners and/or newbie programmers tend to get overwhelmed, which is pretty understandable.

Not only do they have to learn to write code, everyone also tells them to do so properly.

Want to read my opinion on this?
Concentrate on learning how to properly make software work first.

You can still learn how to properly structure your code when you’ve taken the most difficult obstacles.

Learning what variables are, how loops work, what the DOM is, how a network works, and what TCP does is...
...already a lot to grasp in the beginning.

If you also add cleans code principles on top of it, I could understand if many people would simply get overwhelmed.

Better concentrate on the basics first, then try to get into clean code when your foundation is solid. 🙏🏼

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Oliver Jumpertz

Oliver Jumpertz Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @oliverjumpertz

27 Oct
Have you ever had to process events?

If you have, have you ever thought about if the order of events really matters?

There is a huge difference in complexity whether the order of events processed matters or not.
Imagine the following task/problem:

You want to analyze application logs, because you're curious how an API that starts a long running background process behaves performance-wise.

One log message signals the start, a few intermediate ones, and one message that signals the end.
1⃣
If you can somehow ensure that every log message you process comes in order, the problem is manageable.

When you get your end message, you know that you already processed the start message.

You could now, for example, just subtract the end time from the start time.
Read 8 tweets
14 Aug
Interviewing for a new position is never easy.

Algorithms & Data Structures are usually a pain for candidates, but so can System Design be.

Let me give you 7 steps that will help you to improve your experience in system design interviews.

🧵👇
1) Clarify The Requirements

Ask questions, and a lot of them!

Try to find out what exactly the interviewer expects from you.

Try to narrow it down as far as possible to the exact scope of the problem.

Even if the question is to (re)design an existing system, ask!
2) Define System Interfaces

Define all APIs that the system to design will need.

Explain what each API is for as detailed as possible, so the interviewer can jump in and tell you if you got a requirement wrong.

If you got something wrong, no problem, adjust accordingly.
Read 8 tweets
13 Aug
Improving developer experience is always a good investment.

It's even one of the investments with the highest return, in my opinion!

Some things that help to improve DX:

🧵👇
1) Providing All Relevant Information Up Front

Ensure that all information necessary is present in a README.md within the project's repository.

It should be sufficient enough to state what the project does, what problems it tries to solve, etc.
2) Making Sure Starting Out Is Easy

Does the project require some setup to be able to run/test/develop locally? -> Write an interactive script which sets everything up, maybe creating a config file / .env with meaningful defaults or settings from script input.
Read 8 tweets
13 Aug
Some things you also have to consider when building services and software systems:

- Logging
- Metrics
- Tracing

🧵👇
1) Logging
Logging may be obvious for many devs, but there's more to it than just doing it.

Choosing a format, which can be processed easily, should be a priority.

Then asking how those logs are collected and where they can be viewed is also pretty important.
1.1) Log Format

Plain text may be easy to read, but can sometimes be pretty difficult to process automatically.

You should also consider so-called tags, which is like a map where certain variables can be set, like request ids, to be able to follow the execution of a call.
Read 14 tweets
5 Aug
Algorithms & Data Structures 1⃣

Array 1⃣: Array Basics

You asked for it, here it is!

An array is the most basic primitive data structure to store a group of elements.

It stores its elements in a contiguous block within your computer's memory and can't grow in size dynamically An array is like a list, yo...
Please note:

Although I am using JavaScript code here, I'm talking about a real primitive array.

The Array in JavaScript is an object, that is backed by a real primitive array, but abstracts away a lot of the stuff I am going to present to you within the next few days.
We will also cover ArrayLists at some point, which will give you the knowledge about how a JavaScript array is approx. implemented under the hood. 😊
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!