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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/15/04 21:25
Read: times


 
#81226 - poor practice
Responding to: ???'s previous message
shahzad said:
i usually declare temporary variables at the top of the program and use them when i need to do some local processing in a function. so instrad of declaring variables every where in function i delcare it at the top.

This is a really bad idea!

  • It defeats the object of using a block-structured language like 'C';

  • It uses more RAM, because globals are allocated permanent storage, while automatic locals aren't;

  • You risk accidentally re-using a global;

  • Having definitions all in one glob, far removed from the context that uses them, is far less readable

  • etc, etc, etc...

    shahzad said:
    i make sure that variable is not being used twise

    That is a waste of effort and, because it's a laborious manual process, it is error-prone. If you made them local, there would be no risk of using them twice!

    shahzad said:
    this is my programming practice i'm sure many people will not like this.

    It doesn't really matter whether people like it or not (I certainly don't). What matters is whether it produces reliable, maintainable, efficient code.

    I rest my case, m'lud.

  • List of 19 messages in thread
    TopicAuthorDate
    Strange problem with KEIL C++ and 8052            01/01/70 00:00      
       Wait a minute...            01/01/70 00:00      
       Your code            01/01/70 00:00      
       RE: Strange problem with KEIL C++ and 8052            01/01/70 00:00      
          RE: Strange problem with KEIL C++ and 8052            01/01/70 00:00      
             RE: Strange problem with KEIL C++ and 8052            01/01/70 00:00      
                poor practice            01/01/70 00:00      
       andy + gopalakrishn + program with <pre>            01/01/70 00:00      
          RE: andy + gopalakrishn + program with <pre>            01/01/70 00:00      
             RE: andy + gopalakrishn + program with <pre>            01/01/70 00:00      
       RE: Strange problem with KEIL C++ and 8052            01/01/70 00:00      
       KEIL Debugger            01/01/70 00:00      
          RE: KEIL Debugger            01/01/70 00:00      
          RE: KEIL Debugger            01/01/70 00:00      
       try this on your keil            01/01/70 00:00      
       Keil Debugger screen shoots            01/01/70 00:00      
          Shazad            01/01/70 00:00      
          RE: Keil Debugger screen shoots            01/01/70 00:00      
       I am facing Nearly Similar Problem            01/01/70 00:00      

    Back to Subject List