Re: Gallery's K3 class name/dir/file conventions (was "Capitalization")

Bharat Mediratta <[email protected]> Wed, 20 Mar 2013 16:30:58 -0700
Newsgroups gmane.comp.web.gallery.devel
Message-ID <CAESa+_=pBx-PRb2nX9AgWf4T_nTX3QRUnAS7tG8yFKzG1YKdsw@mail.gmail.com>
On Wed, Mar 20, 2013 at 4:16 PM, Shad Laws <shad-xpYdmXCiSuZWk0Htik3J/[email protected]> wrote:

> Hey Bharat,
>
> So, here's my pass at it.  Tag 3.0.x has 17 class files, and
> correspondingly Tag 3.1.x has 17 class files and 17 extension files (34
> total).
>
> tag
> |-- classes
> |   |-- Controller
> |   |   |-- Admin
> |   |   |   `-- Tags.php
> |   |   |-- Tag.php
> |   |   |-- TagName.php
> |   |   `-- Tags.php
> |   |-- Model
> |   |   `-- Tag.php
> |   |-- Tag                   (**1**)
> |   |   |-- Controller
> |   |   |   |-- Admin
> |   |   |   |   `-- Tags.php
> |   |   |   |-- Tag.php
> |   |   |   |-- TagName.php
> |   |   |   `-- Tags.php
> |   |   |-- Model
> |   |   |   `-- Tag.php
>  |   |   |-- Tag.php
> |   |   |-- TagBlock.php      (**2**)
> |   |   |-- TagEvent.php
> |   |   |-- TagInstaller.php
> |   |   |-- TagRest
>

So you did TagRest here instead of Tag/Rest- this was inconsistent in mine.


> |   |   |   |-- Item.php
> |   |   |   |-- ItemTags.php
> |   |   |   |-- Items.php
> |   |   |   `-- Tags.php
>

You're missing a few rest handlers, but that's just an artifact of the
modelling I assume.


> |   |   |-- TagRest.php
> |   |   |-- TagRss.php
> |   |   |-- TagTask.php
> |   |   `-- TagTheme.php
> |   |-- Tag.php
> |   |-- TagBlock.php
> |   |-- TagEvent.php
> |   |-- TagInstaller.php
> |   |-- TagRest
> |   |   |-- Item.php
>  |   |   |-- Items.php
> |   |   `-- Tags.php
> |   |-- TagRest.php
> |   |-- TagRss.php
> |   |-- TagTask.php
> |   `-- TagTheme.php
> |-- media
>  |   `-- tag.css
> |-- module.info
>  |-- tests
> |   |-- Tag_Item_Rest_Test.php
> |   |-- Tag_Rest_Test.php
> |   |-- Tag_Test.php
> |   `-- Tags_Rest_Test.php
> `-- views
>     |-- admin
>     |   `-- tags.html.php
>     `-- tag
>         |-- block.html.php
>         `-- cloud.html.php
>
> Notes (as annotated above)
> 1. All actual class code goes in this directory, and all thin
> extension-enabling files are outside it.  This makes it easy to browse
> code, as you can navigate straight here and ignore everything else.  Also,
> note that the *exact* name of this directory is not super important,
> provided that all the classes inside it follow its name (and that it
> doesn't set a precedent for other devs that ends up causing name
> collisions).
>

Agreed.


>
> 2. It's for these files that the exact name "Tag" is important, as Gallery
> needs to know to look for TagEvent instead of TAGEvent.  So, we can add a
> line to module.info.  BTW, I'm starting to come around to the
> little-endian way, as alphabetizing them groups them together.  Of course,
> there are other options, too: they could be Tag_Event (which extends
> Tag_Tag_Event), Module_TagEvent (which extends Tag_Module_TagEvent), etc.,
> but I'm inclined to think the simplest one is just TagEvent (which extends
> Tag_TagEvent).
>

PHP is case insensitive when it comes to class names so "new TagEvent",
"new TAGEvent" and "new tagEvent" are all the same.  But when it comes to
filenames this will be a problem.   But again, we can easily fix that with
an opinionated framework.  Our opinion will be that your module directory
name (which is your module id) is exactly the same as your prefix.

Here are some example of module directory names and the corresponding file
in which we'd look for their event handler:

  modules/Tag/classes/TagEvent.php
  modules/PDF/classes/PDFEvent.php
  modules/foo/classes/fooEvent.php

Agreed?  If you agree with that then I think we are now in perfect
agreement.

-Bharat

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar

__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]