tags:

views:

127

answers:

6

This may be a silly question, but it's been bugging me.

I've been writing what I believe to be procedural code, but I'm using classes which group together related public and private functions according to purpose. Instead of using objects and methods, I call the functions when needed with a scope resolution operator. ie: db::execute($sql)

I know it's ridiculous, but I just now realized everyone immediately associates classes with OOP. Am I committing some perverted heresy?

+2  A: 

If you know the distinction between classes and "OOP use of classes" then I guess it is not a real problem ...

Cedric H.
+2  A: 

"Perverted heresy" might be taking it a little far, but you're certainly missing out on much of the organizational power of object oriented programming.

Scott Saunders
+6  A: 

you're basically abusing one language construct (class) to emulate another one (namespace). This is totally normal, as long as you use a language that doesn't support the latter (php 5.2-).

stereofrog
+2  A: 

It sounds to me like you're using classes as namespaces.

I don't see anything particularly wrong with this - it provides logical separation of concerns, and presumably makes things easier for you to develop/maintain.

You'd definitely be better off learning more about Object-Oriented Programming so you can take advantage of the benefits it offers.

kiswa
That's basically it. It made sense in an organization way, so I just went with it.
Greg
A: 

You are not doing anything wrong.

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

What you are doing is using this feature in substitution of namespaces. For clarity you should use the latter.

klez
+1  A: 

As long as you don't claim to be doing OOP, I don't see anything wrong with using static methods for procedural programming to make up for PHP's lack of namespaces.

Michael Borgwardt