Why Pseudo Code creates Roadmap to the Four Pillars of OOP

Alberto Garcia
3 min readNov 25, 2022

--

When starting a script, using pseudo code to build a development roadmap facilitates the correct usage of the four pillars of Object-Oriented Programming: Abstraction, Inheritance, Polymorphism and Encapsulation. Pseudo Code serves as a great first step in listing all the prioritized tasks of certain script.

Virtues of Pseudo Code

//Abstraction

To keep code clean and simple, the main functions are abstracted out to methods that are easier to access and call upon interaction. Every action that will occur repeatedly or at one particular moment per game play should be easy to call for any other developer working on that same script.

Abstracting a series of functions into one method hides all of this work from developers that don’t need to tweak it, but also work on that same script. If there is a bug in this particular action, the code is much simpler to find. Leaving pseudo code as comments should help during remote collaboration and provide other developers a hint as to what is intended with the code.

//Inheritance & Polymorphism

The relationship of the“Humanoid.cs” to the “Player.cs” & “Enemy.cs” has a similar inheritance as parents with children. The children can access the genetic material of the parents, but the parents cannot inherit genes from children. Polymorphism is the way in which the enemy script, being a child class, calls the same methods from the parent class, in this case the humanoid script, but is adapted to receive less damage per bullet.

Writing pseudo code may provide an ample production scope, facilitating the creation of all the systems involved in the ecosystem of each particular game. It can show to what extent inheritance might be required, be it single, multi-level, or multiple inheritance, and estimate the number of times one class could use polymorphism.

//Encapsulation

Source

The main principle of encapsulation is security in code; ensuring that code is only used as it is intended to be used, and the values and data being manipulated can’t be corrupted. In encapsulated code, other programmers can’t simply modify the values of variables or the properties of objects. It’s hard to contemplate all of the different ways that other scripts might access one particular code, so it’s far better to encapsulate what only needs to perform as intended. This could be foreseen during early development with the help of pseudo code.

If the pseudo code shows code reusability, method security and functions privatization, then writing and testing the actual code will be much smoother for an entire team. This simple imaginary tool can prevent wasted time and facilitate problem-solving on the core development.

--

--