Microsoft Visual C#: Object Oriented Programming
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
There are four pillars or key-characteristics that make up an object-oriented language:
(1) Encapsulation
(2) Polymorphism
(3) Inheritance
(4) Reuse
Because Microsoft Visual C# is an object-oriented language, it is important to understand these concepts to truly harness the power and versatility of the language.
Encapsulation is the concept of making classes or “packages” that contain everything you need. In object-oriented programming, this means that you can create a class that stores all the variables that you need and all the routines to manipulate the data. You can create a “Triangle” class that stores information about triangles. This could include information about the three angles, the three sides, and more. By encapsulating a triangle, you allow the user to be oblivious to how the triangle works. The user needs to know only how to interact with the triangle. This provides a “shield” to the inner workings of the triangle. Any programs that you write that use the “Triangle” class should not need revisions of any kind.
Inheritance is the way in which individual instances of a class automatically carry with them all the attributes of the “umbrella” class over them. So, triangles, circles, squares, etc. all inherit characteristics of the “shapes” class which overshadows all of them.
Polymorphism means having the capability of assuming different forms. For example, different formulas for different shapes are needed to determine the areas of individual triangles, squares, or circles that are submitted to the program. Polymorphism is the way in which you can guarantee, for example, that all unique shapes will be treated as such and correctly united with the correct area formula (that is, per this example).
Reuse: when you create a class , you should be able to reuse it to create lots of objects. By using inheritance and some of the features in the above sections, you can create routines that can be used repeatedly in many programs and in many ways. By encapsulating functionality, you can create routines that have been tested and are proven to work. You won’t have to test the details of how the functionality works. Rather, you need only know that it works correctly.
Inspired Source: Learn C# in 21 Days by Bradley Jones
















Share your thoughts, leave a comment!