Unit 2 · Introduction to Object-Oriented Programming

2.2Procedural vs Object-Oriented Programming

FeatureProceduralObject-oriented
Main unitFunctionObject (created from a class)
FocusWhat steps must be doneWhich things take part and what they do
Data and functionsSeparateBundled together
Data securityWeak: data is often globalStrong: data can be hidden (encapsulation)
ReuseCopy or call functionsInheritance and composition
Modelling real lifeHarderNatural: objects mirror real things
Maintenance of large programsBecomes difficultEasier, because changes stay inside classes
Typical useSmall scripts, system utilitiesLarge applications, GUIs, games, enterprise systems

Reading the comparison

In this section