01 Jun Doctor, what is wrong with my website? – It is not OOP.
Although it is discussed over and over, a lot of colleagues in the web industry keeps coding using procedural approach, using procedural mysqli (mysql even!) and ignores the basic security concepts. Regardless of the fact that there are too many articles on each subject individually, I could not skip all those constant questions like: “Why do I need it?”, “Is it really necessary?” and the statement: “Well, this is good,” “What do you want, it is working” and similar statements.
Object Oriented Programming (OOP) is a model that focuses on objects rather than actions. The code organisation is about entities that are crucial to the application we are writing.
From the client’s point of view, properly written code means easier optimization, faster work, easier maintenance.
The first step in object-oriented thinking is to identify all objects to be managed through the application and to determine their mutual relationships, a procedure similar to the creation of a table and a column in a database (data modeling). Once we determine the main entity of the applications (objects), we include all of their attributes that we will use through the management of objects. Also, each of the objects can perform some functions that we define through the methods of that object (i.e. user can be logged, users can be listed in the table or as options in the “select” field etc.) Objects among each other communicate through “messages”.
Non-redundant code in OOP is achieved by subclasses, where we define a common class with all common attributes and methods that other similar classes will inherit, and after each individual subclass we define specific attributes and methods.
Since this post does not strive to be any “tutorial” for OOP, I will stop here with listing features. These are the most basic details you need for writing quality web applications.
Why is this important?
This question can be viewed from many perspectives.
From the point of a programmer who is supposed to maintain someone else’s code, the concept of OOP makes it a lot easier to manage something that he did not write. From the perspective of a project manager, better code organization makes it easier to form and assign tasks to developers. From the client’s point of view, properly written code means easier opting, faster work, and easier maintenance.
All of this is especially apparent if design patterns are used, for example well-known templates that solve some of the usual programming chalenges.
The conclusion is that in object-oriented programming application can be written in less time, it costs less and is later easier to modify according to dynamics of the client’s business. And if for any reason a programmer or a development team changes, the new team will be much faster in handling the existing code.