The trend in software development has always been to reuse as much existing code as possible. One manifestation of this is object oriented programming and classes that are shared between a lot of components.
It is undeniable that reusing code saves code. You need to write less of it.
However, it is not certain that it means that you save time.
If you have a large software project and a lot of other classes depend on each class, then a bug in any shared class means that the whole project may come to a standstill, until the bug is fixed.
If you instead duplicate code, and each class has complete control of its own content, you limit the risk of generic project failures.
So duplicating code is better than reusing it? Ehm... sometimes. Look at your project and use your judgement.
No comments:
Post a Comment