{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec8 - CSE 8A Lecture 8 Procedural and object-oriented...

Info icon This 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)
Image of page 1

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

View Full Document Right 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”
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)
Image of page 3

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

View Full Document Right 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
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:
Image of page 5

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern