Denn,
Often those who have not had experience working on large projects with a long life do not understand the concept of writing code that will last for many year over generations of technology, both hardware and software. Nor do they understand that at some time in the future the code will be changed and that tweaking the code for utmost efficiency (when it is not required) is many times at odds with clarity and robustness.
For example writing:
TPM1SC_CPWMS = 0; //set pwm for output compare
TPM1SC_CLKSA = 0; //A:B -> 0:1 == System clock
TPM1SC_CLKSB = 1;
TPM1C0SC_MS0A = 1; //MS0A:MS0B -> 1:0 == outputcompare
TPM1C0SC_MS0B = 0;
TPM1C0SC_ELS0A = 0; //ELS0A:ELS0B -> 0:0 == software compare
TPM1C0SC_ELS0B = 0;
TPM1C0SC_CH0IE = 1;
TPM1C0SC_CH0F = 0;
Instead of:
TMP1SC = 0xXX // what ever XX works out to be
The first method is much easier for someone (including yourself) to understand and modify at a later time.
In most cases, there is no shortage of flash, the code only executes once, and the clarity is much more valuable than the few bytes of flash it may save.
The same is true of your point - while that code may be OK for now, it may not always be so. It is better to err on the side of not having a bug later on that would be difficult to find.
This is programming in the small vs programming in the large. This what "Software Engineering" is vs "Programming".
While there are times when clarity must be sacrificed for speed and size, an Engineer clearly documents this and make it clear the optimizations taken and why.
It also has to do with being a one trick pony vs having to deal with many different machines and contexts over a span of time. I know I will not remember the details later on, and I personally value clarity and ease of maintenance.
Now, having said this, BOTH points of view have validity and relevance, and going to extremes either way is not good either, striking a balance is best. It is important that we all understand the two sides, and not preclude the requirements of either sides. There is always a pro and con to every method, no one way is 100% correct.
Message Edited by JimDon on
2008-03-18 11:15 AM