module 8

Cards (16)

  • Object Oriented Programming (OOP)
    One of the main paradigms of programming used today, where programs are broken down into "objects" which encapsulate data and procedures
  • Procedural programming
    One of the main paradigms of programming used today, where programs are broken down into "procedures" (e.g. functions) that operate on shared data
  • Procedural programming
    • Code runs from top to bottom, calling functions as needed
    • Simpler approach to learn as a new programmer
  • Object Oriented Programming (OOP)
    • Looks for related "groups" of data and procedures that can be encapsulated together to represent/abstract objects
    • More complex, but can be more reusable and scalable
  • Procedural programming
    Data and procedures are independent
  • Object Oriented Programming (OOP)

    Encapsulates data and procedures, controlling access to data via procedures
  • Encapsulation
    Combining data and procedures into a single object, the core concept of OOP
  • Interface
    The outwards-facing parts of an object, defining how it can be interacted with
  • Attributes
    Data stored in an object (variables)
  • Methods
    Procedures/functions of an object (what it can do)
  • Public
    Attributes and methods that are accessible from outside of the object
  • Private
    Attributes and methods that are only accessible from within the object
  • Class
    The blueprint of an object - a data structure that defines what attributes and methods it has
  • Object
    An instance of a class - the values of attributes are unique to each object, but all objects of a class implement the same methods
  • Constructor
    A special method automatically called when an object of the class is created, used to control which attributes must be specified and perform setup
  • Writing a class
    1. Define attributes and methods, including a constructor
    2. Attributes can be made private by adding two underscores before the name