In this section, we will examine general paradigms in OOP. We start with objects because they are the most fundamental artifacts in OOP. Next, we will look into classes that are blueprints to create objects. Then we will continue with paradigms such as inheritance, polymorphism, and dynamic binding.
In an OOP application, objects are the runtime entities or instances that take space in memory, and more specifically, in the heap. Objects have an associated/allocated memory address to store their state and a set of functions or methods that define the suitable operations on the object state. In short, in OOP, an object encapsulates state and behavior.
To create an object, a blueprint or recipe is required, which is called a class in OOP.
The following section will explore the class concept in more detail. For now, we will define a very simple class in order to be able to talk about objects:
class User { let name = "Constant name" var age: Int = 0 func incrementUserAgeByOne...