Unit 5 CSP Flashcards
Event-driven programs
written to respond to specified events by executing a block of code or function
Will everything in an event driving program always execute?
No!
Some portions of the code will never execute
Can the order of an event driven program be known ahead of time?
No
Because it relies on an event to happen. Each time depending on the user something new can happen
Do even driven programs implement algorithms?
Yes
Element IDs
- IDs should be meaningful and descriptive
- allow a programmer to reference interface elements within their code
What must any element that is triggered by onEvent have?
unique ID
Can two or more onEvent calls reference the same ID?
Yes
Does an element ID always need an unique event handler associated with it?
No
What are two actions a programmer could take when debugging code?
- display the value of variables at various points during the program
- ask a friend or collaborator to look over the code segment to see if they are able to find any errors
Global variable
Defined outside of a function and can be used anywhere in code
Local variable
Defined inside of a function and can only be used in that function