1. Trang chủ
  2. » Công Nghệ Thông Tin

Lecture Learning programming using Visual Basic Net – Chapter 1 Problem solving and the objectoriented paradigm

21 249 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 21
Dung lượng 270 KB

Nội dung

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.

CHAPTER ONE Problem Solving and the ObjectOriented Paradigm Objectives • • • • • • 1- 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 McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved Objectives (cont.) 1- • Demonstrate the difference between visual and nonvisual software components • Begin understanding the relationship of Visual Basic NET to the event-driven and object paradigms McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 1.1 Problem Solving 1- • Use computer software to help solve problems – Sample Problem • Problem Description – Find the largest number in the set of numbers • Describing Your Solution – Solve the problem yourself – Formulate your solution approach – Translate your solution McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 1.1 Problem Solving (cont.) 1- • Pseudocode (false code) is an outline style used to document the solution to a program • Algorithm is the formal term for the set of steps used to solve a problem McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 1.1 Problem Solving (cont.) 1- • 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 McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 1.1 Problem Solving (cont.) 1- • Algorithms (cont.) – 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 McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 1.1 Problem Solving (cont.) 1- • 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 McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 1.1 Problem Solving (cont.) 1- • Getting Data and Displaying Results (cont.) – 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 McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 1.2 The Event-Driven ProblemSolving 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 McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 110 1.3 Using the Object-Oriented Paradigm in Problem Solving • Classes and Objects – 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 – Encapsulates means an object holds in its capsule both data and behavior McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 111 1.3 Using the Object-Oriented Paradigm 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 identical data elements and methods McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 112 1.3 Using the Object-Oriented Paradigm in Problem Solving (cont.) • Class Hierarchies – 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 – A superclass contains data and behavior common to subclasses McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 113 1.3 Using the Object-Oriented Paradigm 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 but cannot be used to instantiate objects McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 114 1.3 Using the Object-Oriented Paradigm in Problem Solving (cont.) • Benefits of Using Object Orientation in Problem 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 – Polymorphism enables the same method to assume different behavior McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 115 1.3 Using the Object-Oriented Paradigm 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 McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 116 1.4 Object Paradigm in Visual Basic NET • Supports both the procedural and objectoriented paradigms • Supports both visual and nonvisual classes • Fully supports inheritance and polymorphism • A namespace identifies a set of classes that are treated as a group McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 117 Chapter 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 or by the system McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 118 Chapter Summary (cont.) • In an event-driven environment, code is organized 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 the class possesses McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 119 Chapter 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 environment McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 120 Chapter Summary (cont.) • Classes can define visual or nonvisual objects • 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 McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 121 ... ©2002 by The McGraw-Hill Companies, Inc All rights reserved 11 0 1. 3 Using the Object-Oriented Paradigm in Problem Solving • Classes and Objects – Payroll System problem – Procedural programming. .. The McGraw-Hill Companies, Inc All rights reserved 11 4 1. 3 Using the Object-Oriented Paradigm in Problem Solving (cont.) • Benefits of Using Object Orientation in Problem Solving – Reflects the. .. reserved 1. 1 Problem Solving 1- • Use computer software to help solve problems – Sample Problem • Problem Description – Find the largest number in the set of numbers • Describing Your Solution – Solve

Ngày đăng: 16/05/2017, 14:45

TỪ KHÓA LIÊN QUAN