Encapsulation Part 3: Objects

So far I’ve covered encapsulating arrays but objects are a far more common data type to encapsulate. The basic idea is to allow properties to be set, accessed, checked and removed without giving direct access to the object itself. You’ve almost certainly seen structures like this before. For consistency, setting will return the instance and […]

Encapsulation Part 1: Overview

Encapsulation is one of the four major principles of object-oriented programming (the others are abstraction, inheritance and polymorphism which I might cover in a later post). The basic idea behind encapsulation is to provide access to data while still hiding or protecting it. In this series of blog posts, I’ll show how this is done; […]