How clean is your code? Part I

Tips to write good code while keeping a good pace

Photo by Oliver Hale on Unsplash

Why should you care about your code?

“C’est au pied du mur qu’on voit le maçon”, means that you’re are being evaluated based on your craft. When you’re applying for a job, someone will likely review your past project code, and what will they look for? They don’t have time to fully review your code, so they will look for mistakes(anti-pattern, code smells, bad naming). Very bad code = Not getting hired!

1- Folder structure

The way you organize your package, folders, files, and code matter a lot. You don’t expect to find your socks in the fridge, right? Ok, maybe. But when you organize your files and folders you make it easier for you to modify the codebase because you know exactly where your “socks” are.

//Package by layer                  
├── adapters
│ ├── HomeAdapter
│ ├── SignInAdapter
├── viewmodels
│ ├── HomeViewModel
│ └── SignInViewmodel
├── views
│ ├── HomeView
│ └── SignInView
├── models
│ ├── Home
│ └── SignIn
//Package by feature
├── ui
│ ├── home
| │ ├── HomeAdapter
| │ ├── HomeViewmodel
| │ └── HomeView
│ ├── signin
| │ ├── SignInAdapter
| │ ├── SignInViewmodel
| │ └── SignInView
| model
| ├──home
| │ └── Home
| ├──signin
| │ └── SignIn

2- Naming

You’ve probably read this somewhere: “There are only two hard things in Computer Science: cache invalidation and naming things.” Phil Karlton.

3- Readability and Conciseness

Programming languages are praised for being concise, like Kotlin, Swift, Python but dreaded for being verbose like Java so does your code. Concise means clear, short, and comprehensive. Conciseness is the balance between short and clear where clear is more important.

4- Comment

Commenting is very important, but comments are like using salt in cooking, use it sparingly, and don’t use it for just every recipe. We’re not talking about documentation comment but code comment.

// Calculate the radius of a circle  <- This is bad
fun calculateRadius(circonference: Long) {
// Always use the BarFactory for creating Bar objects because it //guarantees they will be initialised 
//using the correct Config. <- This is good
fun getBar() {


Structure your code well, so it’s easier to navigate through your files. Name your classes, functions, variables properly, add comment when necessary to explain the why, strive for readability more than you do for conciseness. If you do those well, your code will be cleaner and more maintainable.

Further Reading

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store