BeginnerTopic 34 of 104Software & Computing
Object-oriented programming
Models software as objects with data and behaviour.
In depth
OOP organises programs around objects that bundle state (fields) and behaviour (methods), instantiated from classes. Benefits: modularity, reuse and modelling of real entities. Languages: Java, C++, Python, C#. Composition is often preferred over inheritance.
Key points
- Class and object
- Message passing
- Interfaces
ExampleA Car class has speed and an accelerate() method.
What is Object-oriented programming?
Models software as objects with data and behaviour.
Why is it important to understand object-oriented programming?
Object-oriented programming organises code around objects that hold data and behaviour, which helps manage large programs.
What is a class?
A blueprint that defines data fields and methods, and an object is an instance of a class with its own values.
Is OOP always the best choice?
No. Some problems are easier to express with functions or data-oriented designs, so the style should match the problem.
How is Object-oriented programming used in practice?
Typical applications include modelling a machine as an object with state and operations, building a set of classes for shapes that each compute their area and representing a customer order with an object that knows its total.
What should I learn before Object-oriented programming?
Study "NP-completeness" first (topic 33 of 104 in Software & Computing). It covers the groundwork this topic builds on.
What are the key points of Object-oriented programming?
Class and object. Message passing. Interfaces.
Can you give an example of Object-oriented programming?
A Car class has speed and an accelerate() method.
What comes after Object-oriented programming?
The next topic is "Encapsulation, inheritance and polymorphism", which builds directly on this one.
How difficult is Object-oriented programming?
It is classed as Beginner in Software & Computing (topic 34 of 104). It is an entry-level topic. It relies only on basic school mathematics and the ideas introduced earlier in this discipline.