开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
今日推荐开源项目:《第三方登录 JustAuth》
今日推荐英文原文:《6 Programming Habits That (Surprisingly) Not Many Developers Have》
开源日报第779期:《第三方登录 JustAuth》
今日推荐开源项目:《第三方登录 JustAuth》传送门:GitHub链接
推荐理由:JustAuth 是一个第三方授权登录的工具类库,可以让我们脱离繁琐的第三方登录SDK。
目前已支持Github、Gitee、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、支付宝、QQ、微信、淘宝、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、人人、华为、企业微信、酷家乐、Gitlab、美团、饿了么和推特等第三方平台的授权登录。
今日推荐英文原文:《6 Programming Habits That (Surprisingly) Not Many Developers Have》作者:Daan
原文链接:https://medium.com/better-programming/6-programming-habits-that-surprisingly-not-many-developers-have-c58acd9a67f3
推荐理由:好习惯伴随一生,无论学习,工作还是生活。

6 Programming Habits That (Surprisingly) Not Many Developers Have

Distinguish yourself from the herd

When it comes to being a good programmer, there are certain habits that immediately pop up in your mind. There are some habits that most programmers would agree are great to have, but in reality, most of them don’t have these habits themselves. As we all know, we are defined by our habits. To become a better programmer, we should try to build great programming habits. Here are six great programming habits that you should try to build to stand out from the pack.

1. Clean Up Your Code

A great programming habit is that whenever you change a piece of code, you should try to improve that code — it doesn’t matter whether you’re just fixing one line of code or adding an entirely new feature to the existing code.

Robert C. Martin had a great quote for this habit that was based on the Boy Scout Rule:

“Always leave the code you’re editing better than you found it.”
You’ll be amazed by how many small things you can improve while reading through some code. The changes that you make can be as small as renaming a variable or function. Just make sure to do at least one improvement at a time. You’ll leave the code in much better shape and heavily reduce the number of code smells.

The reason why this is such a good habit to have is that we learn constantly. Things that were considered to be good yesterday can be done better in some other way today. Code tends to rot over time, so taking care of your code is essential to keep it maintainable.

2. Think About Who’s Next

Whenever you’re writing a piece of code, you should think about what the next developer is going to find when looking at that piece of code.

Write that piece of code with the mentality to make it easily understandable and as readable as you can. The ratio of time spent reading code versus writing code is well over 10-to-1. This means that you can save a lot of time in the long run by putting in a little more effort into making your code readable.

Don’t try to be fancy when it comes to coding — write simple code that everyone can understand. There’s really no need to do some magic one-liners that you’ve copied from Stack Overflow that you don’t even really understand yourself.

3. Do What’s Needed — Not More Than That

Developers tend to have the weird habit of overdoing things. When a certain feature is requested most developers will build something extra “just in case.”

This is what we call overengineering, which is the art of overdoing things. Code is made more robust or complicated than necessary. The thing with overengineering is there’s no good reason for doing it.

Most of the time, the reason that more gets built than what is really necessary is based on speculation. The developer is already adding code that might be helpful in the future, based on their own thoughts. This additional piece of code gets added to the codebase, but it probably never gets used.

Overengineering can lead to code that is being designed to be so generic that it loses sight of the main task that it was initially designed to perform. Therefore it becomes not only hard to use but fundamentally unintelligible.

4. Plan Your Code

Real programmers love to do one thing and one thing only, and that’s programming. That shouldn’t really shock you. So the obvious thing that happens is that most programmers jump straight into the part that they love the most when they get assigned a certain task.

They start coding immediately.

Rushing into the code might seem exciting at first. However, that excitement might end up costing you a lot of time. When jumping straight into the coding part, you’ll eventually lose sight of the bigger picture.

Before you start coding, you need to plan and organize. Think about problems that you might find along the way and how can you tackle them. How will you structure your code? What’s the reason that you’re going to implement this feature?

These are all great questions to ask yourself before you start coding. These questions can make you more aware of the fact that there’s a lot to think about before writing code.

5. Document

Yes, I know… Definitely not the fanciest habit on this list but a great one to have. Documenting your work is extremely important.

Did you ever have to check out a repository that didn’t have any documentation about how to set up everything properly or how the application was supposed to work?

After reading through the code for a couple of hours, chances are that you still didn’t have a clue. That’s when you wished for some documentation.

As a bare minimum, I would recommend a proper readme.md for your projects that explains what the application is supposed to do and how you can get it up and running.

The exciting part about documentation is that you could do it while coding. Take some time to think about descriptive variable names — this will pay for itself. Choosing good names for your variables, methods, and classes takes time, but it saves more time than it takes.

If you want to read more about how you can create meaningful names in your code, read this article that I’ve written.

6. Never Stop Learning

As Isaac Asimov said, “The day you stop learning is the day you begin decaying.” This is especially true in the tech world, where things change at a rapid pace.

It’s impossible to keep up with everything that changes, and even if you could, I wouldn’t recommend it. Don’t take this to the extreme, but it’s good to learn a new framework or programming language every once in a while.

This doesn’t mean that you have to become an expert in all of these programming languages or frameworks. It’s good to experiment with some of them and see whether you like them.

You’ll gain a lot of new insights into how certain problems are solved in other programming languages or frameworks that will help you grow as a programmer.

Wrapping It Up

When it comes to being able to distinguish yourself as a programmer, there are numerous habits that you could build. We’ve gone over six of these habits that the majority of developers don’t have.

These are the habits that will make you stand out:

+ Clean up your code + Think about the next person who has to look at your work + Don’t do more than needed + Plan your code + Document your work + Never stop learning Try building these habits for yourself, one at a time. Remember that it takes time and consistency to build them — it won’t happen overnight.

Thanks for reading!


下载开源日报APP:https://openingsource.org/2579/
加入我们:https://openingsource.org/about/join/
关注我们:https://openingsource.org/about/love/