search
HomeWeb Front-endHTML Tutorial[译]2016年提高你代码质量的四种方法_html/css_WEB-ITnose

2016年提高你代码质量的四种方法

时间:2016-01-09 作者:Dudley Storey 翻译:小天同学

前端工程师常常被困在魔鬼和一片蓝海之间:面对不断变化的技术和各种各样的工具,而又不想改变熟悉舒适的老习惯。

但是如果我们固步自封,又很难取得进步。然而取得进步的关键是经常反思我们之前做事的方式方法:改变那些阻碍我们进步的习惯,采用新的方式方法来提高我们的效率、创造力并享受这一过程。为此,这里我们讨论四种方法来提高你2016年的工作和生活。

一、审查你的代码

审查是可能在任何的一个过程中,不管是检查代码一致性还是检查可能出现的错误。更广泛的说,审查代码使其符合一个共享约定的命名、间距和样式等。在团队中更是非常宝贵,因为大家同样代码风格的代码会更加容易共享和整合,使团队协作的效率更高。即使你是一个人的这种方法同样是有用的:采用一致的代码风格能更大程度的复用你之前的代码。

审查可以参考很多不同的形式:

1.HTML

对于HTML开说,正式的Lint就是本质上的验证,也可能是团队约定的验证:例如,使用团队约定的tab缩进代码的标准来审查HTML代码。这也许能解决使用HTML5的语义标签(如:

标签),而不是一般的
标签,使得在正文中使用正确的排版。

2.CSS

对于CSS的Lint也有很多批评的声音;但是好消息是很多预处理器,比如Sass,已经(或者可以整合)包含Lint工具了。CSS Lint的范围可以从传统问题(属性/值对分离,缩进,按字母顺序排序)到兼容性问题(CSS属性和值应该继续接受保持浏览器兼容性的前缀);在高端用法中,CSS Lint还集成了面向对象风格CSS开发系统的命名规范,比如BEM。

3.Javascript

Javascript代码Lint工具的范围是很强大的,比如: ESLint 。

如同刚开始任何一个新习惯一样,刚开始的时候采用Lint可能会降低工作效率,但是要想快速的得到投资的回报,关键是制定一系列可管理的规范并坚持这个规范。

二、写工作日记

工程师往往如此忙碌的Hack代码,进而让他们理所当然的认为一年中自己取得了不错的成绩。不幸的是,如此的忙碌到头来也不可避免的会让我们忘记一些我们已经取得的经验。为了不忘记我们的工作中的经验,我们应该总结我们在开发中取得的经验并记录下来。最好的方法就是写博客:在社区分享你的工作,但是很多工程师不愿意这样做,因为要写一个好的博客文章要花费大量的时间,而且也不是每个人都想把自己的工作公开出来的。但是也存在很多其他的选择:你可以将你感觉重要的代码保存下来作为依据,保存在一个简单的博客平台上,比如像 CodePen 提供的产品。

这对于时刻提醒你的错误也是很有帮助的:做出的猜测和遇到的困惑。然而经常wince-inducing,写下来承认你的错误,并从中汲取教训,而不是把他们掩饰隐藏起来。

三、使用样式指南

网站的风格指南——网站元素视觉外观和行为规范的制定——真的快要消失了。传统意义上的巨大的学科正在崩塌,从设计崇高的栖息,到开发者没有探讨和辩解的思想。风格指南已经发展成为活生生的,动态的数字文档,这将有助于加快网站的开发,使页面的风格更加的一致。

四、保重自己

保持锻炼和健康的饮食习惯会让你感到分心,实际上,这是一种投资,有助于你更好的创造和更有效率的工作,而且还能保证你的身体能够更长时间的工作(如果需要)。

尝试着规律的休息在工作的时候,在你的桌子上放一些健康的食物。制定一个活动日程表,保证你的身体和大脑能够得到充足的休息。

无论你是否接受这些做法或者你自己的选择和设计,最重要的是要做出一些改变在你的开发生活中,这样才能提高和成长。

照片By:Lord James,根据知识共享许可

原文链接

由于本人水平有限,如有错误欢迎指正。

扫码关注w3ctech微信公众号

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment