Chapter 1
1 / 57

Chapter 1 Introduction to Object-Oriented Programming and Problem Solving - PowerPoint PPT Presentation

  • Uploaded on

Chapter 1 Introduction to Object-Oriented Programming and Problem Solving. Knowledge Goals. Understand what a computer program is Know the three phases of the software life cycle Understand what an algorithm is Learn what a high-level programming language is

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Chapter 1 Introduction to Object-Oriented Programming and Problem Solving' - harriet

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Slide1 l.jpg

Chapter 1

Introduction to Object-Oriented Programming and

Problem Solving

Knowledge goals l.jpg
Knowledge Goals

  • Understand what a computer programis

  • Know the three phases of the software life cycle

  • Understand what an algorithm is

  • Learn what a high-level programminglanguage is

  • Understand the difference between machine code and Bytecode

Knowledge goals3 l.jpg
Knowledge Goals

  • Understand the compilation, execution, and interpretation processes

  • Learn what the major components of a computer are and how they work together

  • Understand the concept of an object in the context of computer problem solving

Skills goals l.jpg
Skills Goals

  • List the basic stages involved in writing a computer application

  • Distinguish between hardwareand software

  • List the ways of structuring code in a Java application

  • Name several problem-solving techniques

  • Choose an applicable problem-solving technique

  • Identify the objects in a problem statement

    How can you distinguish the knowledge goals from the skills goals?

What is programming l.jpg
What is Programming?


A programmable device that can store, retrieve, and process data

Computer programming

The process of specifying objects and the ways in which those objects interact to solve problems


Writing out instructions for solving a problem or performing a task

Computer program

Instructions defining a set of objects and orchestrating their interactions to solve a problem

How do we write a program l.jpg
How do we write a Program?




How do we write a program7 l.jpg
How do we write a program …

Problem-Solving Phase

  • Understand (define) the problem and identify what the solution must do

  • Specify the objects and their interactions to solve the problem

  • Follow the steps exactly to see if the solution really does solve the problem

How do we write a program8 l.jpg
How do we write a program …

Implementation Phase

  • Translate the object specifications (the general solution) into a programming language

  • Have the computer carry out the solution and check the results

    What if the solution isn't correct?

How do we write a program9 l.jpg
How do we write a program …

Maintenance Phase

  • Use the program

  • Modify the program to meet changing requirements, to enhance its functionality, or to correct any errors that show up in using it

How do we write a program10 l.jpg
How do we write a program …







How can a computer work with objects l.jpg
How can a computer work with objects?


Any knowledge that can be communicated


Information in a form that a computer can use


A collection of data values and associated operations

How does all this fit together?

How can a computer work with objects12 l.jpg
How can a computer work with objects…









How can a computer work with objects13 l.jpg
How can a computer work with objects…

Objects contain data and operations

Consider a Nameobject

What sort of data would this object contain?

What sort of operations might we need to manipulate the data?

How can a computer work with objects14 l.jpg
How can a computer work with objects…








Classes of objects l.jpg
Classes of Objects

What about multiple objects with the same properties?


A specification of the representation of a particular kind of object, in terms of data and behavior (operations)

Classes of objects16 l.jpg
Classes of Objects

Date class

data: month, day, year

operations: set and return month, day, year

Date object (an instance of a class)




What is an algorithm l.jpg
What is an algorithm?

How are the operations specified?


Instructions for solving a problem in a finite amount of time using a finite amount of data

What is an algorithm18 l.jpg
What is an algorithm?

  • Objects: Key, Transmission, Gas Pedal, Engine, Phone

  • 1. Insert the key.

  • 2. Make sure the transmission is in Park (or Neutral).

  • 3. Depress the gas pedal.

  • 4. Turn the key to the start position.

  • 5. If the engine starts within six seconds, release the key.

  • 6. If the engine doesn’t start within six seconds, release the key and gas pedal, wait ten seconds, and repeat Steps 3 through 6, but not more than five times.

  • 7. If the car doesn’t start, phone your mechanic.

  • What is an algorithm19 l.jpg
    What is an algorithm?

    Once we have the algorithm, then what?

    We translate the algorithm into statements in a programming language

    Say again?

    What is a programming language l.jpg
    What is a programming language?

    Programming language

    A set of rules, symbols and special words used to construct a computer program


    Specific combinations of symbols and special words that are defined by a programming language to be complete units within a program; analogous to sentences in a human language


    Instructions for a computer that are written programming language

    What is a programming language21 l.jpg
    What is a programming language?

    There is








    What kind of instructions l.jpg
    What kind of instructions …


    A programmable device that can store, retrieve, and process data


    accept data, send data, perform arithmetic operations, perform logical operations

    What kind of instructions23 l.jpg
    What kind of instructions …

    Control structures

    Statements that organize the instructions that specify the behaviors of objects

    • sequence

    • selection

    • repetition

    • subprograms

    • asynchronous

    Software maintenance l.jpg
    Software Maintenance

    Maintaining software accounts for the majority of its live cycle (i.e., old programs never die, they just get modified)

    Where were you on January 1, 2000?

    Software maintenance27 l.jpg
    Software Maintenance

    Software maintenance tips

    • Check existing code

    • Make changes to a copy

    • Change related aspects to leave clean, consistent code for next change

    • Keep backup copies

    Software maintenance is not glamorous

    but it is necessary!

    How it all works l.jpg
    How It All Works

    Machine language

    The language, made up of binary-coded instructions, that is used directly by the computer

    Assembly language

    A low-level programming language in which a mnemonic represents each machine language instruction for a particular computer

    How it all works29 l.jpg
    How It All Works

    • High-level language:

      • R1 = R3 + R5

      • R2 = R6 - R1

    How it all works30 l.jpg
    How It All Works




    Machine language l.jpg
    Machine Language

    • Is not portable

    • Runs only on specific type of computer

    • Is made up of binary-coded instructions (strings of 0s and 1s)

    • Is the language that can be directly used by the computer

    Why is portability important?

    Assembly languages l.jpg
    Assembly Languages

    • Are machine dependent and run on only one specific type of computer

    • Are translated into machine code by assemblers

    • Are made up of English-like abbreviations such as LOAD, STORE, or ADD

    Better than machine language…

    High level languages l.jpg
    High-Level Languages

    • Are portable

    • Are translated into machine code by compilers

    • Instructions are written in language similar to natural language

    • Examples -- FORTRAN, COBOL, Pascal, C, C++

    • Many are standardized by ISO/ANSI to provide an official description of the language

    High level languages34 l.jpg
    High-Level Languages

    Source code

    Instructions written in a high-level language

    Object code

    A machine language version derived from source code

    Portability l.jpg

    Compiler portability

    Java s road to portability l.jpg
    Java's Road to Portability


    A standardized machine language into which Java source code is compiled

    High level languages37 l.jpg
    High-Level Languages

    Direct execution

    The process by which a computer performs the actions specified in a machine-language program


    The translation, while a program is running, of non-machine language instructions (such as Bytecode) into executable operations

    Virtual machine

    A program that makes one computer act like another

    High level languages38 l.jpg
    High-Level Languages

    Do you understand the difference

    between C++ & Java portability?

    What s inside the computer l.jpg
    What's inside the computer?








    What s inside the computer40 l.jpg
    What's inside the computer?

    Memory unit

    Internal data storage inside a computer, made up of an ordered sequence of addressable cells


    What s inside the computer41 l.jpg
    What's inside the computer?

    Executes instructions

    The Manager

    Does operations

    Holds data and instructions

    What s inside the computer42 l.jpg
    What's inside the computer?


    The physical components of a computer


    Computer programs; the set of all programs available on a computer


    An electrical circuit that sends out a train of pulses to coordinate the actions of the computer's hardware components; its speed is measured in hertz (cycles per second)

    What is system software l.jpg
    What is system software?

    User/computer interface

    A connecting link that translates between the computer's internal representation of data and representations that humans are able to work with

    Interactive system

    A system that supports direct communication between the user and the computer

    System software

    The set of programs that simplifies the user/ communication interface

    Operating system

    Set of programs that manages all the computer's resources

    What is system software44 l.jpg
    What is system software?








    Problem solving l.jpg
    Problem Solving

    Problem solving

    The act of finding a solution to a perplexing, distressing, vexing, or unsettled question

    How do you define problem solving?

    Problem solving46 l.jpg
    Problem Solving

    How to Solve It: A New Aspect of Mathematical Method by George Polya

    "How to solve it list" written within the context of mathematical problems

    But the list is quite general

    We can use it to solve computer

    related problems!

    Problem solving47 l.jpg
    Problem Solving

    How do you solve problems?

    Understand the problem

    Devise a plan

    Carry out the plan

    Look back

    Problem solving techniques l.jpg
    Problem-Solving Techniques

    Ask questions!

    • What do I know about the problem?

    • What is the information that I have to process in order the find the solution?

    • What does the solution look like?

    • What sort of special cases exist?

    • How will I recognize that I have found the solution?

    Problem solving techniques49 l.jpg
    Problem-Solving Techniques

    Never reinvent the wheel!

    Similar problems come up again and again in different guises

    A good programmer recognizes a task or subtask that has been solved before and plugs in the solution

    Can you think of two similar problems?

    Problem solving techniques50 l.jpg
    Problem-Solving Techniques

    Look for familiar things

    Problem solving techniques51 l.jpg
    Problem-Solving Techniques

    Solve by analogy

    Problem solving techniques52 l.jpg
    Problem-Solving Techniques

    Means-end analysis

    Problem solving techniques53 l.jpg
    Problem-Solving Techniques

    Divide and conquer

    Problem solving techniques54 l.jpg
    Problem-Solving Techniques

    Building-block approach

    Problem solving techniques55 l.jpg
    Problem-Solving Techniques

    Merging solutions

    Problem solving techniques56 l.jpg
    Problem-Solving Techniques

    Object-Oriented Problem Solving Stages

    • Brainstorm List all objects that might contribute to solution

    • Filter Review the classes to find duplicates or remove unnecessary objects

    • ResponsibilitiesDetermine the operations associated with a class of objects

    • Collaborations Determine the interactions between classes

    Problem solving techniques57 l.jpg
    Problem-Solving Techniques

    • Attributes Determine the values defined by a class that are used to represent its objects

    • Driver Write a program for creating the objects and coordinating their collaborations to solve the problem