Skip to content

Instantly share code, notes, and snippets.

@togakangaroo
Created January 23, 2012 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save togakangaroo/1664107 to your computer and use it in GitHub Desktop.
Save togakangaroo/1664107 to your computer and use it in GitHub Desktop.
Methods of Removing Redundant Code

Common methods of removing redundant code scored by

  • Ease of Implementation (lower is more difficult)
  • Dont Repeat Yourself (lower involves more repetition and therefore more prone to bugs)
  • Loose Coupling (lower involves higher degrees of coupling and therefore more prone to bugs)
Ease DRY Loose Coupling Refactoring Method
5 1 5 Copy paste
4 4 2 Extract static method
3 4 2 Extract extension method
3 4 3 Extract base class
-5 5 4 Aspects*
4 4 2 Extract public method
4 4 3 Extract private method
3 4 4 Extract method with lambdas as parameters
3 3 3 Extract service/helper class (locally newing up instance)
2 3 4 Extract service/helper class (injecting dependencies)
? ? ? Precompiler macros
? ? ? LISP-style macros
? ? ? Mixins **
? ? ? Extend
? ? ? Dynamic metaprogramming

* Ease of Aspects greatly depends on your language and development toolstack. This chart assumes a standard C# stack not using any particular aspect framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment