Preview

Sequential vs. Event-Driven Programming

Powerful Essays
Open Document
Open Document
1859 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Sequential vs. Event-Driven Programming
Sequential vs. Event-driven Programming
Reacting to the user

Outline
Sequential programming GUI program organization Event-driven programming Modes

Sequential Programming
In sequential programs, the program is under control The user must synchronize with the program:
Program tells user it is ready for input User enters input and it is processed

Examples:
Command-line prompts (DOS, UNIX) LISP interpreters

Shouldn’t the program be required to synchronize with the user?

Sequential Programming (2)
Flow of a typical sequential program
Prompt the user Read input from the keyboard Parse the input (determine user action) Evaluate the result Generate output Repeat

Example
DemoTranslateEnglishConsole.java

Prompt the user User input Output results

Sequential Programming (3)
Advantages
Architecture is iterative (one step at a time) Easy to model (flowcharts, state machines) Easy to build

Limitations
Can’t implement complex interactions Only a small number of features possible Interaction must proceed according to a pre-defined sequence

To the rescue… Event-driven programming But first…

Outline
Sequential programming GUI program organization Event-driven programming Modes

GUI Program Organization
Let’s digress briefly to examine the organization of our GUI programs We’ll do this in stages, by examining three example programs
DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.java

Outline
Sequential programming GUI program organization Event-driven programming Modes

Event-driven Programming
Instead of the user synchronizing with the program, the program synchronizes with, or reacts to, the user All communication from user to computer occurs via events and the code that handles the events An event is an action that happens in the system A mouse button pressed or released A keyboard key is hit A window is moved, resized, closed, etc.

Classes of Events
Typically, two different classes of events
User-initiated

You May Also Find These Documents Helpful

  • Satisfactory Essays

    IF You Want To Purchase A+ Work Then Click The Link Below , Instant Download…

    • 503 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    This agent is already implemented in the GekoProAg project. For the prototype implementation, a simple agent which has one behaviour is created. The class diagram of this package can be seen below in Figure 19.…

    • 464 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    ElizabethFlaimFP

    • 1289 Words
    • 7 Pages

    Objective: Devise a program that will allow a user to input a list of family members with their age and state where they live. Once the list is complete, the program will calculate and print the average age of the user’s family and also print the names of any family members that live in Texas. All three items, the input, average, and printing family members from Texas will require the use of repetitive programming statements/loops.…

    • 1289 Words
    • 7 Pages
    Good Essays
  • Satisfactory Essays

    Pt1420 Unit 7 Study Guide

    • 582 Words
    • 3 Pages

    17.Write a program to read a binary input from the keyboard and display it. Page: 130…

    • 582 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Pt1420 week 2

    • 320 Words
    • 3 Pages

    1. Design an algorithm that prompts the user to enter his or her height and stores the user’s input in a variable named height.…

    • 320 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Nt1310 Unit 3 Assignment

    • 256 Words
    • 2 Pages

    Write a program to read the name of 5 students through keyboard and store them in a file “name.txt”.…

    • 256 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    IT/210 Appendix D

    • 453 Words
    • 4 Pages

    Up to this point, you have identified the processes the program must perform, but you have not given any consideration to exactly how the processes work together to solve the problem. At this point, you must generate a description of the processing using pseudocode, a natural language description of the processing the application must perform.…

    • 453 Words
    • 4 Pages
    Powerful Essays
  • Satisfactory Essays

    It210 Appendix F

    • 372 Words
    • 3 Pages

    1. The program will present a series of user screens that prompts the user for specified input.…

    • 372 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    1. Design an algorithm that prompts the user to enter his or her height and stores the user’s input in a variable named height.…

    • 848 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    You need to identify the events (inputs) that each of these applications would receive and say how suitable an event driven language might be to handle those events.…

    • 532 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    unit 3

    • 313 Words
    • 2 Pages

    Design a program that calculates the total amount of meal purchased at a restaurant. The program should ask the user to enter the charge for the food, and then calculate the amount of a 15% tip and 7% sales tax. Display each of these amounts and the total.…

    • 313 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    You can even create interactive programs that allow the user to input values for variables…

    • 5177 Words
    • 21 Pages
    Good Essays
  • Powerful Essays

    what ever

    • 1175 Words
    • 5 Pages

    Be sure your output file contains user prompts and what was entered by the user .in addition to the results of your program processing. Run with above listed data. The instructor will give you additional data to test.…

    • 1175 Words
    • 5 Pages
    Powerful Essays
  • Good Essays

    Event Driven Programming

    • 5596 Words
    • 23 Pages

    1.1 Key features: service oriented; time driven; event handlers; trigger functions; events e.g. mouse, keyboard, HTML object, form, user interface; event loops; flexibility; suitability for graphical interfaces; simplicity of programming; ease of development. Examples: operating systems as event driven systems; Graphical User Interfaces (GUIs). Programming languages: e.g. Visual Basic (VB), Visual Basic for Applications (VBA), Coldfusion; Integrated Development Environments (IDEs).…

    • 5596 Words
    • 23 Pages
    Good Essays
  • Good Essays

    Intro to programming

    • 534 Words
    • 3 Pages

    Design an algorithm that prompts the user to enter his or her height and stores the user’s input in a variable named height.…

    • 534 Words
    • 3 Pages
    Good Essays

Related Topics