Friday, March 20, 2009

Duplication sometimes is allowed

Just a thougt that in some cases same or similar logic should be implemented in different places and this is "by design", recomended practice!
E.g. in case of validation it is recomended to implement as much validation as possibe near the input (e.g. on UI layer) but at the same time you have to duplication validation on back-end layer as well to follow defencive programming principle.
Similar principle of defend layers are used in security desing. In order to be secure system should be protected by several layers of defences (preferrably build on different technologies).

Why these thougts come to my mind? Just because sometimes developers are too concentrated on reuse for existing code and avoiding duplications in implementation. You have to realise that sometimes duplication is needed and can't be avoided.

No comments: