In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to be a good developer". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "How to be a good developer"!
1. rule of three
The Rule of Three is a rule of thumb for code refactoring that determines when a copied piece of code should be replaced with a new code/program/method.
It states that you are allowed to copy and paste code once, but when you copy the same code three times, you should extract it into a new program. The main idea is to make code/program/method generic across projects so that it can be reused in many places.
2. Stability is king.
Consistency in structure and coding. This can help you improve readability and maintainability of your code.
Try and come up with consistent coding standards. This helps maintain consistency, preferably accurate to your variable naming conventions. Another important thing is the structure of the code program, which should be obvious, and the developer needs to make some changes or add something new.
3. Reduce nesting
The if in If can clutter up the code structure and quickly become difficult to read. Sometimes you may not be able to get around this problem, but be sure to look at your code structure. The same is true for else if, avoiding if nesting as much as possible because it sometimes makes the code harder to read.
Defensive sentences (also known as early return/early exit) are an effective way to help solve this problem! A guard statement is only used to check prerequisites, and can be either a return statement or an exception.
Example of no guard statement:
if (account != null) { if (order != null) { if (order.term == Term.Annually) { // term annually } else if (order.term == Term.Monthly) { // term monthly } else { throw new InvalidEnumArgumentException(nameof(term)); } } else { throw new ArgumentNullException(nameof(subscription)); } }
Examples of using guard statements:
if (account == null) { throw new ArgumentNullException(nameof(account)); } if (order == null) { throw new ArgumentNullException(nameof(order)); } if (order.term == Term.Annually) { // term annually (return here) } if (order.term == Term.Monthly) { // term monthly (return here) } throw new InvalidEnumArgumentException(nameof(order.term));
4. Think big.
It's important to have a sense of the project as a whole, which makes it easier to follow up on small details. Once you understand the overall structure of the project, the small details don't need to take much time to study.
5. Take a moment to think about naming.
One of the things that bothers us about coding is naming variables, methods, or objects. This can be naming a class, method, or even a variable. A good developer will take the time to think about relevant variable names because they know it helps readability!
6. Technical debt is bad.
Asking for a high point can help solve this problem. Try to write your code logic all at once, otherwise you'll have to refactor it repeatedly.
Technical debt is a concept in software development that reflects the cost of extra rework due to choosing a simple (limited) solution now rather than using a better method that takes longer.
7. overestimation
Depending on your department, you may not like this. But good developers tend to overestimate tasks because they know how long things will take, and then add a buffer of time to that expectation to help you get things done.
This can really help you address the point above- "technical debt is bad." If you underestimate or estimate an ideal time, you may not actually be able to complete it and may even leave some technical debt behind. Because your expectation is just to get it done as quickly as possible and get it running properly, not to make the code clean and easy to maintain.
8. document and comments
Documentation and comments help you and others understand and use them more easily. You'll hear experienced people say, can we document this, or code review fails because the interface doesn't have comments, etc.
9. Dare to delete bad or useless code
You often see a lot of unconfident developers commenting out a lot of code and leaving it there. Version control has a purpose! Good developers don't shy away from removing useless code from their apps.
10. Take the time to review the code you write
Good developers spend more time reviewing code and know how important it is.
Early detection of bugs;
Improve developer skills and get other team members into the habit;
Knowledge sharing;
Consistent design and implementation.
The best code review process I've seen is:
1 small task with low risk should be reviewed by 1 developer;
Medium/large or risky changes should be reviewed by 3 developers, one of whom is a senior developer on their team;
A high-risk change or new feature under development should have a meeting of three developers, at least one of whom is the lead developer, and then look at each line together and make recommendations.
11. write test cases
You'll notice that more experienced and capable developers spend more time writing good test cases. Good test cases can help you extend or modify your code with confidence and help reduce bugs.
12. Spend time designing
Before delving into code or writing code, think carefully and break it down into smaller pieces. This helps you to figure out how to put everything together and is more prepared to create cleaner code.
13. Focus on technical implementation principles rather than syntax
This is a big problem! They prefer basic knowledge to grammar. This will help them find problems more effectively and will also help them understand google problems better.
14. Make Google your best friend.
They are experts in Googling and are better able to find solutions to problems. Because they are more focused on basics than grammar, they know which Google terms to search for, which is hard to do if you are obsessed with learning grammar!
15. Function first and then optimization
Some junior developers seem to spend a lot of time making their code look beautiful in the first place, so that they are embarrassed if they find out that it doesn't work properly. Good developers implement functionality early, so problems can be detected early before details are worked out, helping to keep the project running smoothly.
16. Risk management and problem solving
Senior developers can control risk, abstract complex problems through the application of design patterns, and solve different problems independently based on past experience.
17. ask more
Good developers want to know more. Even if it sounds simple, they don't mind asking questions. These may be technical or business-related issues. Understanding business requirements helps them write better code! They are confident in their abilities and therefore not afraid to ask questions.
18. Separate logic from the database as much as possible
This depends on the type of app you build, but only if it doesn't impact performance.
They know to control database queries in simple CRUD operations.
Create, read (aka retrieve), update, and delete
The business logic layer should then pull these things together. This helps developers know where to look for business logic. If there is logic in database queries and code, this can quickly become confusing.
19. Keep your code simple.
They know that keeping the code simple is the best way to do it. Even if it means writing more code sometimes. You'll see many junior developers writing code like this:
return dir.Keys.Any(k => k >= limit) ? dir.First(x => x.Key >= limit).Value : dir[dir.Keys.Max()]; At this point, I believe that everyone has a deeper understanding of "how to be a good developer", so let's actually do it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.