无论您是在高中,大学还是其它途径学习的编程,问题是您实际上并没有学习如何编写干净的代码。
Whether you learn to program in high school, the university, or in some other way, chances are you really don't learn how to write clean code.
即使在应用程序只供本地使用的情况下,也应该编写干净的代码,并提供足够的测试和调试输出。
Even when an application is only for local use, write clean code, and have lots of instrumentation and debugging output available.
但是我将关注一个我在记录这个播客时所遇到的一个问题:不能够编写干净简洁的代码,这也是程序员们遇到的一个相当普遍的问题。
But I would like to focus on an issue that arose while I was recording the podcast: programmers' all too common inability to write clean, maintainable code.
如果你想尽可能快地工作,就需要编写干净整洁的代码。
If you want to work as fast as you can, you want to work with clean code. Period.
因此,很多人会责备我们为什么会编写如此多不干净的代码。
So, there's enough blame to go around for why we get too much dirty code.
“难道这些学生们都没有意识到在现实的社会中编写不干净的代码是要受到惩罚的吗?”他十分惊奇地问到。
"Don't students realize there is a penalty in the real world for writing bad code?" he wondered.
一个倾听我们记录的播客的人简单地问了这样一个问题:为什么当今大学毕业生不能够编写出干净的代码(也就是,易读的、结构合理的、优雅的代码)呢?
One of the people listening to us record the podcast simply asked me why students coming out of our colleges today don't write good code (that is, readable, well-formatted, elegant code).
代码编写窍门消失不见,很多开发人员,有非常出色的、也有“平庸”的,最终合力清理干净了那堆破烂代码,但也让公司为此付出了很多时间与金钱。
A lot of very good and even "average" developers eventually cleaned up the mess, but it cost the company a lot of time and money.
把编写干净代码作为您个人过程的一部分。
我认为有以下几个造成我们编写不干净或者冗长代码的原因。
I think there are three reasons why we get dirty or sloppy code.
innerText属性提供了特殊特性,比如能够直接获得子节点的文本,这可以帮助我们编写更干净的代码。
The innerText attribute offers special features, such as the ability to get the text of the child node directly, which can help you write cleaner code.
但是dojo确实是一种很好的让人们在他们的工作中对干净代码编写技术进行思考与合并的方法。
But the dojo is a great way to get people to think about and incorporate clean coding techniques into their own work.
我们为什么会编写出一些不干净的代码呢?
测试驱动开发是有用的,但在编写测试代码的时候,还有其它一些简单的原则你必须铭记于心,你必须保证测试代码干净并且同样可测。
TDD can be useful, but there are other simple principles that you can keep in mind while writing your tests last and still reach a clean and entirely testable piece of code.
测试驱动开发是有用的,但在编写测试代码的时候,还有其它一些简单的原则你必须铭记于心,你必须保证测试代码干净并且同样可测。
TDD can be useful, but there are other simple principles that you can keep in mind while writing your tests last and still reach a clean and entirely testable piece of code.
应用推荐