Answer the question
In order to leave comments, you need to log in
Is it possible to write PHP OOP and procedural together without a framework?
I began to develop a regular security script on Linux, which drags all the information about the user, who logged in, what time, when, from where, why, what he does, and so on and so forth.
I know OOP well, but the script will not work out big, maximum 2-3 files each with 50-100 lines no more.
I make this script only for my personal server, not for work, not for clients, for myself personally.
The library works in OOP style.
Stack Overflow says that it's okay to write procedural style and OOP together, unless of course the project is large or the script will grow in size.
Your opinion friends.
Answer the question
In order to leave comments, you need to log in
"the script won't grow in volume" is a typical mistake of a developer, now you have 2-3 files, in half a year you will want to expand the functionality, in a year still whatever, in 3 years you will have a garbage dump of code that you can figure out yourself you can’t, always write as if it’s a big project, there will be less hemorrhoids in the future, write as if it will be a big project, and a psychopath will accompany him - a drug addict who has a gun and who knows where you live.
Pure OOP will stupidly not work without a procedural (functional) style - encapsulation, as it were, hints. This is just an abstraction of functional programming to abstract some logic into some object with methods and properties - but they, like functions, need to be called somewhere and this does not make the functional style (procedural) OOP-shny. When they talk about separation, they mean not to insert frank crutches. For example, in the MVC model, I will check the session not in the action, but before the description of the controller class. But if I do the same somewhere in the core that serves my entire MVC system, then this is normal.
Shit code is a bad habit and it starts with "well, this is for me, here you can do it any way." No, you must always do well, so that OOP, and not mutants, would become a habit. I myself have stepped on this rake more than once, it’s not worth it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question