Purpose of OOLs
Current languages could not simulate real world entities properly, better cohesion and coupling.
OOL Influences
Procedural Languages, Lambda Calculus, Types
class hierarchy
expresses relationship between classes
polymorphism
function is applicable to more than one type
white box inheritance
sharing, but breaks encapsulation. Inherited class internals visible to subclass
inheritance
reusing the definition of one type of object to define another type of object
encapsulation
bundles slots and the methods that operate on those slots into a single unit, leads to loose coupling and strong cohesion
black box inheritance
uses functionality of superclass without exposing the superclasses’ implementation details, doesn’t break encapsulation
cohesion
how much code belongs together
weak cohesion
coincidental bundling, similar functions
medium cohesion
components provide similar services or functions
strong cohesion
each component contributes to software function
coupling
how connected the code is
loose coupling
changes in A are unlikely to affect B
tight coupling
changes in A are likely to affect B, puts change costs up
best type of coupling
loose
best type of cohesion
strong
strong cohesion and loose coupling
results in understandability, maintainability and adaptability
generic functions
a function that can run on multiple data types
fn <T>my_func(p: T) {} in rust, same as a polymorphic function
generic functions features
classes, instances, methods, multi methods, slots, singe/multiple inheritance
prototyping
simplest kind of OO, object = attributes + behaviours
delegation
enables the sharing of behaviour, object = attributes + behaviours + parent
traits
sharing behaviour (methods)
maps
sharing structure (slots)