Naming Conventions for Large Scale Projects

Status
Not open for further replies.

LazyD

$monies = false;
Dec 7, 2006
655
12
0
Wine Cuntry
wildfoxmedia.com
Im curious to hear peopels input on how they handle naming conventions for things like HTML IDs, Classes, etc. As well as function names for PHP and Javascript.. Im working on a large scale project and finding myself tripping over certain names and such...
 


The old ones are always the best, Camel case, typeVariable and actually taking some thought into how you name classes rather than MotherFuckPostIt.class.php
thumbs.gif
 
KISS baby......just KISS.........

Only make 1 magic class across all sites:

Code:
Class UberObject {

      
      public function DoIt(string $doWhat, array $withWhat) {

                switch ($doWhat) {
                      case 'Login': 
                              $user = $withWhat[0];
                              $pass = $withWhat[1];
                              ..........ultra proprietary business logic goes here......
                              break;
                      case 'CreateUser': 
                              $user = $withWhat[0];
                              $firstName = $withWhat[1];
                              $lastName = $withWhat[2];
                              ..........ultra proprietary business logic goes here......
                              break;
                      (your custom business logic can go here.....have fun!)
                 }
      }

}
Database is a more of the same. Keep it simple. Keep it beautiful. 1 Table:

ID int primary key;
ObjectType varchar;
ObjectSerialized Longtext;

The magic here is that you can store any object in the table, and you only need 1 table.





This solution is the holy grail in the ultimate quest for refactored code. Consultants around the country are charging big bucks to spread such joy across large enterprises.
 
Screw it............i'm gonna give you something for free........a colleague mentioned that querying the above table for a specific object, say a specific person by their name, would be impossible. Nah, I say........just select all where objectType = 'Person' and deserialize each row and check for matches. However, I have quickly discovered this gem of a solution:

ID int primary key;
ObjectType varchar;
ObjectSerialized Longtext;
IndexColumn1Name varchar;
IndexColumn1Value varchar;
IndexColumn2Name varchar;
IndexColumn2Value varchar;

Now you can dynamically query for not 1, but TWO custom values of your own choosing. Want to select Billy Booger from your table............


Select ObjectSerialized from ObjectTable where ObjectType = 'Person' and 'IndexColumn1Name' = 'person.firstName' and 'IndexColumn1Value' = 'Billy' and 'IndexColumn2Name' = 'person.lastName' and 'IndexColumn2Value' = 'Booger'


Viola!!!

Hello Billy Booger.......Bye Bye complex code!!!
 
As much fun as that looks...

This is something where im working with other programmers, using the Cake framework. Im talking general naming conventions, not uber proprietary functions...
 
??

You might want to look into Hungarian Notation, but I think it is a bitch to work with (and a lot of programmers agree).

Some things that helped me in the past:

a) Talking names - Name that variable, calss, etc something useful. SO no "DoIt" Class, rather "DBConnector" or "ContentWriter"

b) some cvonventions regarding capitalization and such. For example we had ALL UPPERCASE names in XML tags and all lowercase in HTML tags doing XSLT processing projects. So it would look like:

Code:
<xls:for-each select="MYCHILDNODE">
  <p>
    <xsl:value-of select=".mytext"/>
  </p>
</xsl:for-each>
My xsl is rusty, so this will probably not even look like working code.. :error:

Stuff like that, just think about it as you go along, trip over something three times, agree on a rule. Most of the time it is just a matter of the team agreeing on following some guidelines.

::emp::
 
On a serious note....

If you look at some of the more popular open source projects, such as apache, etc.........

They usually include coding guidelines/standards to follow if you are interested in contributing code. I've found that these guides are a good place to start researching.
 
If you're implementing naming functions, you should ideally feel like you are doing an annoying ass homework assignment. While its a pain in the ass to make actual legit Visio diagrams and 'conventions' and plan shit.. they actually come in use down the line.

My answer: make a UML diagram. I'm doing that right now for my software engineering class. Annoying as shit but you gotta admit its useful.
 
Status
Not open for further replies.