I am a wordpress plugin developer. I saw the source of many pluginsand many plugin use "classes" in them and some without classes.

Many huge coded plugins like "wp-postratings" does not use Classes and some small plugins use Classes.

edit: Since classes have private, public and protected access specifiers, i feel a taste of security Does it increase security?

Other than PHP does other languages require classes ?

Is it compulsory to use Classes ?

I need some suggestions.

+14  A: 

No, it's not compulsory, nor does it increase security per-se. it's just a different style of programming.

Most programmers would agree that object-oriented programming (classes) has many advantages over modular programming (functions). But that's more of a religious debate that I'd rather not get into :)

Eric Petroelje
erm, actually you don't **need** classes to implement OO - it just makes it easier
@symcbean: I always thought classes are a fundamental part of OOP. Can you give an example of OOP without classes?
Felix Kling
@Felix - You can simulate many aspects of classes in a language like C using structs and function pointers. You can even simulate inheritance to a certain extent using unions or clever alignment in your stucts. You also see things resembling OO in many C APIs. Like the use of handles in the WIN32 API where you have different types of handles, operations that work on only certain types, and operations that work on all types of handles, etc.
Eric Petroelje
@Eric Petroelje: I see. Thank you.
Felix Kling
@Felix - Eric's already provided the answer I was thinking of - but you might also want to consider how javascript works - it has real objects - but no classes.
+2  A: 

It's obviously not a technical requirement, but if the code structure of your plugin can be described in 2 or more classes, I'd say go OO. It doesn't have anything to do with security but it might make your code cleaner and easier to maintain.

+1  A: 

Unless you have a good reason not to, I recommend always using classes. There is no real downside to using them.

+4  A: 

You should read about Object Oriented Programming. It is not compulsory to use classes but it can make code organization and maintenance of your code easier.

Felix Kling
Recently i saw a tutorial in developing a web app. It uses classes for login and registration system. So classes increase security ?
Aakash Chakravarthy
@Aakash Chakravarthy: No the don't increase security. But they make it easier to keep track of states and group functionality. For example it is much easier to have a `User` class that holds all the information of the current user as to use a lot of global variables.
Felix Kling
The use of classes (or not) has nothing to do with security, and everything to do with organizing your program into chunks of reusable and easy to understand code.
+1  A: 

Using classes is not mandatory it just helps you and other developer who will modify your code to understand it better.
In my opinion you should use classes whenever it's necessary.

Martin Sikora
+2  A: 

As Eric already said, it's not compulsory, nor does it increase security per-se.

One huge advantage, however, is that it simplifies prefixing and reduces the risk of accidentally causing an error from redeclaring a function.

I always use OOP when I can.

John P Bloch

You do not have to write code in an Object Oriented Fashion. You can write procedural code in PHP as well. Many projects do, Drupal, if I am not mistaken is one of them.

At the end of the day. Use the programming paradigm that is best suited to the task at hand, whether it be procedural, functional or OOP.

Russell Dias