How to write clean code

As a software developer, writing code is obviously our top task. Just like architects, their mission is to create houses that are both beautiful and firm but our work is similar.

We are hired to create automated solutions to solve existing problems of different industries. Sometimes, people tend to only evaluate the final product, which may be the application / software / solution that we give them. However, there are many things to do before the final product. And the foundation of a finished product is still code. When the code is well written, everything becomes more fluid.

So how do you write beautiful and clean code? The more clean your code is, the more professional you are considered, and the easier it will be to adjust, to fix errors, and develop new features in the future.

Are you interested in writing clean code? If yes, follow the video below

Translations from videos on:

Hello, what's up, I'm John Sönmez of simpleprogrammer.com . I have received the question of how to write clean code. I can help you with that. Writing clean code is what makes me focus so much when I'm a software developer and I think it's very important. This email came from Pratham.

He said: "Hello John, I'm a fan of your Youtube channel. I am an Android programmer and am working freely. Recently, I encountered an obstacle in adding functionality to a project. After the inquiry process, I learned that Google has examples where functionality is mentioned in one of their open source applications. ” He said: “When browsing their code, I was surprised by the level of abstraction and how they arranged everything. Even, I feel like I haven't reached that level yet. I would love to know, how can I reach that level. Currently, I am no longer naive like a year ago, but what I think I lack the most is the abstraction of the code, separating the code and testing. Do you have any suggestions so that I can advance to a higher level? "

There are a few things that I think can help. First, I would like to introduce 2 books. You probably already have one, I would like to introduce to you who haven't, the first book is Code Complete by Steve McConnell, this is a really good book. Go buy and read it. It will help you write good and cleaner code. Then you will be surprised with Robert Martin's second book Clean Code, who wrote the title of my book – and I consider it my mentor, this book is really great. . If you read both of these books and start doing what they have said in it, you will write better code.

My ability to write code after reading these two books has increased by 5-6 steps easily. I started writing much cleaner code, a lot of abstract concepts became clearer, all the things you mentioned, the kind of code you looked at from a software developer perspective. "Oh, like a poet, I can read it with a cigar and a Scotch pack." I am exaggerating a small problem, but anyway, my code has become cleaner from reading these books.

This brings me to another point where you're heading. You look at your code, then you look at other people's code that their code is better, cleaner, more flexible, more abstract, learn it. Try to apply it, edit it. If you already have the source code, add it. Imagine like you implemented a new feature based on that code – Then start applying it when you deploy your own project.

Another thing I will say here is the link between you and the developers they write good at. Pairing is one of the fastest ways to learn how to write good code, pair with people who write good code. Find someone, offer to help them for free, either work with them, or be someone working with you and you're ready to tell them "Can I write a program with you?" , or "Can I sit here and see what you're doing?" if you can stay behind someone, look at what they're doing. Sometimes the fastest way to gain knowledge, like when I want to learn a new skill I will go to find an expert and say, "Can I pay you to see what you are doing?" Or "Can I help you? “, Usually you won't have that opportunity.

These can make big changes. You see someone writing good code and if you can ask a few questions, if you say "Oh, that's interesting. Why do you do that? ”Without asking such questions, ask what the idea is. When you understand their idea, you can start to follow that idea. We are very good at imitating. The fact is we have brain cells that are capable of mimicking behavior when we see it. That is one of the great things of people. So, if you see someone's actions and understand what they do, you can imitate them and can do the same exactly.

Anyway, I think these are the best ways to make sure you get better in the future. As long as you always try your best, you will achieve good results, and look at good examples. Connect to everyone you can and read 2 books that I've introduced to you, which will help you write better, cleaner code. Sure.

That's good, that's all I give you today and if you have any more questions, email me at john@simpleprogrammer.com . I will answer you the next time. Best regards.

Translation of Thien Le (goclaptrinhinfo@gmail.com)

ITZone via Techmaster

Share the news now