coding style - In C# (or any language) what is/are your favourite way of removing repetition? -
i've coded 700 line class. awful. hang head in shame. it's opposite dry british summer.
it's full of cut , paste minor tweaks here , there. makes it's prime candidate refactoring. before embark on this, i'd thought i'd ask when have lots of repetition, first refactoring opportunities for?
for record, mine using:
- generic classes , methods
- method overloading/chaining.
what yours?
i start refactoring when need to, rather first opportunity get. might of agile approach refactoring. when feel need to? when feel ugly parts of codes starting spread. think ugliness okay long contained, moment when start having urge spread, that's when need take care of business.
the techniques use refactoring should start simplest. recommand martin fowler's book. combining common code functions, removing unneeded variables, , other simple techniques gets lot of mileage. list operations, prefer using functional programming idioms. say, use internal iterators, map, filter , reduce(in python speak, there corresponding things in ruby, lisp , haskell) whenever can, makes code lot shorter , more self-contained.
Comments
Post a Comment