Skip to content

Classes #1

Description

@ageorgou

Motivation

  • Organising code, grouping together relevant functionality
  • "Encapsulation": having data and its behaviour/logic together
    • example: simulation class, all parameters together rather than reading from global state
  • Abstraction: Hide the implementation details so other parts of the code don't need to change
  • Possibly have two examples showing different benefits (Could be Person class from Loveleen's lecture)

Syntax

  • Use one of the examples above.
  • Start by showing usage (constructing and accessing attributes).
  • Show syntax: class keyword, constructor
  • Show syntax and usage: methods

Homework

Show an example of a run_simulation function. Create a class that collects the simulation parameters and has a run() method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions