工厂需要大量冗长重复的代码。
使用“寻找匹配副本”功能,我们能够找到重复的代码。
对于所有重复的代码,一定会出现不一致性,因此将很难进行维护。
With all that repeated code, you're bound to have inconsistencies, and it will be hard to maintain.
每一块重复的代码都使得程序逻辑中出现错误的几率增加。
Each block of repeated code increases the chances of introducing an error into the logic.
想一想那些重复的代码,你需要重新设计你的整个类层次。
Think about all of the duplicated code you'd now have spread throughout your entire class hierarchy.
就在清单2的注释之后,您是否看到了来自清单1的两行重复的代码?
Just after the annotations in Listing 2, can you spot two lines of duplicate code from Listing 1?
在这样的情况下,它将只指示出那些至少有10行类似或重复的代码块。
In this case, it will only indicate blocks of code that have at least 10 lines that are similar or have been duplicated.
在person类中有一些重复的代码,但我把它留给稍后的重构练习。
There's a bit of code duplication in the Person class, but I'll leave that for a later refactoring exercise.
我觉得我的编程逻辑是错误的但我不知道如何解决它没有丑陋的大量重复的代码。
I feel like my logic in the programming is wrong but I am not sure how to fix it without lots of ugly repetitive code.
然后,不需要考虑代码将要完成的任务是什么,而只需要坚定地移除这些重复的代码。
Then, without really thinking about what it is you're trying to achieve, just pigheadedly try to remove that duplication.
例如,如果他们看到有抽象的机会,他们就会进行重构,从具体的实现中除去重复的代码。
For example, if they see an opportunity for abstraction, they refactor to remove duplicate code from concrete implementations.
有时候,使用这种语句比嵌套的for循环或if语句更好,可以减少重复的代码而且结构更清楚。
Using such a statement can sometimes be a better route than nested for loops or if statements to cut down on repetitive code or just for better structure.
在我们的示例中,不需要suffix . py脚本,因为脚本结尾处重复的代码行并不多。
Is not necessary, because we don't repeat a lot of lines at the end of the scripts. But we do have to specify which page we will be loaded next?
正如书中所指出,为了设置定时器和确定动画的当前进度,需要编写大量必不可少却又一再重复的代码。
As the book illustrates, there is a lot of boiler-plate code required in order to setup timers and determine the current progress of the animation.
靠人工来寻找重复的代码是一项挑战,但使用像CPD这样的插件却能在编码时轻松地发现重复的代码。
Finding duplicate code manually is challenging, but using a plugin like CPD, however, quickly reveals duplicated code while you are coding.
Eclipse的PMD插件提供了一项叫做CPD(或复制粘贴探测器)的功能,用于寻找重复的代码。
The PMD plugin for Eclipse provides a feature called CPD (or Copy Paste Detector), which finds duplicated code.
随着时间的推移,你会看到多个代码片段和应用功能中存在的模式和重复的代码,这对起到增效作用很有帮助。
Over time you will start to see patterns and duplication across code fragments and application functionality which will help achieve synergies.
我喜欢编写新的代码,但也喜欢采用一些现有的代码,以某种方法将其简化或将重复的代码提取到一个公共类中。
I'd rather write new code, but I enjoy taking some existing code and reducing complexity in a method or extracting duplicate code into a common class.
考虑一下只有自动化或者紧密控制的流程,才能给您带来可重复的代码;人类并不擅长记住启动或者终止计时器。
Consider that only automated or tightly controlled processes can give you repeatable metrics; humans aren't good at remembering to stop and start stopwatches.
原系统存在的缺陷主要包括功能重复的代码和不合理的设计,这些问题在大型J2EE系统尤其是BOSS系统中普遍存在。
The main faults of the original system contain duplicated codes and defective design, and these are common for J2EE system especially BOSS.
为了消除这些重复的代码,许多测试框架提供了一次性指定每个测试都需要运行的setup和teardown 代码的机制。
To eliminate repetitious code like this, many testing frameworks provide a way to indicate once what setup and teardown code needs to run for each of entire groups of tests.
添加ViewComponentParam属性,它可以告知MonoRail把参数作为属性绑定到你的视图组件上——减少了重复的代码规则。
Added ViewComponentParam attribute which tells MonoRail to bind the arguments as properties on your view component - reducing repetitive code rules.
正如我在命令式版本中所做的一样,我将重复的代码提取到其factors类中,并且为便于阅读,将factors方法的名称改为of,如清单8所示。
Just as I did with the imperative versions, I extract the duplicated code into its own factors class, changing the name of the factors method to of for readability, as shown in Listing 8.
一旦运行了cpd,您的eclipse根目录下就会创建出一个report文件夹,其中包含一个叫做cpd. txt的文件,文件中列示了所有重复的代码。
Once you've run CPD, a report folder is created in your Eclipse root directory containing a file called cpd.txt, which lists all duplicate code. An example of the cpd.txt file is shown in Figure 9.
还有另一个重要的原则,在第一个案例中我们不介意有一些重复的代码,如果能够明确如何消除重复代码,我们愿意这么做,但现在还没有,我们仍然希望能找到清晰的解决方案。
Another important principle is that in the first case we don't mind having some duplicate code. If it's clear how to eliminate duplication, we do, but we are willing to wait for clarity.
这不仅使您避免了一遍又一遍的重复编写相同的代码,也使您的应用程序更易于维护。
Not only does this save you from repeating the same code over and over, but it also makes your application much easier to maintain.
测试以更明确的方式表述这种理解,并以可靠和重复执行的代码加以表示。
Tests express that understanding in a much less ambiguous form, as code that executes reliably and repeatedly.
然而,确保代码库中的重复代码不会增多这样的目标是可以实现的。
However, an appropriate goal is to ensure that duplicate code within the code base does not increase.
可以通过调用这个标记在多个位置使用自定义标记,无需在不同的地方重复编写相同的代码。
You can use a custom tag on multiple places simply by invoking the tag, and remove the repetition of writing the same piece of code in different places.
从理论上来说,可以看到利用代码生成技术可以迅速、准确地生成大量重复性的代码。
On the theoretical side, you can see that code-generation techniques are capable of quickly building a large volume of repetitive code accurately.
应用推荐