When we are writing any program, apart from making sure that it serves the required purpose, we must make sure that we also take the following aspects into consideration:
- Code reuse: We must try to implement the program flow in such a way that common functionalities can be used across multiple modules.
- Code maintenance: We must accept that any program code that's written is bound to have a few bugs. However, we must ensure that the code that's written is clear and structured enough that it's understandable and easy to maintain.
- Design patterns: Design patterns allow us to write programs in such a manner that there is a common template/structure/functionality that can be used across multiple modules. This ensures that the performance of the application is not compromised, which is a key aspect of any program application.
All of these aspects are difficult to achieve in a procedural language. However, using object-oriented programming, which is the main essence of any high-level programming language, we can achieve the aforementioned objectives.
In this chapter, we will cover the following topics:
- Understanding object-oriented programming
- Understanding encapsulation
- Understanding abstraction
- Understanding inheritance
- Understanding polymorphism
We will also go through code examples to understand how these features are implemented in a C# application.