Don’t Repeat Yourself (DRY) Essential Developer Principles C#

The DRY (Don’t Repeat Yourself) Principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
The principle was formulated by Andy Hunt and Dave Thomas in The Pragmatic Programmer, and underlies many other well-known software development best practices and design patterns.Inorder to explain the principle in detail lets derive the following aspects

  • Duplication is waste

Every line of code that goes into an application must be maintained, and is a potential source of future bugs. Duplication needlessly bloats the codebase, resulting in more opportunities for bugs and adding accidental complexity to the system. The bloat that duplication adds to the system also makes it more difficult for developers working with the system to fully understand the entire system, or to be certain that changes made in one location do not also need to be made in other places that duplicate the logic they are working on. DRY requires that “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.”

  • Repetition in process calls for automation

Many processes in software development are repetitive and easily automated. The DRY principle applies in these contexts as well as in the source code of the application

Manual testing is slow, error-prone, and difficult to repeat, so automated test suites should be used, if possible. Integrating software can be time consuming and error-prone if done manually, so a build process should be run as frequently as possible, ideally with every check-in. Wherever painful manual processes exist that can be automated, they should be automated and standardized. The goal is to ensure there is only one way of accomplishing the task, and it is as painless as possible.

  • Repetition in logic calls for abstraction

Repetition in logic can take many forms. Copy-and-paste if-then or switch-case logic is among the easiest to detect and correct. Many design patterns have the explicit goal of reducing or eliminating duplication in logic within an application. If an object typically requires several things to happen before it can be used, this can be accomplished with an Abstract Factory or a Factory Method. If an object has many possible variations in its behavior, these behaviors can be injected using the Strategy pattern rather than large if-then structures. In fact, the formulation of design patterns themselves is an attempt to reduce the duplication of effort required to solve common problems and discuss such solutions. In addition, DRY can be applied to structures, such as database schema, resulting in normalization.

Visual Studio 2013

Announcing LightSwitch in Visual Studio 2013 Preview

The team will be rolling out detailed posts on all the new features in the coming weeks on the LightSwitch Team Blog. To recap, here are some of the biggies:

  • You no longer need to switch between Logical View and File View because all your project content is available under one view in Solution Explorer
  • LightSwitch projects work more seamlessly with the IDE, so using the scoping, search, and browse history features are all now available in your LightSwitch projects.
  • You can view multiple designers at the same time. Each screen, table, and query is now opened in its own document tab.
  • Improved team development! Each entity, screen, and query is now persisted in its own .lsml model file, dramatically reducing the likelihood of merge conflicts when multiple developers work on the same project. We’ve also improved compatibility with existing source code control providers.
  • Intrinsic database management with linked database project, providing the ability to generate reference data and make schema enhancements.
  • Improved JavaScript IntelliSense, as well as notable improvements to the core JavaScript experience such as code editor and DOM Explorer enhancements (more info here).
  • API support for refreshing data on lists and screens in the runtime app.
  • Integration with other Visual Studio features, such as Team Build and Code Analysis.

And of course there are fixes for many issues customers reported. I encourage you to test drive the VS2013 preview – LightSwitch was already a super productive development environment, and it’s gotten even better in this release!