Monday, March 1, 2010

'Reuse' Is Not Usable

When it comes to code sharing, many times it is either not done at all, or only in a very minimal fashion, or heavily shared but super complicated -- meaning, shared once, but no one use that after they were shared.

Is there a balance? I have been always battling between sharing the code and keeping code simple. What's the principle or guidelines to follow?

When to share? When not? Or what are not sharable?
Below is the list I come up with:
1. Interface sharing. If the interface could be defined clear enough that any one (developer) comes and understand it right away, share it. If the shared interface became layer by layer, function plus function, specialized here and there for a particular implementation, don't share it.
2. Function sharing. Surprisingly, this is the best sharing technique. It provides two main benefits: a. Scalable. b. Focused logic (any function should be implemented within one page).
... to be filled

Rule of thump
  1. Copy / paste code is never a good idea.
  2. If it turns out you spend more time and make tremendous effort to reuse some simple stuff, you probably over shared the code
  3. Refer to rules above and try writing reusable code as much as possible.
And I liked this link...

No comments:

Post a Comment