Presentation is loading. Please wait.

Presentation is loading. Please wait.

Console and GUI Programs

Similar presentations


Presentation on theme: "Console and GUI Programs"— Presentation transcript:

1 Console and GUI Programs
Two Models for Programming This is used for C++, Java and VB. Check which one is most current. Copyright © Curt Hill

2 Paradigms Pronounced Pair-a-dime Definition: A model or example
A way of approaching a situation that affects every action that is taken Copyright © Curt Hill

3 Operating Systems A set of programs that runs the computer
Performs a number of important functions: Interprets user commands Establishes a file system Handles errors Among other things Copyright © Curt Hill

4 User commands Early operating systems used console input
These include DOS, UNIX, VMS Later operating systems adopted a GUI Graphical User Interface Pronounced “Gooey” These include Mac OS, Windows, Xwindows The two use different computing models Copyright © Curt Hill

5 Simple Example The Console and GUI program will be demonstrated using a program to compute greatest common factor Each program will receive two numbers from the user Compute GCF using Euclid’s method Copyright © Curt Hill

6 Euclid’s Method for GCF
Make the larger num1 and smaller num2 Divide num1 by num2 and keep remainder Set num1 to num2 Set num2 to remainder Repeat the division until num2 < 2 Copyright © Curt Hill

7 The Console Version This program computes the Greatest Common Factor using Euclid's method Enter the first number 323 Enter the second number 437 GCF is 19 Do you want to do another? n Copyright © Curt Hill

8 The GUI Version Copyright © Curt Hill

9 The Console Screen Usually a list of messages and inputs
When a program writes a message Appears on the bottom of the list All previous messages scroll up When input is needed the user types it at bottom No need for a pointing device, like a mouse Copyright © Curt Hill

10 The Console Paradigm The model for computing is that the program is in control It starts executing at some designated point Continues from there If it needs input, it initiates the input Prompts user and then reads The order of input is determined by program Copyright © Curt Hill

11 Form of Console Program
OS Pgm Subr Subr Subr Subr Subr Subr Service Service Copyright © Curt Hill

12 Form Again In a console program the Operating System starts the main program This program may in turn call subroutines Methods, functions, procedures These may call others Some will call OS services Such as input and output Copyright © Curt Hill

13 Other Console Comments
Interrupts are used by OS but not a factor in programs Interrupt: A response to an event whose timing is unpredictable When interrupt processing is done, whatever was running is resumed Copyright © Curt Hill

14 The GUI Screen Usually a series of Windows
Each window has certain characteristics and controls A control is an item within the window Buttons Edit boxes List boxes Copyright © Curt Hill

15 GUI History Developed at Xerox Palo Alto Research Center
Alan Kay and others They were not going to market it Jobs of Apple saw it and used for Mac Gates developed Windows because of success of Mac Xwindows was developed for UNIX independently Copyright © Curt Hill

16 WIMP The classic GUI is also known as WIMP Windows Icons Menus
Pointer (mouse or trackball) Copyright © Curt Hill

17 The GUI Paradigm The model for computing is that the operating system and user is in control The program starts It displays its windows through the operating system Then waits for the user to do something Most of the execution is in response to some user action, communicated by the OS Copyright © Curt Hill

18 A Sample Window Copyright © Curt Hill

19 Form of GUI Program OS Pgm Subr Subr Subr Subr Subr Service Service
Copyright © Curt Hill

20 Form Again In a GUI program the Operating System starts the main program Main program describes how windows are to be drawn It then returns to OS It also registers event handlers These are subroutines The events are things like a button click The subroutines may call other subroutines as well OS services Event handlers are called by OS not program Copyright © Curt Hill

21 Objects In many programming environments the controls are objects in the technical sense An object is some data and code that acts on it These objects often conform to the PME model Copyright © Curt Hill

22 The PME Model Properties Methods Events
Data that is part of the object and affects how it is used Methods Code that manipulates the object Events What to do if some user action occurs Copyright © Curt Hill

23 Properties Data that affects how the control looks or acts Examples:
The caption of a button or text of an edit box The alignment of the text The position: Left, top, width, height Some of these are modified at design time and others at run time Copyright © Curt Hill

24 Methods Actions that can be performed at run-time on the control
Usually involves a substantial amount of programming by someone else Clearing an edit box can be done by assigning an empty string to its text property or executing its Clear method Copyright © Curt Hill

25 Events When a button is clicked some action needs to be taken
An event is an action that occurs at unpredictable times, so some code handles it Examples: Mousing over a control Left click, right click or double click of a control Receiving or losing focus Typing in a control Copyright © Curt Hill

26 Languages C++, SmallTalk, Java are full object oriented languages
Full support for objects, PME, inheritance, polymorphism There are one or more full GUI development environments Visual BASIC is half of an object oriented language Has objects, most of PME No inheritance, no polymorphism Has a full GUI development environment Copyright © Curt Hill


Download ppt "Console and GUI Programs"

Similar presentations


Ads by Google