CHAPTER ONE Problem Solving and the Object- Oriented Paradigm
McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved Objectives Understand problem-solving concepts. Formulate algorithms using pseudocode. Realize the complexity writing algorithms. Understand an event-driven environment. Understand basic concepts of classes and objects.
McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved Problem Solving 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 Problem Solving (cont.) 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 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.
McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved 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.
McGraw-Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved Problem Solving (cont.) 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 The Event-Driven Problem- Solving 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 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 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 Microsoft Visual Basic.NET A Rapid Application Development (RAD) environment Supports object-oriented paradigm