How does C# deal with code reuse?
There are many approaches where C# helps us deal with code reuse. The ability to build libraries, as we did in the previous section, is one of them. The most important one is the fact that the language is object-oriented. Besides, it is worth mentioning the facilities that generics brought to the C# language. This section will discuss the last two we mentioned.
Object-oriented analysis
The object-oriented analysis approach gives us the ability to reuse code in different ways, from the facility of inheritance to the changeability of polymorphism. Complete adoption of object-oriented programming will let you implement abstraction and encapsulation too.
The following diagram shows how using the object-oriented approach makes reuse easier. As you can see, there are different ways to calculate the grades of an evaluation, considering you can be a basic or a prime user of the system:
Figure 13.4: Object-oriented case analysis...