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.
除了最明显的复制-粘贴违规之外,在所有地方手工查找重复代码也非常具有挑战性。
For example, if they see an opportunity for abstraction, they refactor to remove duplicate code from concrete implementations.
例如,如果他们看到有抽象的机会,他们就会进行重构,从具体的实现中除去重复的代码。
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.
复制就意味着耦合,因为改变一条复制的代码意味着改变另一个代码。
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.
还有另一个重要的原则,在第一个案例中我们不介意有一些重复的代码,如果能够明确如何消除重复代码,我们愿意这么做,但现在还没有,我们仍然希望能找到清晰的解决方案。
Duplicate code is a common problem on software projects.
复制代码是软件项目当中一个常见的问题。
Duplicate code is a common problem on software projects.
复制代码是软件项目当中一个常见的问题。
应用推荐