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.

  • 相关阅读:
    cassandra安装
    002 spring boot框架,引入mybatis-generator插件,自动生成Mapper和Entity
    033 SSM综合练习09--数据后台管理系统--基于AOP的日志处理
    032 SSM综合练习08--数据后台管理系统--jsp页面显示当前用户名
    031 SSM综合练习07--数据后台管理系统--用户详情查询
    030 SSM综合练习06--数据后台管理系统--SSM权限操作及Spring Security入门
    029 SSM综合练习05--数据后台管理系统--订单分页查询
    027 SSM综合练习03--数据后台管理系统--product-list.jsp和main.jsp页面制作
    Idea 目录结构下有红色波浪线
    virtualbox上,android x86 的分辨率的设置
  • 原文地址:https://www.cnblogs.com/ghgyj/p/4006924.html
Copyright © 2011-2022 走看看