The text editor we developed in the previous chapter was implemented in procedural code. Although it offered some benefits for quick coding, it had some typical limitations:
- We started encountering global variables
- The function definitions needed to be defined above the code that called them
- Most importantly, the code was not reusable
Therefore, we need some way to ensure that our code is reusable. This is why programmers prefer to use object-oriented programming (OOP) to organize their code into classes.
OOP is a programming paradigm that shifts the focus onto the objects we want to manipulate rather than the logic required to manipulate them. This is in contrast to procedural programming, which views a program ...