程序员沟通技巧_6种使程序员生活更轻松的技巧

程序员沟通技巧

Whether you are a novice or experienced programmer, following these helpful professional tips will save you time and greatly improve the quality of your code.

无论您是新手还是经验丰富的程序员,遵循这些有用的专业提示都将节省您的时间,并大大提高代码质量。

1)为人类而不是机器编写代码 (1) Make Code For Humans, Not just Machines)

When you are writing code, you must always think: Will another programmer understand what you have written? That other programmer may very well be your future self. To ensure readability, it’s essential to make your identifiers (i.e. variable and function names) consistent throughout your code. Additionally, designing a similar length, grammatical structure, and explanatory style when naming your functions will provide uniformity and help anyone who is reading the code.

在编写代码时,您必须始终思考:另一个程序员会理解您编写的内容吗? 那位其他程序员很可能就是您未来的自己。 为了确保可读性,必须在整个代码中使标识符(即变量名和函数名)保持一致。 此外,在命名函数时设计相似的长度,语法结构和解释样式将提供一致性,并帮助正在阅读代码的任何人。

Image for post
Martin Fowler
马丁·福勒

2)编写代码,您会记住 (2) Make Code You will Remember)

This won’t be the last code you write, so write code you will remember six months or a year from now. Name your methods with short but descriptive verbs representing the action they perform. When coding with numbers and strings, assign meaningful variables that will be recognizable later on. Using meaningless numbers, signs and symbols will only create frustration in the future. Keep it simple and straightforward.

这不是您编写的最后一个代码,因此编写代码将使您记住六个月或一年。 用简短但描述性的动词来表示您的方法,这些动词代表它们执行的动作。 使用数字和字符串编码时,请分配有意义的变量,这些变量稍后将被识别。 使用无意义的数字,符号和符号只会在将来造成挫败感。 保持简单明了。

3)使用正确的语言解决问题 (3) Use the Right Language to Solve the Problem)

When it comes to deciding which programming language to use, choose the right language for the project. Often new programmers try to cut corners and code with a language they already know, even if a different language is better suited for the task. Finding and using the correct language or tool for the project might increase the work but putting in the extra time will be worth it in the long run. Remember, it’s better to take the extra time and do a job right the first time, than to take shortcuts and have to go back and fix the loopholes you missed initially.

在决定使用哪种编程语言时,请为项目选择正确的语言。 即使不同的语言更适合该任务,新程序员也常常尝试使用他们已经知道的语言来偷工减料和编写代码。 为项目找到和使用正确的语言或工具可能会增加工作量,但从长远来看,花额外的时间是值得的。 请记住,比起采取捷径而不得不回过头来纠正最初错过的漏洞,花更多的时间来第一次做正确的工作要好。

4)如果被卡住,请休息一下 (4) If You Get Stuck, Take a Break)

Everyone has those moments when you get so frustrated with coding you start yelling and blaming your troubles on your computer. If or when this happens, take a step back from your computer and do something to take your mind off coding. Perhaps a bathroom break or a walk around the block will be sufficient. But often it’s better to work on another project or take a half hour break from work completely and do something relaxing. Once you feel refreshed and energized, take another stab at the code.

当您对编码感到沮丧时,每个人都会遇到这些时刻,您开始大吼大叫并将麻烦归咎于计算机。 如果发生这种情况,请从计算机后退一步,并采取一些措施使您不必担心编码。 也许洗手间或在街区漫步就足够了。 但是通常最好是进行另一个项目,或者完全休息半小时并放松一下。 一旦感到精神焕发和精力充沛,请再次尝试一下代码。

5)保持方法的可维护性 (5) Keep Methods Maintainable)

Complicated monster methods are a common error seen among novice programmers. To save time and headaches, limit your methods to a manageable size making your code easier and quicker to read and maintain. When you have lengthy methods, break it up into smaller descriptive components, each portion representing a well-abstracted action. If you don’t do this proactively, the monster method will win. With maintainable methods, not only will the code be more readable, it makes debugging the code simpler and less time consuming.

复杂的怪物方法是新手程序员常见的错误。 为了节省时间和麻烦,将您的方法限制在可管理的范围内,使您的代码更易于阅读和维护。 如果有冗长的方法,请将其分解为较小的描述性组成部分,每个部分都代表一个抽象的动作。 如果您不主动执行此操作,monster方法将获胜。 使用可维护的方法,不仅使代码更具可读性,而且使调试代码更简单且耗时更少。

6)英文代码 (6) Code in English)

Using English as your main coding language will simplify everything. English has become the universal language of code. To improve the usability and versatility of your code, you must use a language all programmers can read and understand. Having a universal language facilitates efficiency, readability and commonality as well as, it allows programmers to connect internationally with one another and share their codes easily without need for translation.

使用英语作为主要的编码语言将简化一切。 英语已经成为代码的通用语言。 为了提高代码的可用性和多功能性,必须使用所有程序员都可以阅读和理解的语言。 拥有一种通用的语言不仅可以提高效率,可读性和通用性,还可以使程序员在国际上相互联系,并轻松共享其代码而无需翻译。

Although some of these tips may seem tedious or time consuming now, once you incorporate them into your daily coding routine, you we quickly see enhanced work performance and efficiently throughout your daily tasks.

尽管现在这些技巧中的一些看起来似乎很乏味或很耗时,但是一旦将它们纳入日常编码例程中,您就会很快看到在整个日常任务中工作性能得到了有效提高。

翻译自: https://medium.com/swlh/6-hacks-to-make-a-programmers-life-easier-a17bdd0c1c91

程序员沟通技巧

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值