21
Mamba
Re: Coding Standards
  • 2009/3/9 16:20

  • Mamba

  • Moderator

  • Posts: 11394

  • Since: 2004/4/23


Quote:
I wouldn't mind seeing the core coding standard

Try this link
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

22
zyspec
Re: Coding Standards
  • 2009/3/9 17:27

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


Thanks Mamba. I don't understand the inconsistency between core function names and module function names but what do I know...

For example why would a core function be called 'xoops_do_something' (underscore seperated) and a module use '[module_identifier]_doSomething' (camelCaps seperated)? See Naming Conventions > Overall Proposal section.

23
Mamba
Re: Coding Standards
  • 2009/3/9 17:52

  • Mamba

  • Moderator

  • Posts: 11394

  • Since: 2004/4/23


Quote:
I don't understand the inconsistency between core function names and module function names but what do I know...

Well, it shows that you have a good eye and that you pay attention

That was the older version. In the new everything is "_doSomething"

EDIT: I've removed the file with Coding Standards from this post. The next message has an updated version.
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

24
trabis
Re: Coding Standards
  • 2009/3/9 18:48

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Pdf has some alignment bugs, you should check the correct way of align arrays there.

I do think that coding standards are very important, and must be respected by those who are committing to core. There are some old areas that are not clean yet, but the recent core changes are as good to read as poetry. Got to love XOOPS (and phppp)!

25
Mamba
Re: Coding Standards
  • 2009/3/9 20:47

  • Mamba

  • Moderator

  • Posts: 11394

  • Since: 2004/4/23


Trabis, good catch.

I simply printed it from the Web to PDF, but obviously the alignment didn't work. I corrected it manually in this attached document.
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

26
zyspec
Re: Coding Standards
  • 2009/3/21 21:56

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


Not sure I should post this here, but it is related - please feel free to move it if it should be somewhere else.

Looks to me like there's a bug in the XoopsLoad class if CamelCaps is the recommended naming nomenclature (Xoops 2.3.2 and beyond, as of 3062 revision).

XoopsLoad->load($name,$type) converts $name to lowercase and then re-capitalizes the first name of the class so it would incorrectly change a CamelCaps class name to just a ucfirst classname. For example it would change 'MymoduleMyClass' to 'Mymodulemyclass'. It should find the ./class/myclass.php file correctly but it won't find the actual class.

Unless I'm missing something - which IS likely

27
trabis
Re: Coding Standards
  • 2009/3/21 22:02

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


ucfirst($dirname) . ucfirst($name)

Like MymoduleMyclass.
Looks fine to me.

28
zyspec
Re: Coding Standards
  • 2009/3/21 23:32

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


what about things like MymoduleMyClassAllTopics

This is a legitimate CamelCaps class name according to the documentation but wouldn't work. More practically "real life" examples would include virtually any 'handler' class and a class like
MymoduleMediaUploader.

It looks like most module developers have not used CamelCaps except as you indicate ucfirst...

Just trying to understand if we should use MymoduleMyClassName or MymoduleMyclassname as the 'preferred' class naming nomenclature.

Login

Who's Online

264 user(s) are online (95 user(s) are browsing Support Forums)


Members: 0


Guests: 264


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits