Chapter 1 deck Chapter 2 deck Chapter 3 deck Chapter 4 deck Chapter 5 deck Chapter 6 deck Chapter 7 deck Chapter 8 deck Chapter 9 deck Chapter 10 deck Chapter 11 deck Chapter 12 deck Chapter 13 deck Chapter 14 deck

Benefits of OOP & Summary

5 slides · use ←/→ or Space to navigate, F for fullscreen.

Reading view

← Back to the full Chapter 7 deck

Benefits of OOP & Summary
Fullscreen for presentation · Print / PDF for a handout
1 / 5
Lesson

Benefits of OOP & Summary

Why use OOP in JavaScript, and the lecture summary.

Benefits of OOP & Summary

Benefits of OOP — Part 1

BenefitDetail
Modular codeObjects can be defined and developed independently — divide a large codebase into manageable, self-contained units.
AbstractionHide complex implementation details inside a class; expose only a clean, easy-to-use public interface.
Code reuseDefine a class once and instantiate it as many times as needed — eliminating copy-paste duplication.
InheritanceChild classes extend parent classes to gain their properties and methods, minimising redundant code.
Benefits of OOP & Summary

Benefits of OOP — Part 2

BenefitDetail
PolymorphismObjects of different types respond to the same method call in their own way — enabling flexible, extensible code.
Readable codeClass-based code closely mirrors real-world concepts, making it intuitive for developers joining the project.
State managementEach object tracks its own state internally, reducing reliance on global variables and lowering bug risk.
Improved testingObjects can be tested in complete isolation; a bug in one class does not require re-testing unrelated code.
Benefits of OOP & Summary

Lecture Summary

#Takeaway
1Class syntax — use the class keyword with a constructor to define object blueprints cleanly.
2Object instances — use new to create independent instances, each with its own property values.
3Animation loop — requestAnimationFrame() drives smooth 60fps rendering on the canvas.
4Game loop — iterate an array of game objects each frame: update all, then draw all.
5Prototype extension — add shared methods to all instances by extending the constructor prototype.
6OOP benefits — modularity, reuse, abstraction, inheritance, polymorphism and testability.
Benefits of OOP & Summary

Activity — complete the code

Complete the OOP benefits recap.

// OOP benefits
// — define objects independently in manageable units
// Code — define a class once and instantiate it many times
// — each object tracks its own state internally
// Improved — objects can be tested in isolation