Object Oriented Programming in C#
Object-oriented programming is a way of developing software applications using real-world terminologies to create entities that interact with one another using objects.
Object-oriented programming makes applications flexible (easy to change or add new features), reusable, well-structured, and easy to debug and test.
Most programming languages provide the following basic building blocks to build object-oriented applications:
- Classes: A Class define the structure using methods and properties/fields that resemble real-world entity.
- Methods: A method represents a particular behavior. It performs some action and might return information about an object, or update an object’s data.
- Properties: Properties hold the data temporarily during the execution of an application.
- Objects: Objects are instances of the class that holds different data in properties/fields and can interact with other objects.
- Interfaces: An interface is a contract that defines the set of rules for a particular functionality. They are used effectively with classes using OOP principles like inheritance and polymorphism to make applications more flexible.
Object-oriented Design Principles
There are various object-oriented principles and techniques using which you can develop applications that are maintainable and extendable.
The followings are four main principles of object-oriented programming:
You will learn the above principles in detail in the next few pages.
Steps for Developing Object-oriented Applications
Developing an object-oriented application starts with the business requirement document. Typically, a business analyst provides you with a business requirement document after understanding and analyzing the requirement from the customer. So, the business requirement is the starting point.
The followings are overall steps to develop an object-oriented application:
-
Abstraction: First, identify essential entities and their characteristic from the business requirement for a high-level view.
- Find nouns from the business requirement (the noun is the person, place, thing, or process).
- Identify potential classes and their members from the nouns.
- Encapsulation: An implementation of abstraction in code. Create classes and their members with appropriate access modifiers to show functionalities and hide details and complexity.
-
Define relationship: Establish relationships between classes using inheritance and polymorphism.
- Inheritance
- Polymorphism
- Use Principles & Patterns: Use the SOLID principles and Design Patterns as and when necessary to make applications flexible.
Here you will learn about important object-oriented principles and patterns and when and how to use them in your application.