Duplicate code is a common problem on software projects.
复制代码是软件项目当中一个常见的问题。
Duplicate code can creep into a code base unbeknownst to anyone.
重复代码可能在代码库中悄然发生。
The duplicate code is, of course, the two private data members for street and city.
当然,重复的代码是表示街道和城市的两个私有数据成员。
Just after the annotations in Listing 2, can you spot two lines of duplicate code from Listing 1?
就在清单2的注释之后,您是否看到了来自清单1的两行重复的代码?
However, an appropriate goal is to ensure that duplicate code within the code base does not increase.
然而,确保代码库中的重复代码不会增多这样的目标是可以实现的。
Finding duplicate code manually can be quite challenging in all but the most obvious copy-and-paste violations.
除了最明显的复制-粘贴违规之外,在所有地方手工查找重复代码也非常具有挑战性。
Avoid duplicate code by abstracting out things that are common and placing those thing in a single location.
通过抽取公共部分放置在一个地方避免代码重复。
Duplication always implies coupling, because changing one piece of duplicate code implies changing the other.
复制就意味着耦合,因为改变一条复制的代码意味着改变另一个代码。
For example, if they see an opportunity for abstraction, they refactor to remove duplicate code from concrete implementations.
例如,如果他们看到有抽象的机会,他们就会进行重构,从具体的实现中除去重复的代码。
And just as code duplication can make a software program more difficult to maintain, so too does duplicate code in build scripts.
代码复制令软件程序更难于维护,同理,构建脚本中的复制代码也存在这样的问题。
Finding duplicate code manually is challenging, but using a plugin like CPD, however, quickly reveals duplicated code while you are coding.
靠人工来寻找重复的代码是一项挑战,但使用像CPD这样的插件却能在编码时轻松地发现重复的代码。
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.
我喜欢编写新的代码,但也喜欢采用一些现有的代码,以某种方法将其简化或将重复的代码提取到一个公共类中。
Refactoring: Refactor out any duplicate code generated in a coding session. You can do this with confidence that you didn’t break anything because you have the tests.
求精(Refactoring):去掉在编码过程中产生的任何重复代码,你可以自信地认为这么做不会破坏任何东西,因为你还有测试作为后盾。
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.
还有另一个重要的原则,在第一个案例中我们不介意有一些重复的代码,如果能够明确如何消除重复代码,我们愿意这么做,但现在还没有,我们仍然希望能找到清晰的解决方案。
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.
一旦运行了cpd,您的eclipse根目录下就会创建出一个report文件夹,其中包含一个叫做cpd. txt的文件,文件中列示了所有重复的代码。
Or you can duplicate and edit existing application code while leaving the original mixed UI and business logic in place.
或者,可以复制和编辑现有的应用程序代码,同时保留最初的UI和业务混合的情况。
At the same time, recording all test scenarios can create duplicate test code when you're testing similar scenarios.
同时,在测试与以前类似的场景时,记录所有测试场景会创建重复的测试代码。
If you are just going to render a larger image or add more information, using the JSP tags will help you avoid a lot of duplicate JSP code.
如果正打算呈现一个较大的图像或添加更多信息,那么使用JSp标记将帮助您避免许多重复的JSp代码。
A more elegant solution might be to split package structure across two source directories for client-side and server-side code and to duplicate common classes into both directories.
更好的解决方案是将包结构分解成两个源目录,一个负责客户端代码,一个负责服务器端代码,然后将公共类复制到两个目录中。
With SOAP encoding, the XML schema was generated directly from the service provider application data structures and the client code worked with a generated duplicate of those data structures.
使用SOAP编码,XML模式直接由服务提供者应用数据结构产生,客户端代码使用这些产生的数据结构副本进行工作。
CPD, which is part of the popular open source static analysis tool PMD, reports the number of duplicate lines in a code base.
CPD是流行的开源静态分析工具pmd的一部分,它报告代码基中重复行的数量。
Rather than duplicate the code that defines and manages these properties, you can create a common Account parent class that has a cash balance, and can handle credit and debit transactions.
与其重复定义和管理这些属性的代码,不如创建一个通用的帐户(account)类,该类具有现金收支平衡并且可以处理借贷事务。
Whether it is browser security protection, code library management, and even the detection of duplicate files stored in the media, hashing technology plays an important role.
无论是浏览器安全保护、代码库管理乃至检测存储介质的重复文件,散列技术都在其中发挥着重要作用。
This method lives in the Radar class for logical reasons and to not duplicate the code.
在雷达的逻辑的理由类此方法的生活,并不会重复代码。
Thus, you can present the results of the same Action in different ways and not duplicate any Action code.
这样,您可以以不同的方式显示同一个Action的结果而不用复制任何Action代码。
To order a key from a locksmith, the app produces a code that the locksmith can use to create the duplicate.
要直接向锁匠下单,应用会生成一个代码供锁匠配制钥匙。
Traditional parallelized compiler techniques use node splitting to make irreducible loops reducible, but will make code duplicate inevitably.
传统的并行编译器在处理非可规约循环时一般使用结点分割法,但由此带来的代码复制是不可避免的。
It might be that the two modules do similar things at one point, so the code in one module is effectively a duplicate of the code in the other.
俩个模块在一个方面做相似的事情,这个是很有可能的,那么这个模块的代码实际上是复制了另一个模块的代码。
If the calling code does catch the exception, the pipe consumer will still see the error, but there will not be a duplicate error.
如果调用代码捕获了异常,则管道使用者仍将看到错误,但不会有重复错误。
If the calling code does catch the exception, the pipe consumer will still see the error, but there will not be a duplicate error.
如果调用代码捕获了异常,则管道使用者仍将看到错误,但不会有重复错误。
应用推荐