ebakircie / OOP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

1_yox45V3KzQM6AAOKJF8zwQ

What is Object-Oriented Programming?

Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic. An object can be defined as a data field that has unique attributes and behavior.

With OOP developers manipulate objects and this approach is well suited for large, complex and constantly updated or maintained programs. Through inheritance, we can minimize codes. It also makes the developing process very benefical to collaborative development since projects are dividing into groups that improve sustainability and efficiency.

Benefits of OOP

  • Re-usability
  • Security
  • Extensibility
  • Maintainability
  • Efficiency
  • Understandability
  • Developing complex software

Abstraction is setting rules for behaviours of classes and stricting their action and hiding any unncessary implementations. Derived classes can extend their abilities which helps us to organize our flow so we can easily make additional changes or implement new functions.

Classes are our blueprints of everything like attributes, methods or objects. Each of them can have different abilities or functions as our intend. They always have the same as the class.

Constructors are preparing the new object for us to use them as we need them. They can be used to set the values of the member of an object.

We can restrict the direct access to some componenets of an object that not necessary to its user. While encapsulation hides the implementations of class without affecting functioning, it allows the class to work as its intended by the designer.

One of key feature of OOP is inheritance. We can create new classes from base class which inherits all the properties and behaviors of its parent but also can extend itself. This greatly increase the code reusability and efficiency.

Interfaces are used for abstraction. Since C# is not supporting multiple inheritance from classes, we will inherit via interfaces for multiple inheritance. Default access modifier is public. They could not contain body of an object, only signatures but with the newer version of C# may have a body. Sub classes must be implemented all members inside interface. This allow developer to set rules of behaviour to the sub classes. Helps us to follow a pattern easily.

Another key feature of OOP along with inheritance and encapsulation. As the meaning of polymorphism, it means many-shaped. In other words, one object has many forms or has one name with multiple functionalities. "Poly" means many and "morph" means forms. It helps to class to have multiple implementation with the same name. For example Method or function overloading. We achieve it by giving different parameters to method with same name.

Static means something which cannot be instantiated. We can use them wherever we need without instantiate. All members of static class must be also static. It cannot contain instance members or constructor. Static classes cannot inherit from other classes. We can easily access them everywhere in solution even if it is in different layer if we gave reference. The only thing we should consider that they remain in memory for the lifetime of the application.

About


Languages

Language:C# 100.0%