1 cs 106, winter 2009 class 4, section 4 slides by: dr. cynthia a. brown,...

Post on 19-Dec-2015

223 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

CS 106, Winter 2009Class 4, Section 4

Slides by: Dr. Cynthia A. Brown, cbrown@cs.pdx.eduInstructor section 4: Dr. Herbert G. Mayer, herb@cs.pdx.edu

2

Analysis -> Design

• Determining what a process should do is called analysis or requirements gathering.

• We begin by describing the interface (perhaps with a picture), and writing our use cases and tests

• We determine what our objects and events are, and what internal state the process needs to keep track of.

• At that point we are ready to design our process using flowcharts.

3

Flowchart process

• Start with a list of objects and their events, along with the internal state you need to keep track of. Be flexible… you may discover the need for more events or state variables as you design the process

• Make a flowchart for each event• Using the flowcharts, walk through the use

case tests and make sure everything works properly

4

Flowchart Symbols

Flowline: Connects symbols and indicates the flow of logic.

Input/Output: Data to be read or displayed are described inside.

Terminal: Represents the beginning or end of a task.

Processing: The process description is includedinside the symbol.

Decision: Used for logic/comparison operations. Hasone entry and two exits.

5

One more…

Continuation

6

Money Input Slot: Version 2 User Inserts Coin

end

Nickel?

MonEnt<- MonEnt + .05 Dime?

MonEnt<- MonEnt + .10 Quarter?

MonEnt<- MonEnt + .25

yes no

yes

end

no

yes

end

no

Return coin

end

7

Selection Button AEvent Flowchart

8

Your Assignment

• For the parking meter, list the objects and their events, and create variables for the internal state.

• Choose 4 non-trivial events, and create flowcharts for them.

• Due next Thursday, Oct. 16.

9

The Next Step

• First we gather requirements and organize them in use cases, with tests. This is the look and see phase.

• Then we design a process that will do what the requirements specify. This is the imagine step.

• Finally we implement our design in a program, machine, manual, etc. This is the show step.

• We can then test it to see if we have accurately implemented the requirements.

10

Specification -> Implementation

• We will learn how to implement a process on a computer, using Visual Basic

• The great thing about this is that we can play with it and test it to make sure it meets our specifications and passes all our tests

• Implementing a process for the computer also forces us to be extremely clear and thorough

11

A Little About Computers

• A computer consists of hardware: the physical machine.

• The hardware is not useful until we install software: the programs that make the computer do what we want.

12

CPU (where processing takes place) can:· compare 2 numbers· add/subtract/mult./divide 2 numbers· copy/load number from memory to CPU· store a number from CPU to memory· …

Central Processing Unit (CPU)

MemoryMemory (simply):Holds numbers/text/music/pictures/video,all in digital form.

Input/Output/Storage devices:Hold numbers/text/music/pictures/videoDisplay numbers/text/music/pictures/videoAllow numbers/text/music/pictures/video to be input

Data must move fromexternal storage (e.g., disks) into memory.

The CPU can’t see the datauntil it is inside the CPU.

A Simplified View of Hardware

13

Software: Operating System

• The most basic software on your computer is the operating system

• Common operating systems are Windows (various flavors), Linux (again available in many versions), and Mac OS (ditto).

• Windows and Mac OS are proprietary.• Linux is open source, and some versions are

free.

14

Operating System

• The operating system runs your computer and orchestrates the rest of the software

• It makes sure, for example, that the information that a key has been pressed gets sent to the right piece of software

• It makes sure that information gets sent to and retrieved from external devices as needed

• It keeps all the windows organized• It controls access to your files

15

Application Programs

• An application is a program you use to complete some task

• Examples include web browsers, word processors, games

• Using an application makes you a software user

16

Software Developer

• All the programs that run on your computer, including the operating system and the application programs, were written by someone (often by a big team of people) called software developers

• They were written using a programming language such as Visual Basic (other examples include Java, Perl, C++)

17

Computer Programs

• Programs contain instructions for the computer that tell it how to perform some process

• Actual computer instructions at the hardware level are digital like everything else, and stored in memory just like data. In fact the ability to store a program distinguishes a computer from other sophisticated machines

18

Writing a Program

• Programmers usually write in “high level” languages

• You write using an editor and other tools, possibly a programming environment. Just as with a word processor, which helps you write documents, the programming environment helps you write programs

19

A Program is a Special Kind of Document

• A program is a document (or set of documents) that contains instructions for the computer

• Running a program makes the computer do something

• There are two ways to run a program: interpreted and compiled

20

Compiled Programs

• A compiler translates a program into a form that the operating system can run on a computer.

• Once a program is compiled, it is independent of the source code and the development environment

• On Windows, .exe files are compiled programs

21

Interpreted Programs

• When an application program is interpreted, an interpreter (which is also a program) reads the application program line by line and interacts with the operating system to run the program

• The interpreter uses the source code• In the development environment, using the

interpreter lets us look at what the program is doing internally while it is running

22

VB Can Do Both

• Interpretation is great while we are developing the program since it lets us examine what is going on

• After the program is finished, we can compile it to get something that runs faster and is independent of the source code and the development environment

23

VB Projects

• A VB project is more than just a single file of code

• VB has many great features that assist us in easily creating nice user interfaces that interact well with the Windows environment

• It automatically creates components that the operating system will need to run the program properly

24

Controls

• Controls are what VB calls the objects that can appear in the user interface

• Chapter 2.2 has a nice tutorial on the most common controls– Text box– Button– Label– List box

• We’ll walk through an intro to these after the break

25

BREAK

10 min

26

DEMONSTRATION

Getting started with Visual Basic

top related