This content originally appeared on Level Up Coding - Medium and was authored by Anh Dang
Thought Programmer
Good Programmer vs Bad Programmer
Writing software is hard but writing good software is very hard. There are many existing terms related to programming techniques such as Clean Code, STUPID principle, SOLID principle, and so on. They help us to become a good programmer and avoid things those bad programmers did.
Today let me help you to look at them carefully.
1. Don’t learn only to code
For any programming language, there is a set of principles that acts as the foundational basis like syntaxes, keywords, concepts, and so on.
Don’t learn programming syntax first, let’s study concepts. Syntax is different for every programming language.
What you really should learn are the concepts like OOP (Object Oriented Programming), FOP (Functional Oriented Programming), POP (Procedural Oriented Programming); branching (if-else, while-do), iteration (for) or design patterns.
If you can write if-else blocks but you don’t know how to use them it means that you learn syntax but don’t understand foundational concepts.
2. Avoid outdated information
Follow tech news (blog, newsletter, and so on) with new updates emerging almost every day like my page.
But keep in mind that each of these types of sources has different advantages and disadvantages.
Technology changes very quickly and you are cut down to run into issues from using old resources.
So let make sure that you checked the date of published information before you are looking at it further.
In practice, I have learned very many concepts and knowledge daily. I already keep up with emerging techs.
You also should check the versions of libraries that you are using in your programs to get the latest version.
3. But don’t forget old books
Let’s read old books.
Some information is more than 10 years old but it’s still very useful.
Human beings have been around for a long time.
So almost every problem you have has probably been written about by some other human living before you.
4. Stop using else keyword in your program
In some simple cases, you are allowed to use else keyword.
if (codition) {
if statements
} else {
else statements
}
As a good programmer, you use switch-case statements.
But in a complex case, good programmers don’t use the else keyword (or switch-case statements).
Instead of the else keyword, they use state-machines.
If you don’t know any about state-machines, you are not a good programmer.
Also, as a good programmer, you should use De Morgan to simplify your logic.
5. Don’t write bad comments
In my opinion, comments are unnecessary.
Bad comments are truly worse than no comments at all.
A comment is of zero value if it is wrong.
Here is a bad comment that should avoid since only if the comment describes what the code is doing.
/* set the value of the age integer to 32 */
int age = 32;
Comments often attempt to explain what or how which tends to merely repeat the code.
So, keep in mind that if you use comments in your program, it should explain why not how.
6. Don’t be a STUPID programmer
They’re 6 code smells that we should avoid while writing programs.
Singleton pattern
It is one of the simplest design patterns.
It ensures there can only ever be a single instance of a given class.
But programs using global state are very difficult to test.
Programs that rely on global state hide their dependencies.
Try and avoid Tight Coupling
Tightly coupled modules are difficult to reuse.
And also hard to test.
Untestability
Whenever you don’t write unit tests because you don’t have time.
The real issue is that your code is bad, but that is another story.
The Dangers of Premature optimization
There’s a famous quote by Donald Knuth, author of the legendary “The Art of Computer Programming”.
It is also an old book.
Premature optimization is the root of all evil.
There are only two rules to optimize an application.
Don’t do it.
Or don’t do it yet.
Indescriptive Naming
You write code for people, not for computers.
Computers just understand 0 and 1. Programming languages are for humans.
Duplication is waste.
Duplicated code is bad.
When you duplicate code, you hide the repeated structure, and you copy all of the existing bugs.
So please Don’t Repeat Yourself and also Keep It Simple, Stupid.
7. Don’t build everything from scratch
Don’t reinvent the wheel.
We have to make sure that we do the right things and don’t do unnecessary things.
Let’s use tools and libraries developed by others. Also, there are coding guidelines across languages.
Try to understand what solutions exist in the world before venturing into building something from scratch.
8. Stop being afraid to ask for help
Sometimes you stuck in a problem.
You can not know everything.
Everyone is always ready to share.
Never be afraid or too proud to reach out and ask other people for advice.
Even if you have crazy questions.
If I can be of assistance, please do not hesitate to contact me.
Easy, right?
Thanks for reading and don’t forget my bits of advice. If you like my content, please follow my page Anh Dang.
Things I’ve Learned to Avoid in My 15 Years as a Software Engineer was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Level Up Coding - Medium and was authored by Anh Dang
Anh Dang | Sciencx (2021-10-22T14:10:08+00:00) Things I’ve Learned to Avoid in My 15 Years as a Software Engineer. Retrieved from https://www.scien.cx/2021/10/22/things-ive-learned-to-avoid-in-my-15-years-as-a-software-engineer/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.