Professional Documents
Culture Documents
An Introduction To Object-Oriented Programming
An Introduction To Object-Oriented Programming
Programming
1
Objectives
2
What are programs? (revisited)
• A program is a step-by-step series of instructions
• Programming is the process of writing these instructions
• Programmers, or software developers, design and write
programs
• An application is a collection of one or more programs
• Program development is the process of writing
applications
3
Programming and
Application Development
• Store program
• Machine Cycle
• Fetch
• Decode
• Execute
• Stored
4
Application Types
• The Pacific Greetings Demo program from
Lecture “Introduction to VB.NET” is just an
example of a Windows Based application.
5
Application Types
• Windows Applications
6
Application Types
• Web Applications
7
Application Types
• Console Applications
8
Application Types
• Windows Services
9
Application Types
• Web Services
10
Application Types
• Components
11
The Development Cycle
12
13
Phase 1 – Analyze Requirements
• Verify the requirements are complete
• Make the initial determination that it is
possible to solve the problem using a program
• List input and output data required
• Determine whether the input data is available
for testing
14
Phase 1 – Analyze Requirements
• Ensure that the information provided explains
how to convert the input data into output data
so that a solution, or algorithm, can be
developed
15
16
Phase 2 – Design Solution
• Develop a logical model that illustrates the
sequence of steps you will take to solve the
problem
• Objects are smaller pieces of a program
• Object model
• Attributes
• Methods
17
Phase 2 – Design Solution
• Object Model
18
Phase 2 – Design Solution
• Flowcharts graphically represent the logic
used to develop an algorithm
• Control structures, included in flowcharts,
allow the programmer to specify the code that
will execute only if a condition is met
• Pseudocode expresses the step-by-step
instructions using keywords and depicts
logical groupings or structures using
indentation
19
20
Control Structures
21
Pseudocode
22
Storyboard
23
Phase 3 – Validate Design
• Validate, or check, the program design
• Step through the solution with test data
• Compare the program design with the original
requirements
24
Phase 4 – Implement Design
• Write the code that translates the design into
a program
• Create the user interface
• Create comments, or notes, within the code
that explains the purpose of the code
• Test the code as it is written
25
Phase 4 – Implement Design
26
Phase 5 – Test Solution
• Test plan
• Test cases
• Integration testing
• Boundary values
27
Phase 6 – Document Solution
• Includes the requirements documents,
program design documents, user interface
documents, and documentation of the code
• Code should be archived electronically
28
Solving the Problem Using a
Procedure-Oriented Approach
• Emphasis of a program is on how to
accomplish a task
• A flowchart uses standardized symbols to
show the steps needed to solve a problem
• Pseudocode uses English phrases to
describe the required steps
• User has little, if any, control
29
Solving the Problem Using a
Procedure-Oriented Approach
• Computer programming is about two things:
• Data and Processes that are performed on
the data
• Eg. From the Skate-Away Sales application:
• Data: all the information regarding the sale
• Processes:
• calculating and displaying the totals
• Reseting the data when the user wants to enter
new data.
30
Solving the Problem Using a
Procedure-Oriented Approach
• In procedure oriented approach:
• Data and processes are viewed as separate
• Data is stored in the text property of objects
• Procedures access that data and process it.
31
Solving the Problem Using
an Object-Oriented (OO)
Approach
• Emphasis of a program is on the objects
included in the interface and the events that
occur on those objects
• You will use a TOE (Task, Object, Event)
chart to assist you in planning your object-
oriented programs
• User has a lot of control
32
OOP Terminology
• Object
• Anything that can be seen touched, or used
• Has Attributes - also called Properties
• Characteristics that describe the object
• Has Behaviors - also called Methods
• Operations the object is capable of performing
• Class
• Pattern or blueprint used to create an object
33
OOP Terminology (continued)
• Encapsulation
• Combination of attributes and behaviors that
describe object created by class
• Abstraction
• Hiding internal details of object from user
• Inheritance
• Ability to create one class from another
• Polymorphism
• Same instruction carried out differently
depending on the object giving the instruction
34
OOP Terminology (continued)
• Program is composed of objects
• Each object encapsulates both its data and its
processes
• Objects send messages to each other to do all
the work in the program
• Data are also called properties or attributes
• Processes are also called methods or
behaviors
35
OOP Terminology (continued)
• What is an object?
• Each object is a member of a class
• The class describes the properties and methods
that each member possesses
• It describes the general pattern for every object
in the class
• Analogy: A cookie cutter
36
OOP Terminology (continued)
• Object
• A specific entity that follows the pattern of the
rest of the class
• Analogy: A cookie (from the cookie cutter)
37
OOP Terminology (continued)
• Classes and objects in the real world
• Class: Car
• Every car has “properties” (# of doors, engine
size, color)
• Every car has “methods” (drive, stop, turn on,
turn-off)
• Object: My car
• My car has 4 doors, a 1.6L engine, and is white
• My car can drive, stop, turn on, and turn off
38
Thought problem #1:
Consider students in this class. What are
some properties and methods of students?
What’s an example of a student object?
39
OOP (continued)
• You know a lot of OOP already!
• It may seem scary to have all this “new” stuff
thrown at you, but you’re more familiar with
OOP than you think just from using VB.NET
40
OOP (continued)
• For example: in the Skate-Away application:
• txtName object is derived from TextBox
Class.
• This is clearly illustrated in the properties
window.
41
OOP (continued)
• And in the forms .Designer.vb file.
42
OOP (continued)
• Note that every member of the textbox class has the
same set of properties, but that textbox object has
different values for those properties
• The Properties window gives you a listing of property
values for each object
• Example:
Name: txtFoo Name: txtBar
Text: “Hi Mom” Text: “I love USP”
Visible: True Visible: False
44
Illustration of OOP Terms
45
Summary
• Describe programs, programming,
applications, and program development
• Identify each of the phases in the
development cycle
• Define an algorithm
• Object Oriented Programming includes:
• Objects – things with attributes and behaviors
• Attributes are the characteristics of an object
• Behaviors are actions that an object performs
46