Brief Overview of Object Orientated Programming(OOP)

A brief overview of OOP .

Image for post
Image for post
“turned on Acer laptop on table near cup” by Anete Lūsiņa on Unsplash

What is OOP?

OOP is Object Orientated Programming, which is based on creating a application based on splitting or restricting responsibilities using classes, interfaces, etc. There are multiple concepts such as abstraction, decomposition, generalization, encapsulation, and composition. The purpose of OOP is to make your applications extendable, maintainable, and reusable(if you were to change frameworks).

What are the concepts of OOP and why do we use them?

Abstraction — Abstraction is making classes has little surprises. Or making them as intuitive as possible.

Decomposition — Decomposition is breaking functionality of your application, and parts of your application to smaller parts.

Generalization-Is to generalize parts of your application, there creating base classes, leading the way for inheritance.

Encapsulation-Is hiding/protecting parts of your application, so your data is easier to manage. Also can add new code and won’t effect the class.

Composition-A prefered way over overusing Generalization, where you would compose alot of your logic in one class, easier to change class. BUT DO NOT DO A COMPOSE ONLY APPROACH!

What pattern is used most with OOP?

The most used pattern used for making web applications is model-view-controller. These are 3 main objects for model-view-controller. Entity, Control, and Boundary objects.

Entity — Objects that are responsible for “real world” data. Data that is retrieved from a database. Like using EntityFrameworkCore to create a class inheriting from DbContext , to retrieving data from mysql database.

Control — Class that is responsible for coordinating the use of 2 objects. Used to filter data from database, or controls business needs.

Boundary — Class that are responsible for accepting input,and outputting output. Used for interacting with the UI.

There is one more type of object which is a subcategory of the entity object.

Value — Class, which is immutable and used for debugging.

How would you structure a OOP web application?

You could follow many methodologies, but in this circumstance we would use Domain Driven Design .

Here are 5 parts of your web application.

Data — class library that is responsible for retrieving data from the database.

Infrastructure —A class library used for implementing your persistance layer for retrieving data. Like a RepositoryClass.

Domain — A class library used for defining models of your objects for the persistance layer like a Customer Class for your CustomerRepository.

Services-A class library used to retrieve data for the controller.

Web-A mvc application used to hold your models, controllers, and view. You would implement another frontend framework if wanted at this part.

Well that is it for the overview. If I made any errors, or you would like to add something add, respond. I would like the improve this article.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store