Up: Lectures

Classes and Objects

September 19th, 2011 Leave a comment Go to comments

Object-oriented programming in Python.

Requires: Python

Introduces: Python objects and classes

Motivating questions:

  1. I have a complex program which has lots of duplicated code, is there any way to simplify it?
  2. How do I change the behavior of one part of my program without affecting the rest of it?

Lectures:

  1. Introduction (pdf, ppt)
    • Objects combine functions with data to make both easier to manage.
    • Objects add abstraction to help reduce duplication.
    • They can also help programs to grow piece by piece over time.
    • They also can make programs more complex, if overly used.
  2. Basics (pdf, ppt)
    • A class defines a the behaviors of a new kind of thing.
    • An object is a particular thing with particular properties.
    • Methods are just functions that are part of a class.
    • Member variables are just variables that are part of a class.
    • Constructors are methods that are called when an object is created.
  3. Interfaces (pdf, ppt)
    • Something’s interface is what it knows how to do
    • Programming to interfaces makes it much easier to test/change/replace.
  4. Inheritance (pdf, ppt)
    • One class can inherit methods and member variables from another.
    • Inheritance makes it possible to reduce duplication of code
    • Overriding allows a class to customize the behavior of methods it inherits.
  5. Overloading (under construction)
  6. Design (under construction)
  7. Quality (under construction)

Exercises: link

  1. No comments yet.
  1. No trackbacks yet.