Category: Development

  • Setting Up CakePHP with IIS

    I’ve found myself doing this several times over the past little while as I had to switch computers.  Each time I would struggle with a few of the steps, so I thought I would document them this time and share for future me (or you if you like).

    (more…)

  • What Do You Care Most About When Reviewing Someone Else’s Code?

    I wrote an article a few months ago called Compelling Interview Questions where buried deep in the middle under several open-ended technical questions I asked the question “What Do You Care Most About When Reviewing Someone Else’s Code?”

    The funny part about this when you read a few lines below I follow it up with I’m not looking for anything in particular; just some generic catch-phrases that most people throw out there.  E.g. properly indented code, no large comment blocks, documentation to explain a complex block of code, etc…

    Ask me today what I expect from this question and my answer is totally different!  Today being as I write this article – ask me in the present and let’s see if my answer changes…

    (more…)

  • Implementing the Repository Pattern with CakePHP

    I must admit, my recent articles are becoming a bit obsessed around the repository pattern.  What can I say, I like it, it’s useful, and it’s not restrictive based on a language or a framework.

    I’ve long professed how I dislike convoluted controllers.  CakePHP’s find method almost immediately causes this when used inside a controller.  More importantly, the code inside the find method is extremely unreadable.  This is almost more important than a large controller function!

    This is where the repository pattern comes in.  At its most basic example (which some will consider overkill – you know who you are), I still think the repository pattern is clearer.

    Here is an example using the regular find approach:

    [code]
    $user = $this->User->find('first', array('conditions' => array('id' => $id)));
    [/code]

    Compared to a repository example:

    [code]
    $user = $this->UserRepository->GetById($id);
    [/code]

    The code is almost identically; however, in the second example, it’s clear that if I were to “read” the code I am retrieving a user by id opposed to I’m finding the first user with the conditions of id being equal to the variable $id.

    So if you are sold, let’s continue with a full suite example…

    (more…)

  • My Favorite Thing About Coldfusion

    I’ll be honest; I have not written a line of Coldfusion in over 5 years.  It was one of the first languages I used professionally, I must emphasize that it wasn’t personally!

    But when I was regularly using it there was one function that I miss and wish was in other languages.  That function is cfchart!

    P.S. yes this is really off topic, but after I got a LinkedIn message about a Coldfusion developer, it made me think back to my beginning days of development.

    (more…)

  • Automapper Performance Testing

    I hate typing more lines of code then I need to; especially something as simple as mapping a domain model to a view model.  Enter Automapper!

    By performing a one-liner: [code] Mapper.Map<Customer, CustomerViewItem>(customer);[/code] I can quickly map my domain models to my view models.

    I was recently reviewing an old article on CodeProject: http://www.codeproject.com/Articles/61629/AutoMapper that contains a quick and easy demo.  Inside this article, it discusses performance and it indicates that Automapper is 7 times slower than manual mapping.  This test was done on 100,000 records and I must say I was shocked.

    My first thought is this requires more testing.  Especially since 100,000 records is a lot.  In most scenarios I would estimate my largest mapping might be 1,000, but even 1 would probably be a very regular use-case.  Let’s put it to the test…

    (more…)