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: Evolution and TrendsThe Future of HTML: Evolution and TrendsMay 13, 2025 am 12:01 AM

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

Why are HTML attributes important for web development?Why are HTML attributes important for web development?May 12, 2025 am 12:01 AM

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

What is the purpose of the alt attribute? Why is it important?What is the purpose of the alt attribute? Why is it important?May 11, 2025 am 12:01 AM

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML in Action: Examples of Website StructureHTML in Action: Examples of Website StructureMay 05, 2025 am 12:03 AM

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

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 Article

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.