Is this some kind of bizarre heresy to use itemless classes?

It might be a stupid question, but it annoyed me.

I wrote what, in my opinion, is procedural code, but I use classes that combine related public and private functions in accordance with the goals. Instead of using objects and methods, I call functions, when necessary, with a scope resolution operator. i.e.: db::execute($sql)

I know this is funny, but I just realized that everyone immediately associates classes with OOP. Am I doing some kind of perverse heresy?

+4
source share
6 answers

you basically abuse one language construct (class) to emulate another (namespace). This is absolutely normal if you use a language that does not support the latter (php 5.2 -).

+6
source

If you know the difference between classes and "using OOP classes", then I think this is not a real problem ...

+2
source

Perverted heresy may take a little bit, but you are certainly missing out on most of the organizational strength of object-oriented programming.

+2
source

It seems to me that you use classes as namespaces.

I do not see anything special in this - it provides a logical separation of problems and, apparently, facilitates your development / support.

You are definitely better off learning more about object-oriented programming so that you can take advantage of the benefits it offers.

+2
source

Unless you claim to be doing OOP, I see nothing wrong with using static methods for procedural programming to make up for the lack of a namespace in PHP.

+1
source

You are not doing anything wrong.

Some classes are used only to contain utility functions (for example, the Arrays class in Java), which are actually called "static methods".

What you do is use this function when replacing namespaces. For clarity, you should use the latter.

0
source

All Articles