RSS
 

OhHai->IHasASong()->ICanHasGenre()

03 Feb

Sometimes naming conventions can have weird side effects.

Consider this example:
Our tables and fields are named in CamelCase (or StudleyCaps, or StudleyCamels as we like to call them), this is not my preferred way of naming tables/fields, but it’s what we’ve got so we work with it. We* decided that Genres are entities so the Genres table contains a Genre field which is a VARCHAR.
In PHP we are using our own flavor of ORM that avoids the pitfalls of most ORM systems while keeping the benefits. Our database objects all have Get methods for each object property (which may or may not be a field in the table that the object represents). If you want a song’s Genre, you call Song->GetGenre(), which gives you a Genre object. If you then want the text-representation of the Genre, you have to call…GetGenre(). So if you want, from the Song object, the text representation of the Song’s Genre, you call: Song->GetGenre()->GetGenre()
We might as well have made it say Song->GetGenre()->PrettyPlease() or ->NoSeriously()

At least we aren’t writing our code lolcats style (see: lolcode) or it might look more like the title:
OhHai->I->HasASong()->CanHasGenre()->CanHasGenreNoowwwwwwws()

*actually someone else decided before I ever started working here

Kthxbye.

 
3 Comments

Posted in Coding

 

Leave a Reply

 

 
  1. Skyler Slade

    February 3, 2008 at 5:10 pm

    If you’re alluding to me in “*actually someone else,” no that wasn’t me. That was decided before I was here, by a guy named Evan who, as far as I know, didn’t do anything other than create a non-standard database schema. I never saw him do any dev work; he was in marketing. He created the schema maybe around a month or two before I came on, and he left Grooveshark a month or two after that.

    But the odd naming convention has grown on me now, and I sort of like it :-p

     
  2. Jay

    February 3, 2008 at 5:31 pm

    Haha, if I was picking on you I would have linked to you when I said actually someone else. I didn’t know who it was, but it sounds like you have some material for a post about why marketing people shouldn’t be allowed to do dev. :P

     
  3. Jay

    February 3, 2008 at 5:32 pm

    Omgwtf, time to learn how to turn off emoticons.