You'll often here these terms in your programming life
- reuse is better
- code is made to be reused
- don't reuse other's code
- reuse of code breaks things
The above arguments each of them stand true in different scenarios. And this is the part most programmers miss. They hear one fact and applies it to all known problems in their life.
There are two perspectives here -
First, code shouldn't be reused at every instance, even if there is a more-effective solution present. The thing to understand is, if you need to built something that is core-business, then that should be a altogether new code. Let's take example of online travel booking websites. They should have their own code written for searching the flights and booking (along with needed code to interact with bank, a notification code to the end-user). The thing they should re-use is already existing accounting solution for maintaining their books.
Another, is re-use of module/library -
Let's say for instance you are using a external library, then there's always a risk if it's behavior changes in future. You don't have control over things. And you need workarounds in your code in case things go wrong. A good interesting read can be found here where someone suggested to use C++ for writing parts of GIT(the version control tool), and Linus Torvald gave a huge refusal to not. The debate their goes more on C-C++, but few things he said boils down to not reuse the code for manipulating string from a external library, as that was a core part of GIT. [Got to know of this from the HN thread]
No comments:
Post a Comment