Object Oriented Programming (Theory)

Introduction: Welcome! This page will be explaining Object Oriented Programming with examples. The examples are theory only but a code example will be released soon (if not already). What is Object Oriented Programming? Object Oriented Programming (OOP) is commonly used in programs which require doing the same things over and over again. Much like a function or method can be ran multiple times, OOP classes can be ran multiple times, simultaneously. When is OOP used? OOP is used in games and some other software. The reason it is used in games is because the game requires the same things to happen over and over again at the same time, for example... Example (Theory): In games there are entities (characters, animals, keys, doors, etc). Each entity has its own class with it's own variables which is where OOP comes in to play. Say if we had one class which controlled the doors in our map, the objective of the game is to get the specific keys for each door. If we just had one class handling all of our doors, once we got a key it would set the door variable "open" to true and it would open all of the doors in our map. Whereas if we use OOP to control the doors in our map, we still only have one class but all the variables in the class only refer to a single door. Therefore giving us the ability to control seperate doors, with the same amount (or less) of code than that without using OOP. Finished!

Comments

thank u but need more study time

Add new comment