super3 / IRC-Bot

A very little basic IRCBot that will get improved over the next time.
http://www.wildphp.com
102 stars 47 forks source link

Use proper methods for getting and setting variables #59

Open NanoSector opened 9 years ago

NanoSector commented 9 years ago

Right now we're getting things like $this->arguments without using proper methods like getArguments.

This is, AFAIK, violating the OOP structure and makes it more difficult to fix bugs.

Consider the following (not a real situation): A security flaw is found in the way commands handle arguments. This is because arguments are passed without any verification.

Without proper methods: fix every command one by one and hope third party commands will follow sooner or later. With proper methods: modify getArguments and fix all included and third party commands in one go.

It may seem like a lot of work and at first it is, but I think in the end it will pay off with easier maintenance of the codebase. Things like $this->bot don't really need this, but couldn't really hurt either.

Interesting read: http://php.net/manual/en/language.oop5.overloading.php Though I'd personally prefer having a method for each variable.