Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/03/06 14:49
Read: times


 
#121615 - small and readable
Responding to: ???'s previous message
Matthew Barlage said:
I am very interested in seeing how people on this forum go about optimizing their code. I am usual happy that my functions give me the result I want, and take the "If it ain't broke don't fix it" approach.



My approach:

try to hold the code small, clean, readable and maintenable.

E.g. whenever I detect similiar pieces of code, I try to write a subroutine for it, which was called with different parameters.

Or if the same expression was needed on different places, you can try to calculate it once and store the result to use it later.

In general I try to avoid copy&paste sequences.
Because on later changing of something you forget to change at least one of the pasted pieces (murphys law).


There is no code which need no maintenance, exept only such code which was never used.


Further optimization can be done on considering, how often a certain task was needed. Then a task can be delayed by a timer to use CPU time for other tasks.
Often it can be seen, that the CPU was fully blocked by unimportant tasks.


On most cases, if you try to hold code small, then it need also less code space, was executed faster and contain less errors.


Peter


List of 33 messages in thread
TopicAuthorDate
code optimisation            01/01/70 00:00      
   Optimisations            01/01/70 00:00      
   problem solved            01/01/70 00:00      
      good closure!            01/01/70 00:00      
         and the very best ...            01/01/70 00:00      
            Isn't that why we have "tools"?            01/01/70 00:00      
               not quite and a good read            01/01/70 00:00      
               A Posidriv driver and a Phillips screw            01/01/70 00:00      
                  I have done this too, I think you are wrong            01/01/70 00:00      
                     Best Ways?            01/01/70 00:00      
                        what is best?            01/01/70 00:00      
                           Guide lines and trade-off\'s            01/01/70 00:00      
                              what about 'and'            01/01/70 00:00      
                                 Dangerous Information            01/01/70 00:00      
                                    depends on what you define as overhead            01/01/70 00:00      
                                       Overhead            01/01/70 00:00      
                                          the whole truth, please            01/01/70 00:00      
                                             one good thing...            01/01/70 00:00      
                                             CPU Overhead            01/01/70 00:00      
                                                there is an article 'somewhere' that cover C for            01/01/70 00:00      
                                                   the real optimum            01/01/70 00:00      
                                                      Your time is appreciated            01/01/70 00:00      
                                                   how about these?            01/01/70 00:00      
                                                      a required capability for optimum code            01/01/70 00:00      
                        small and readable            01/01/70 00:00      
                           my sentiment            01/01/70 00:00      
                              In that spirit ... where's the user guide?            01/01/70 00:00      
                                 Did you download the documentation            01/01/70 00:00      
                                    have a look            01/01/70 00:00      
                                       Non-GPL            01/01/70 00:00      
                                       I'll have a look!            01/01/70 00:00      
                                    It's not quite as the page suggests            01/01/70 00:00      
                        Lint            01/01/70 00:00      

Back to Subject List