After studying this chapter, you should be able to Understand problemsolving concepts, formulate algorithms using pseudocode, realize the complexity writing algorithms, understand an eventdriven environment, describe how classes and objects work, use and understand the terminology of the object paradigm.
Trang 1Oriented Paradigm
Trang 2• Understand problem-solving concepts.
• Formulate algorithms using pseudocode.
• Realize the complexity writing algorithms.
• Understand an event-driven environment.
• Describe how classes and objects work.
• Use and understand the terminology of the object paradigm.
Trang 3and nonvisual software components.
• Begin understanding the relationship of
Visual Basic NET to the event-driven and object paradigms.
Trang 4– Find the largest number in the set of numbers.
• Describing Your Solution
– Solve the problem yourself.
– Formulate your solution approach.
Trang 5style used to document the solution to a
program.
• Algorithm is the formal term for the set of
steps used to solve a problem.
Trang 61.1 Problem Solving (cont.)
• Algorithms
– A set of ordered steps for solving a problem,
such as a mathematical formula or the
instructions in a program The terms algorithm and logic are synonymous Both refer to a
sequence of steps to solve a problem Taken
from TechEncyclopedia.com
Trang 7– A formula or set of steps for solving a
particular problem To be an algorithm, a set
of rules must be unambiguous and have a
clear stopping point Algorithms can be
expressed in any language, from natural
languages like English or French to
programming languages like Visual Basic
Trang 81.1 Problem Solving (cont.)
• Getting Data and Displaying Results
– Most algorithms need data
– You must be able to display the results of an
algorithm
– Input data must be accurate
– Algorithm results range from simple to
complex
Trang 9– Major Tasks of a Computer-Base Solution
• Write appropriate computer code to accept and validate data.
• Write appropriate computer code to implement the algorithm.
• Write appropriate code to format the results.
Trang 10Solving Environment
• Most of today’s computer applications are event driven.
• Helps developer organize a solution into
small segments of code.
• One organizes a solution around a series
of events.
Trang 11– Payroll System problem.
– Procedural programming has separate data
and program logic
– Object-oriented programming (OOP)
combines the data and program logic
– Methods describe the behavior associated
with an object
Trang 12Paradigm in Problem Solving (cont.)
– A class is a definition or template that defines how objects are created
– An instance of a class is another name for an object
– Special methods known as classes methods
may be accessed by a class
– Each object instantiated from a class has
Trang 13– The “is a” relationship may be used describe
class hierarchies
– A UML (Unified Modeling Language) class
diagram may be used to define classes
– A subclass descends from a superclass or
base class
Trang 14Paradigm in Problem Solving (cont.)
• Inheritance means a subclass acquires all data elements and behaviors of its related superclasses.
• Member describes the contents of a class.
• Siblings describe any two or more classes that descend from the same superclass.
• An abstract class provides a base class
Trang 15Problem Solving
– Reflects the natural way we think
– The same class definition can be used in
many applications
• Supports the concept of code reuse.
– In creating a subclass, we automatically
inherit all members from the superclass
Trang 16Paradigm in Problem Solving (cont.)
• Visual versus Nonvisual Components
– Some objects can be seen on the GUI
– Other objects cannot be seen on the GUI
– Microsoft provides both visual and nonvisual
components with Visual Basic NET
Trang 18Chapter Summary
• Problem solving with a computer requires the
developer to first solve the problem without a
computer
• Writing algorithms may be difficult
• Most computer applications also include code to obtain input data and to display results
• An event-driven environment is an application
which responds to events generated by the user
Trang 19organized into small units called event
procedures.
• Objects are software components created from a template called a class.
• Each class template defines data and
behaviors that each object created from
Trang 20Chapter Summary (cont.)
• Classes can be arranged in hierarchies
that define a set of “is a” relationship.
• Superclasses (or base classes) are at the top of the hierarchy and subclasses
descend from superclasses.
• A subclass “is a” superclass.
• The object paradigm and polymorphism
provide a very natural and flexible
Trang 21• Most classes created to solve business
problems are nonvisual.
• Visual Basic NET creates event-driven
solutions that use a combination of the
object and nonprocedural paradigms.