编写代码用什么牌子电脑好

tech2023-07-11  103

编写代码用什么牌子电脑好

In any given week I can expect to write at least a few hundred lines of code in around four different languages. I can also expect to edit, review, and collaborate on code written by the other developers I work with.

在任何给定的一周里,我都可以用至少四种不同的语言编写至少几百行代码。 我还可以期望在与我一起工作的其他开发人员编写的代码上进行编辑,审查和协作。

Simply put, there’s a lot of code flying around all over the place, and things can get very complicated when it’s not organized, managed, and most importantly, written well. Let’s look at a few different ways to improve the overall quality of our code.

简而言之,到处都是很多代码,如果没有组织,管理,最重要的是编写得不好,事情就会变得非常复杂。 让我们看一下提高代码整体质量的几种不同方法。

1.开始构建模块 (1. Start Building Modules)

One of the best ways to keep code consistent, reusable, and organized, is to group functionality together. For example, rather than dumping all your JavaScript into one main.js file, consider grouping it into separate files based on functionality, then concatenating them once you reach your build step. Of course, there’s a lot more to writing modular code, and you can write modular code for more than just JavaScript.

保持代码一致,可重用和组织化的最佳方法之一是将功能分组在一起。 例如,与其将所有JavaScript都转储到一个main.js文件中,不如考虑根据功能将其分组为单独的文件,然后在完成构建步骤后将它们串联起来。 当然,编写模块化代码还有很多,您可以编写模块化代码,而不仅仅是JavaScript。

CSS preprocessors like Sass (our introduction here) allow you to write individual CSS files, and then include them into one main file when you compile them. This lets you write individual CSS files for different components like buttons, lists, and fonts. At the end, they’re all included into one main file, but maintaining these files becomes a whole lot easier.

像Sass这样CSS预处理程序(我们的简介在这里 )允许您编写单个CSS文件,然后在编译它们时将它们包含在一个主文件中。 这使您可以为按钮,列表和字体等不同组件编写单独CSS文件。 最后,它们都包含在一个主文件中,但是维护这些文件变得非常容易。

New technologies, such as Polymer allow you to write custom HTML elements, so that your HTML, CSS, and javascript can be grouped into individual components based on functionality. Be sure too look into Browserify (our introduction here), which allows you to use Node.js-style modules in the browser.

诸如Polymer等新技术可让您编写自定义HTML元素,以便可以根据功能将HTML,CSS和javascript分组为单个组件。 请确保也浏览Browserify ( 此处是我们的介绍),它使您可以在浏览器中使用Node.js样式的模块。

Brad Frost also gives a great overview on the ideas and methodologies for writing modular code here.

Brad Frost还对此处编写模块化代码的思想和方法进行了概述。

2.说到预处理器… (2. Speaking of Preprocessors…)

Preprocessors don’t just help with writing modular code. They’re great for a lot of other things too! Preprocessors add extra functionality to your code internally, while outputting the same HTML, CSS, and Javascript that your browser recognizes. They usually require some extra setup time, but they make up for it once you’re comfortable with using them.

预处理器不仅可以帮助编写模块化代码。 它们对于许多其他事情也很棒! 预处理器会在内部为代码添加额外的功能,同时输出浏览器可以识别的相同HTML,CSS和Javascript。 它们通常需要一些额外的设置时间,但是一旦您习惯使用它们,它们就会弥补这一点。

Using a preprocessor can help you save time by eliminating the need to write the same repetitive code multiple times. They also add helpful functionality like variables, functions, loops, and simplified syntax. Most preprocessors are highly customizable as well. Several include the option to select your prefered output style, incorporate plugins and addons, and even create custom notifications when needed. The most popular preprocessors have large communities, are well maintained, and answers to common problems are not hard to find.

使用预处理器可以消除多次编写同一重复代码的需要,从而帮助您节省时间。 它们还添加了有用的功能,例如变量,函数,循环和简化的语法。 大多数预处理器也是高度可定制的。 其中一些选项可以选择您喜欢的输出样式,合并插件和插件,甚至在需要时创建自定义通知。 最受欢迎的预处理器社区很大,维护良好,对常见问题的答案也不难找到。

Here’s a video introduction to the most common preprocessors for CSS, HTML and JavaScript: Sass, Haml and CoffeeScript.

以下是有关CSS,HTML和JavaScript最常见的预处理器的视频介绍: Sass,Haml和CoffeeScript 。

If you’re interested in Sass, here’s a look at how SitePoint author Hugo Giraudel organizes his Sass projects, and his favorite tools for doing so.

如果您对Sass感兴趣,请看一下SitePoint作者Hugo Giraudel如何组织他的Sass项目 ,以及他最喜欢的工具 。

While you’re looking at Sass, be sure to check out HAML and Coffescript as well.

在查看Sass时,请务必同时检查HAML和Coffescript 。

You don’t have to use a preprocessor for every language you write, but many of them are helpful and can lead to you writing better code.

您不必为每种编写的语言都使用预处理程序,但是其中许多功能很有用,可以使您编写更好的代码。

3.写作前计划 (3. Plan Before You Write)

When was the last time you sat down and on paper wrote out exactly how you would approach a project? What frameworks do you plan to use, how many browsers are you expected to support, do you plan to use any automated task runners or build systems? It’s easy to jump into a project thinking you know exactly how it should be structured, only to realize halfway through that you need to go back and rewrite some code.

您上次坐下时是什么时候在纸上写出您将如何进行项目的确切记录? 您计划使用哪些框架,预计将支持多少个浏览器,您计划使用任何自动任务运行程序还是构建系统? 跳入一个项目很容易,以为您完全知道应该如何构造它,而只是半途而废,因此您需要返回并重写一些代码。

North is an outstanding set of guidelines that outline how to plan a web project from start to finish. It’s a long and comprehensive living document, not all of which has to do with writing code, but its length and detail goes on to show just how many factors must be considered when building a website.

North是一套出色的指南,概述了从头到尾如何计划Web项目。 这是一个漫长而全面的文档,并不是所有的内容都与编写代码有关,但是它的长度和详细程度继续说明了构建网站时必须考虑的因素。

Deciding on the right tools and libraries to use can be a challenging task, especially when new tools and libraries are created every day. I curate this list of tools and resources to help keep track of the best and most useful, so feel free to use it when planning your next project.

选择合适的工具和库可能是一项艰巨的任务,尤其是每天创建新工具和库时。 我整理了这些工具和资源列表,以帮助跟踪最佳和最有用的工具,因此在计划下一个项目时可以随时使用它。

4.使用版本控制 (4. Use Version Control)

Version control is a system that records changes to a file or set of files over time, allowing multiple users to edit, track changes, and host assets. There are plenty of services that enable version control, including Bitbucket, Assembla, and Github. Github is my personal favorite, as it promotes social coding, meaning people can share code on Github while improving and learning about code written by other users.

版本控制是一个系统,该系统记录一段时间内对一个文件或一组文件的更改,从而允许多个用户编辑,跟踪更改和托管资产。 有很多启用版本控制的服务,包括Bitbucket,Assembla和Github。 Github是我个人的最爱,因为它促进了社交编码,这意味着人们可以在Github上共享代码,同时可以改善和学习其他用户编写的代码。

Version control can be a complicated topic to understand, but there are plenty of tutorials to help get you started. I recommend taking a look at our introduction to Git for a basic overview on getting started. We also have a guide to using Git in a team environment and some tips to take your Git skills to the next level. If you’re not sold on Git, you have other options for version control as well.

版本控制可能是一个很难理解的主题,但是有很多教程可以帮助您入门。 我建议看一下我们对Git的介绍,以获得有关入门的基本概述。 我们还提供了在团队环境中使用Git的指南,以及一些使Git技能更上一层楼的技巧 。 如果您未在Git上出售产品,则还有其他版本控制选项 。

One last tip: use the command line. The command line can be an intimidating interface, but getting familiar with it will go on to improve your understanding of programming as a whole, while enabling you to use other great tools like Gulp and Grunt.

最后一个提示:使用命令行。 命令行可能是一个令人生畏的界面,但是对它的熟悉将继续增进您对整体编程的理解,同时使您能够使用其他出色的工具,例如Gulp和Grunt。

5.开始进行代码审查 (5. Start Holding Code Reviews)

This is easier to do if you work with a team of developers, but not impossible if you work on your own. The basic idea of a code review is to present some code you’ve written to a group of peers (or superiors) so that you can explain what you’ve written, learn how to write better, and even teach others who may be unfamiliar with the technologies you’ve written.

如果您与一组开发人员一起工作,这样做会更容易,但是如果您自己工作,这并非没有可能。 代码审查的基本思想是将您编写的一些代码呈现给一组同行(或上级),以便您可以解释自己编写的代码,学习如何更好地编写代码,甚至可以教其他可能不熟悉的代码您所编写的技术。

It’s best done weekly, with the goal of learning how to improve what you’ve already written. Here’s an article on the benefits of code reviews that explains how to get the most out of it.

最好每周进行一次,目的是学习如何改进已经编写的内容。 这是一篇有关代码审查的好处的文章 ,介绍了如何最大程度地利用它。

If you don’t work on a team, or you’re very anti-social, jslint and SCSSlint can be helpful. These tools will check your code for errors while keeping your files neat and clean. No human contact necessary!

如果您不在团队中工作,或者您非常反社会,那么jslint和SCSSlint可能会有所帮助。 这些工具将检查您的代码中是否有错误,同时保持文件整洁。 无需人工干预!

6.应对编码挑战 (6. Take Coding Challenges)

There are plenty of free resources online that are aimed towards providing challenges for developers looking to get better at languages they use every day. Most of these sites come with a large community willing to help out when needed, so don’t worry about getting stuck and being unable to continue.

在线上有大量免费资源,这些资源旨在为希望日渐完善他们每天使用的语言的开发人员带来挑战。 这些站点中的大多数都有庞大的社区,愿意在需要时提供帮助,因此不必担心会卡住或无法继续。

CodeWars is great for brushing up on your javascript abilities, and The Practice App will give you random front end challenges to build on Codepen.

CodeWars非常适合提高您的javascript能力, The Practice App将为您提供在Codepen上构建的随机前端挑战。

结论 (Conclusion)

Following some or all of these tips will drastically improve your coding skills, and therefore the quality of the sites, tools or apps you’re building.

遵循这些技巧中的一些或全部将极大地提高您的编码技能,从而提高您所构建的网站,工具或应用程序的质量。

Have some more tips and tools for writing better code? Feel free to share in the comments!

还有更多技巧和工具可以编写更好的代码吗? 随时分享评论!

翻译自: https://www.sitepoint.com/6-tips-for-writing-better-code/

编写代码用什么牌子电脑好

相关资源:购物网站系统源代码网页模板正式版
最新回复(0)