Forums / Discussions / The eZ Coding standards need you !

Thursday 26 May 2011 9:09:02 am - 17 replies

Introduction

In our continuous effort to open eZ Publish to both our community and professional partners, we have worked on establishing coding standards that will help uniformize how our software is written and organized.

Since you, community members, are contributing more and more to eZ Publish, by means of pull requests or extensions, it only makes sense to ask for your feedback before we publish a first version of these standards.

» Read full blog post

Author Message

Matthieu Sévère

Thursday 26 May 2011 11:46:07 am

Hello Bertrand,

Thank for this, that's VERY useful !

I'm a bit confused about conding standard on class name. You say that class name are Upper Camel Case with a prefix "ezp". But ezp doesn't begin with a capital so it's not Upper Camel Case ? 

Also you give an exemple "FooProvider::factory()" and it's not prefixed with ezp and is Upper Camel Case. So, is prefixed class with ezp only for internal used in eZSystems ? What should we use in extension ? Is a prefix needed ?

Cheers !

--
eZ certified developer: http://ez.no/certification/verify/346216

Yannick Komotir

Thursday 26 May 2011 12:08:26 pm

Hello,

Thank you for this big work ! What about //autogentag// in extensions ?

<|- Software Engineer @ eZ Publish developpers -|>
@ http://twitter.com/yannixk

Bertrand Dunogier

Friday 27 May 2011 2:53:49 am

"

Hello,

Thank you for this big work ! What about //autogentag// in extensions ?

"

It is valid for extensions built by our build server, but won't be applied to community ones, as they're not built this way. This would require a completely different project I'm afraid :(

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Bertrand Dunogier

Friday 27 May 2011 2:58:18 am

"

I'm a bit confused about conding standard on class name. You say that class name are Upper Camel Case with a prefix "ezp". But ezp doesn't begin with a capital so it's not Upper Camel Case ? 

Also you give an exemple "FooProvider::factory()" and it's not prefixed with ezp and is Upper Camel Case. So, is prefixed class with ezp only for internal used in eZSystems ? What should we use in extension ? Is a prefix needed ?

"

About Camel Case, the standard is actually LowerCamelCase due to the prefix. It isn't an easy question, actually, but I would propose the following:

  • The class name, prefix ignored, uses UpperCamelCase
  • The prefixes for ezpublish are ezp (for ezpublish) and ezx (for ez extensions)
  • Community / Market extensions must use their own prefix, either based on the extension name or the provider name

So yes, ezp / ezx are to be reserved to eZ Systems, and a prefix is required for extensions. We will update this when we start using namespaces ourselves (soon !).

I'll update the document accordingly, thanks !

Oh, and the FooProvider class is of course a mistake, it will be fixed to ezpFooProvider :-)

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Bruce Morrison

Friday 27 May 2011 4:07:21 am

Looks good.

"Torough documentation"  should be "Thorough documentation"

No mention of line length?

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Bertrand Dunogier

Friday 27 May 2011 5:19:01 am

"

Looks good.

"Torough documentation"  should be "Thorough documentation"

No mention of line length?

"

Thank you for highlighting my english mistakes in huge black letters, Bruce, I'll fix this soon :-)

Did I really forget line length ? My god, thanks, todo list as well !

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Bruce Morrison

Friday 27 May 2011 5:57:08 am

Hey Bertrand

Opps. Sorry about the big back letters - cut n paste from the google doc.  Had assumed that they would be stripped on publishing since headings are not available in the OE toolbar. What else can be pasted into these???

Are there plans to create/release a php CodeSniffer rule set based on the standard?  

Cheers
Bruce 

Bertrand B

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Bertrand Dunogier

Friday 27 May 2011 6:05:54 am

"

Opps. Sorry about the big back letters - cut n paste from the google doc.  Had assumed that they would be stripped on publishing since headings are not available in the OE toolbar.

"

Hmmm headings ARE available in the OE toolbar, but not when replying in comments... maybe they're just removed from the UI but not from the supported XHTML? This wouldn't be surprising...

No offense taken anyway, it was kinda funny ;-)

"

Are there plans to create/release a php CodeSniffer rule set based on the standard? 

"

It is part of the plan, yes !

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Björn Dieding@xrow.de

Monday 30 May 2011 8:37:47 am

I don`t wanna use xdebug.... I am stuck with Zend Debugger :-)

So the doc should say should use a debugger.

Looking for a new job? http://www.xrow.com/xrow-GmbH/Jobs
Looking for hosting? http://hostingezpublish.com
-----------------------------------------------------------------------------
GMT +01:00 Hannover, Germany
Web: http://www.xrow.com/

Carlos Revillo

Monday 30 May 2011 12:16:50 pm

Hi there. Really great work!. 

A question. Are there any plans to apply this standards specially those related with phpdoc things to the actual code? or at least, do you think that contributions related to this (changing doxygen to phpdoc) will be helpful or do you prefer community member take care of other things? :)

thanks!

Damien Pobel

Monday 30 May 2011 1:32:56 pm

Hi Carlos,

The current approach is to change the comments format by small steps when working on a specific file/class/method (see this commit for instance) but as always, you are free (and welcome ;-)) to open some pull requests on this topic (and/or any other ;-))

Cheers

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish

Bertrand Dunogier

Tuesday 31 May 2011 12:57:18 am

"

I don`t wanna use xdebug.... I am stuck with Zend Debugger :-)

So the doc should say should use a debugger.

"

Hehe, okay, I will make the title more generic, but Xdebug will still be recommended, as quite a lof of developers don't use a debugger at all, and we recommend Xdebug. Thanks ;-)

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Felix Woldt

Thursday 16 June 2011 2:55:19 am

Thank's for the standard.

I have a question about the the following convention:

"

>>

Files

Naming

Files MUST be named in lower-case, and MUST NOT use any separators (dashes, spaces,
underscores). PHP files MUST use the .php extension Template files MUST use the .tpl
extension.

>>

If i understood it right the following naming of a template is not allow anymore

because of "MUST NOT use any separator"

design/standard/override/templates/node/view/full/jac_folder_gallery.tpl

An other example you can see in github of our cjw_newsletter extension:

https://github.com/cjw-network/cjw_newsletter/tree/master/design/admin2/override/templates/node/view/full

or

https://github.com/cjw-network/cjw_newsletter/tree/master/design/admin2/templates

I don't think that this is a good idea. We heavily use underscores in tpl files to have a better overview / structure over the templates. The templates often have the same name as the related ez content class name s where you can use "underscores". The underscore is also used by ez in some php filenames e.g.

kernel/content/function_definition.php

or in a lot of tpl files

design/standard/templates/popup_pagelayout.tpl

 

My proposal is to change the text to:

"Files

Naming

Files MUST be named in lower-case, and MUST NOT use any separators (dashes, spaces) except
underscores. PHP files MUST use the .php extension Template files MUST use the .tpl
extension."

What do you think?

"

http://www.jac-systeme.de - Developers united in eZ Publish: http://www.cjw-network.com

CJW Newsletter 1.0.0 released: http://projects.ez.no/cjw_newsletter

Felix Woldt

Thursday 16 June 2011 5:34:06 am

Hi Bertrand,

what is about the coding standard for ez templates?

I think this should be included in the document, too.

http://www.jac-systeme.de - Developers united in eZ Publish: http://www.cjw-network.com

CJW Newsletter 1.0.0 released: http://projects.ez.no/cjw_newsletter

Donat Fritschy

Monday 20 June 2011 7:29:18 am

Hi Betrand

it seems to me that the heredoc exmple is misleading, as it WILL expand variables and such.

http://www.webmanufaktur.ch - Developers united in eZ Publish: http://www.cjw-network.com

Bertrand Dunogier

Wednesday 29 June 2011 6:59:45 am

"

I don`t wanna use xdebug.... I am stuck with Zend Debugger :-)

So the doc should say should use a debugger.

"

Made the paragraph more generic, thanks !

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Damien Pobel (eZ)

Thursday 28 July 2011 6:14:30 am

Those coding standard are on PHP code only, we should probably add some coding standards for HTML, CSS and above all JavaScript.

Cheers

You must be logged in to post messages in this topic!