zoukankan      html  css  js  c++  java
  • Maintainable JavaScript(编写可维护的JavaScript) PART I Style Guidelines

    “Programs are meant to be read by humans and only incidentally( 顺便;偶然地;附带地) for computers to execute.” —Donald Knuth

    When a team is brought together(被放在一起) for the first time, everyone brings with them their own ideas about how code should be written. After all, each team member comes from a different background. Some may come from one-man shops where they could do whatever they wanted; others may have been on different teams that had particular ways of doing things that they liked (or hated). Everyone has an opinion about how code should be written, and it usually falls in line with(fall in line with 同意) how that individual would personally write it. Establishing style guidelines should always come as early in the process as possible.

    The terms “style guidelines” and “code conventions” are often used interchangeably. Style guidelines are a type of code convention aimed at the layout of code within a file. Code conventions can also include programming practices, file and directory layout, and commenting. This book is actually a collection and discussion of code conventions for JavaScript.

    Why Style Guidelines?

    Figuring out style guidelines is a process that typically takes longer than it should.Everyone has an opinion and, when you’re going to be spending eight hours a day writing code, all  programmers want to do so in a way that is comfortable to them. It takes some compromise within the team and a strong leader to move the conversation forward. Once established, style guidelines allow the team to work at a much higher level, because all code looks the same.

    Having all code look the same is incredibly important on a team, because it allows:

    • Any developer to work on any file regardless of(不管) who wrote it. There’s no need to spend time reformatting or deciphering the logic of the file, because it looks the same as everything else. If you’ve ever opened a file and immediately fixed all the indentation before starting your work, you can understand the time savings consistency provides when working on a large project.

    • Errors become more obvious. If all code looks the same, and you come across some code that doesn’t, you’ve likely found a problem.

    It’s no wonder that large companies around the world have published style guidelines either internally or publicly.

    Style guidelines are a personal thing and must be developed within a team to be effective. This section of the book lists recommended focus areas for the development of your JavaScript code conventions. In some cases, it’s impossible to tell you that one guideline is better than another, because some are just a matter of preference. Rather than trying to force my preferences upon you, this chapter highlights important aspects that should be covered in your style guidelines. My personal code style guidelines for JavaScript are included in Appendix A.

  • 相关阅读:
    一文读懂数字人民币的发行原因与特性
    人工智能时代来临,我们终将何去何从?
    SQL在物联网时代还值得使用吗?
    比你更懂你的物联网时代,电商会不会出现新的模式
    什么样的才叫物联网?物联网发展趋势会比互联网更好吗?
    如何使用人工智能创建蛋白质形状的语言
    为什么智能优势是未来物联网的核心
    大数据、物联网和人工智能等技术能否带来新的模式
    函数间的参数传递
    函数间的参数传递
  • 原文地址:https://www.cnblogs.com/ghgyj/p/4006924.html
Copyright © 2011-2022 走看看