C: Global Variables versus Parameters

Moderator
Posts: 3,554
Joined: 2003.06
Post: #9
NelsonMandella Wrote:C programs can become very complex and difficult to manage once they reach anywhere from approximately 10k to 20k lines of code. Modular code helps to mitigate this complexity, but it can also add complexity to what would be a short, simple program.

Yeah, that's pretty well put.

The best way to learn when and how to use globals is experience. For small programs, like say less than 10k lines of code, accessors are probably just getting in the way of getting the program done. Larger than that and using techniques for modularity (and debugging as DoG and Skorche pointed out) definitely start coming into play.

I will add this: As you are learning, I wouldn't worry toooo much about whether you're using globals or not, or how you specifically use them. As you start to become familiar with the language it does become more obvious what globals and parameters are really useful for.
Quote this message in a reply
Post Reply 


Messages In This Thread
C: Global Variables versus Parameters - DoG - Jan 13, 2010, 05:03 AM
C: Global Variables versus Parameters - AnotherJake - Jan 13, 2010 11:41 AM
Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Accessing an inherited class's variables Tobs_ 22 8,395 Feb 28, 2007 05:26 PM
Last Post: mac_girl
  Problems with variables in Obj-C vnvrymdreglage 16 5,942 Oct 2, 2006 10:19 PM
Last Post: vnvrymdreglage
  Should global variables be pointers or full objects? ia3n_g 1 2,067 Aug 4, 2006 05:53 PM
Last Post: OneSadCookie
  where do global variables fall into the memory type? WhatMeWorry 3 2,525 Jun 5, 2006 02:45 PM
Last Post: OneSadCookie
  Arrays or variables containing executable functions Jones 4 3,752 Jun 2, 2006 08:35 AM
Last Post: Zekaric