written by owen on 2012-Jul-24.
I see the â€œre-inventing the wheelâ€ talk gets thrown around alot. And it is usually by people who have either forgot or do not know the benefit of doing a total re-write of something that they have probably spend years tediously writing and testing.
There are times when you write something like this;
item_top = ( menu_top+menu_margin+menu_item_margin+(menu_item_height*(i-menu_option_start)) )-item_shift;
That piece of code positions an option in a menu dynamically as the menu is drawn on the screen. The code works but it is full of potential problems, edge cases and ways it can be improved. What if the user wants thier menus to slide in from the left or the right? It just would not work! No matter how you look at it I will have to hack out lots of that code to get a feature like that implemented. There is no way around it.
I may not want to improve/change the menu now because I do not know a better way it can be optimized and sliding menus are not really important to users at the present moment. That code provides a specific and complicated function - it is what I often refer to as â€œpure codeâ€. 50 years from now that code will still work. There are no API calls or libraries or classes being swapped around, no underlying framework with a billion lines of hidden code - it is nothing but solid, bueatiful, simple math. Not to mention one of the worst things you can do in programming is over optimize.
Anyway the point will come and often times when making a better wheel works out to more that just adding fancy effects, not always, but it is certain that the time will come when a re-write is necessary.
On the flip side most "apps" are nothing more than a sequence of API calls with a different GUI - it really doesnâ€™t need to change until a new API gets released and there is no real room for improvement by "re-writing" it, since its performance is less about the code quality and more about the APIs and the platform. You could reduce the amount of APIs you call or probably call some different functions but in most cases you are probably already copy-pasting the best practices so there is no reason for you to touch that code again. The code is solid as a rock - until the next version.
Say for instance you write a â€œhello worldâ€ in Java 1.0 - there is NOTHING you can do to improve it - NOTHING. Because there is really not much "code" in it. You could probably decide to change the words to French â€œbonjour tout le mondeâ€ or change the UI colour but there would be no real option to "re-invent of the wheel". You cannot re-invent a wheel if you have no "wheel". You need a wheel if you want to re-invent something. Often times the difference between one application and the another is the user interface. In the back end itâ€™s all the same API calls and libraries.
It all comes down to how much code you have and how many choices you have. Only thing you can possibly do is wait until Java 1.1 to come out with new compiler improvements which will make the program run faster and added API calls which include stuff which they either forgot to include or purposely delayed (because of milestones and such).
A perfect example is Apple. Apple mac OS has one of the most rigid APIs in the consumer computing world. Apple owns the development environment, the operating system, the programming language and the best software on the platform. It is almost impossible to develop an application that is better than an application that is written by Apple itself. This is because they own and diligently monitor the â€œwheelâ€. Its not a question of not wanting to re-invent it - you simply CANNOT. And even if you have a wheel of your own, THEIR wheel is chromed 24 inch LED spinners. And even if by some luck or dedicated hard work you manage to create something new and innovative Apple will eat it up and leave cold and dry without even a second look. It is destined to happen, you are even instructed to re-test you application and upgrade to a new compiler to take advantage of the 3000 â€œnewâ€ API calls.
So in conclusion, spending hours or even months writing your own custom stuff is a luxury and not always just about "re-inventing the wheel". There are times when you can no longer hack/patch your way out of the hole. You sandbox is your sandbox.