Lec8 - CSE 8A Lecture 8 Procedural and object-oriented programming Top-down design Designing classes for object-oriented programming Instance

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Page 1 of 32 CSE 8A, UCSD LEC8 CSE 8A: Lecture 8 Procedural and object-oriented programming Top-down design Designing classes for object-oriented programming Instance variables and instance methods Constructors The “this” variable Variables of reference type vs. variables of primitive type Exam return & discussion (Reading: Savitch, part of Ch. 4 and Ch. 5)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Page 2 of 32 CSE 8A, UCSD LEC8 Programming paradigms So far, we have been doing mostly “Procedural Programming” in Java We have been defining classes, but we have only been defining static methods -- procedures -- inside them. To call these methods, you haven’t had to create any objects first We have been creating some objects (instances of classes Scanner, String, etc.) and using them, but these are not objects that are instances of classes we have defined Procedural Programming is a programming paradigm, a way of thinking about how to tell a computer to do something useful Now we will begin to take a serious look at another programming paradigm: “Object Oriented Programming”
Background image of page 2
Page 3 of 32 CSE 8A, UCSD LEC8 Procedural Programming and Object-Oriented Programming “PP” and “OOP” are two programming paradigms, but they have much in common It is possible to do object-oriented programming (OOP) in a “procedural” language like C or Pascal It is possible to do procedural programming in an “object-oriented” language like Java or Smalltalk or C++ Some things these two paradigms have in common are they use variables (see lecture 2 and 3) they use branching (see lecture 4) they use iteration (see lecture 5) they use functions (see lecture 5 and 6) So, when learning OOP, don’t forget what you already know about programming (However, OOP does involve some different ways of thinking, as we will see)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Page 4 of 32 CSE 8A, UCSD LEC8 Top-down software design A large problem can be broken down into a set of subproblems Each subproblem can then be solved separately, and the solutions combined into an overall solution (And to solve those subproblems, they can be broken down into sub-subproblems, etc!) This basic strategy is known as “top-down design”, “stepwise refinement”, “divide- and-conquer”. .. Top-down design is an important example of abstraction in computer programming By dividing the problem into subproblems that can be solved independently, you can concentrate on some details while “abstracting away” the rest This is essential in making really large problems solvable Top-down design can apply in procedural programming, and OO programing
Background image of page 4
Page 5 of 32 CSE 8A, UCSD LEC8 Top-down design in two paradigms In Procedural programming: Each subproblem is typically solved by a designing a subprogram (also called procedure, subroutine, function) These functions are called by a main() function and each other to solve the overall problem In OO programming:
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/12/2008 for the course CSE 8 taught by Professor Marx during the Fall '08 term at UCSD.

Page1 / 32

Lec8 - CSE 8A Lecture 8 Procedural and object-oriented programming Top-down design Designing classes for object-oriented programming Instance

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online