markward / local_autogroup

A local plugin for Moodle 2.7 onwards which handles the dynamic creation, population and cleanup of groups on courses.
3 stars 25 forks source link

Referring to namespaced classes #9

Open mudrd8mz opened 9 years ago

mudrd8mz commented 9 years ago

Just for your information, Moodle coding guidelines have somewhat strict guidelines on how (not to) use the namespaced classes. Things like $this->user = new domain\user(); are explicitly discouraged at https://docs.moodle.org/dev/Coding_style#Namespaces As with any coding style guidelines, this is something you may or may not agree with but it's a result of quite long discussions. We do not strictly discriminate contributed plugins on the coding style. But I noticed you try to get in line with Moodle coding guidelines so I thought I would let you know here.

markward commented 9 years ago

Hi David,

Thanks for providing me with feedback.

Would this be resolved by adding a "use domain\user as user" line to the top of the file so that I can just refer to "user" inline?

Thanks again

Mark

mudrd8mz commented 9 years ago

Would this be resolved by adding a "use domain\user as user"

Well, not really. Moodle coding style explicitly states:

Do not use named imports ("use XXX as YYY;") unless it is absolutely required to resolve a conflict.

I am just quoting https://docs.moodle.org/dev/Coding_style#Namespaces here. Please note this is really meant as a note. Of course, you can decide to ignore it (although we generally encourage the community to follow the Moodle coding style for plugins, too).