|Nov 13, 2012, 04:44 AM||#1|
what is event driving programming and its features
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
MAC THE PLANET
last gen 13" retina MacBook pro, iPhone 5 64gb, iPad mini retina
|Nov 13, 2012, 11:52 AM||#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.