When you are in times where you need two locations for something, make certain the system fails noisally and noticeably when they’re not “in sync.” Compilation should fail, an evaluation have a tendency to will get run should fail, etc. Software development company ought to be impossible to allow them get free from sync.
Not to mention, the easiest thing about this rule may be the classic “Don’t Repeat Yourself” principle-do not have two constants that represent exactly the same factor, do not have two functions which do exactly the same factor, etc.
You will find likely different ways this rule is applicable. The overall idea is the fact that when you wish to possess two implementations of merely one concept, you need to in some way make that right into a single implementation rather.
When refactoring, this rule helps find things that may be enhanced and provides some assistance with how to pull off it. If you notice duplicate logic within the system, make an attempt to mix individuals two locations into one. Then if there’s another location, combine that certain in to the new generic system, and proceed for the reason that manner. That’s, if there are various implementations that should be combined into one, that you can do incremental refactoring by mixing two implementations at any given time, as lengthy as mixing them does really result in the system simpler (simpler to know and keep). Sometimes you need to determine the very best order to combine these to get this to most effective, however if you simply can’t figure that out, take it easy about this-just combine two at any given time in most cases you’ll find yourself having a single good means to fix all of the problems.
Software development company is also important to not combine things once they shouldn’t be combined. You will find occasions when mixing two implementations into you might cause more complexity for that system in general or violate the only Responsibility Principle. For instance, in case your system’s representation of the Vehicle along with a Person possess some slightly similar code, don’t solve this “problem” by mixing them right into a single CarPerson class. It is not prone to decrease complexity, just because a CarPerson is really two various things and really should be symbolized by two separate classes.
This isn’t a solid law from the world-it’s a far more of the strong guideline which i use to make choice about design when i develop incrementally. However, it’s quite helpful in refactoring a legacy system, creating a new system, and merely generally enhancing code simplicity.