PHP Classes

reason not defined clearly

Recommend this page to a friend!

      PHP Classes blog  >  What Are PHP Classes ...  >  All threads  >  reason not defined clearly  >  (Un) Subscribe thread alerts  
Subject:reason not defined clearly
Author:Daniel Fotograf
Date:2015-10-29 13:46:03
Update:2015-10-30 00:30:26

  1. reason not defined clearly   Reply   Report abuse  
Picture of Daniel Fotograf Daniel Fotograf - 2015-10-29 16:54:26
so basically from your article, the only reason why I should use classes is naming convention? Am I missing something, because that's not a reason, even if you have a huge application. just saying.
and the whole login/register process just to post a comment is way to complex.

  2. Re: reason not defined clearly   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-10-29 17:51:37 - In reply to message 1 from Daniel Fotograf
No, that is not what the article says. What it says is:

"The main reason why it is better to organize your project code in classes is to avoid collision of names of functions or variables used by different components."

This is a reason to use OOP as opposed to using global code.

This article appeared because some contributors were submitting packages of global code to the site, when it only accepts code based on OOP classes, thus the name of the site "PHP Classes".

Of course there are other reasons to use OOP, but that is outside the scope of this article.

As for registration, did you have to submit a password and validate your email address?

You can register and login immediately without entering a password for the site nor validating your email address, clicking on the buttons on the left of the registration page that allow you to login using your account on either Gmail, Facebook, Hotmail, StackOverflow, or Github.

  3. Re: reason not defined clearly   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2015-10-30 00:30:26 - In reply to message 1 from Daniel Fotograf
You can blame the whole user registration and validation process on malicious users. There was a time when we could be a little trusting and could not imagine people would do some of the things they do. I still do not fully understand their motivation, however, I am well aware that the time of trust is ancient history.

In my personal projects, I could care less about naming collisions because I simply do not collide anything. If I plan on sharing code then I have to be a little more polite and classes are a good way to keep my own conventions outside of the global scope.

In my experience there are just as many OOP fanatics as there are procedural fanatics. If someone has written some bad code and shares it, I simply don't use it. On the flip side, if someone does not like my code then they don't have to use it. I am aware though that phpClasses is all about the objects, so when I am in his house I follow his rules.

Okay... I am moving a bit off topic. The reason you should use OOP when sharing code on this site is because that is what this site is about. The reason I use objects, when I use them, is because I love the $this pseudo-variable.