what is event driving programming and its features

Discussion in 'Mac Programming' started by dudeofblokes, Nov 13, 2012.

  1. macrumors regular

    Joined:
    Nov 3, 2007
    Location:
    carrickfergus, northern ireland, united kingdom
    #1
    as someone new to this area im wondering if someone can explain to me in the simplest way what event driven programming is?

    and what its key features are?

    i have tried searching the web and the like of wikipedia etc offer no help, your replies are appreciated
     
  2. macrumors regular

    Joined:
    Aug 21, 2011
    Location:
    Stockholm Sweden
    #2
  3. macrumors 603

    notjustjay

    Joined:
    Sep 19, 2003
    Location:
    Canada, eh?
    #3
    Classic programming is like checking a mailbox for your iPad mini package delivery. Is it here yet? Go outside and check for the box. No box? Then go back inside, do something else for a while, go outside later and check again. You spend a lot of time wondering "Is it here yet? Is it time to go check?" You check your watch often because you don't want the package to be sitting out there too long (it could get stolen!) Do you check the door every hour? Every 10 minutes?

    In programming terms this is calling polling.

    Event driven programming is like having a doorbell. You don't have to "do" anything. Take a nap on the couch. When your iPad mini arrives, the delivery guy will ring the doorbell, and you'll know it's time to get your package. You don't waste time checking the door needlessly or timing yourself.

    It can be a little weird to get used to event-driven programming when coming from a "classical" programming background because you are used to writing the code that is actively in control of the computer. What will it do next? Then what? You're not used to code that "does nothing".

    With event-driven programming, you throw your program into some kind of "main application loop" that might do absolutely nothing other than sit there and wait for events to happen (kind of like taking a nap on the couch). Then you just worry about the code that will run when something happens.
     
  4. thread starter macrumors regular

    Joined:
    Nov 3, 2007
    Location:
    carrickfergus, northern ireland, united kingdom
    #4
    thank you guys for your help
     

Share This Page