Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Class 10: Object Oriented Programming

Class 10: Object Oriented Programming

Class notes for 2/6/2014

Ian Luke Kane

February 06, 2014
Tweet

More Decks by Ian Luke Kane

Other Decks in Technology

Transcript

  1. Procedural Programming Review Design Method = Top Down Start with

    a problem (procedure) and then systematically break the problem down into sub problems (sub procedures). Procedures, also known as routines, subroutines, methods, or functions simply contain a series of computational steps to be carried out. Issues?
  2. SegSim Explanation “Segregation Simulation”: A simple model for investigating how

    over time communities can become segregated based on various prejudices. 1. Break the problem down into one dimension; a street initially populated with equal probability either black ‘B’, white ‘W’ or empty ‘ ‘ houses. 2. We then allow the system to evolve by randomly selecting houses and applying a simple condition: If the house is surrounded on both sides by a house different to itself, it will decide to move to an empty location in the street where this condition is not satisfied. In the unlikely event that a suitable location cannot be found after a designated number of attempts, the house will leave the street.
  3. SegSim Sample Output | BW W BWB BWBBWWBWWW W B

    BW BW WW BWW BWWW | : 17   | BW W BWB BWBBWWBWWW WBB BW BW WW WW BWWW | : 15   | BW W BWB BWBBWWBWWW WBB B BWWWW WW BWWW | : 13   | BBW W BWB BWBBWWBWWW WBB B WWWW WW BWWW | : 11   | BBW W BWBBBWBBWWBWWW WBB B WWWW WW WWW | : 8   | BBW BWBBBWBBWWBWWWWWBB B WWWW WW WWW | : 6   | BBW BWBBB BBWWBWWWWWBB B WWWW WW WWWW | : 5   | BBW WBBB BBWWBWWWWWBB BB WWWW WW WWWW | : 3   | BBWW BBB BBWWBWWWWWBB BB WWWW WW WWWW | : 1   | BBWW BBBB BBWW WWWWWBB BB WWWW WW WWWW | : 0
  4. SegSim Modified Rules Suppose we want to add a different

    type of house that plays by different rules, then see how the simulation differs? Consider a nomad type house (label ‘N’) which does not care about its neighbors. However, it remembers how long it has been in one location, and if longer than a specified threshold it moves to a new location. How must we modify the original program in order to account for these new rules?
  5. Object Oriented Programming An object oriented program may be viewed

    as a collection of interacting objects, as opposed to the procedural model, in which a program is seen as a list of functions to perform. The aim of object-oriented programming is to try to increase the flexibility and maintainability of programs. Data before action.
  6. Object Oriented Programming A programming paradigm that represents concepts as

    objects that have data fields (properties that describe the object) and associated procedures known as methods. Objects, which are instances of classes, are used to interact with one another to design applications and computer programs. Some verbiage can vary.
  7. What is a class? A collection of objects that have

    common properties, operations and behaviors. A combination of state (properties) and behavior (methods). A data type, and objects are instances of that data type. In other words, classes are prototypes from which objects are created. The blueprint.
  8. What is an object? An instance of a class. An

    object receives all of the characteristics of a class, including all of its default data and any actions that can be performed by its methods. Objects can communicate. An object passes a message to another object, which results in the invocation of a method. The “object” you build from the blueprint.
  9. What is a method? A set of functions contained within

    a class. Allows you to do “stuff.” The response to a message is executing a method. Sending a message means calling a method.
  10. What is a property? A default set of data stored

    in a class. A class can have multiple properties and the properties can be changed dynamically through the methods of the class.
  11. What is inheritance? Multiple classes may share some of the

    same characteristics, and have things in common with one another, but also may have certain properties that make them different. Object oriented programming allows classes to inherit commonly used state and behavior from other classes.
  12. Major Distinction Procedural • Uses procedures to operate on data

    structures* Object-Oriented • Bundles the two together, so an object, which is an instance of a class, operates on its "own" data structure. * A particular way of storing and organizing data in a computer so that it can be used efficiently