Jump to content

Classes/Functions


Ninjakreborn

Recommended Posts

I have been using functions for a long time. Long ago I got obsessed with Classes and started using them for everything..but lately I am starting to wonder if that is the best idea.

 

A function is re-usable code that is brought together in an organized purpose for re-use at future times.

A class is a collection of related values, properties, methods that allow for a specific task to become easier.

 

In this situation a class generally has something that is done..but the system remembers what was done. For example you use variables to contain data that passes back and forth through various functions..that's why your able to advanced operations on just a few lines of code.

 

Functions are not the same way..they are each separate parts of re-usable code that aren't connected (necessarily).

 

So what I usually have been doing is creating a class..but their not always related to the same things.  I have actually been making classes with a collection of random functions. It's not like file handling..creating a class that can deal with file handling..you can call a few parameters to setup what files and then start calling the class functions to automatically handle everything.  So in this situation I am starting to wonder if a random collection of unrelated functions brought together into a class is a waste of time..

 

Since I am also losing the benefits that a class helps to bring.

What are your thoughts on this and how you decide what your going to make into functions and what your going to make into classes.

By the way I debated on where this should go...if I put it into the wrong area feel free to move it.

Link to comment
Share on other sites

So in this situation I am starting to wonder if a random collection of unrelated functions brought together into a class is a waste of time..

 

Not a waste of time maybe, but certainly not the best possible usage of classes/OOP.

Link to comment
Share on other sites

That's what I was thinking..so my thoughts are starting to be, to take my functions and split them up into which functions are related..creating me a php page that has different classes within the pages for different related functions so I can use the Classes/oop power better.  Then below my classes perhaps have all of my unrelated functions that are randomly used.  Since I have 4-5 file handling functions I can put them together into one class, then group them separately. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.