MVC WTF?

mvc wtf?
As a freelance developer, inheriting and working with code I did not originally write is common place. More often than not, code written using a known framework results in perfectly readable code, easy enough to work with and extend. Granted, every project is not written in Laravel 5, but the code that I inherit is workable.

When I recently inherited a complicated CodeIgniter site I was (initially) confident I’d have a good base to extend and work with. How wrong I was I? I could literally write a book about why the project I inherited was so bad. For the sake of brevity, I’ll stick to the main issues.

This post proves a single statement. Code written using a framework, is not necessarily “good”. It can end up painfully awful. In retrospect, I would have preferred to inherit a WordPress site. At least then my expectations are low to begin with 🙂

Continue reading MVC WTF?

The Video Js API – Referencing Video Objects

video js api
After using the excellent VideoJs HTML5 video player today, I thought a small article regarding improving site performance for video heavy websites was in order. The site in question is a project I inherited from a very large agency. The site was an internal application (so no need to worry about video SEO). By correctly referencing the VideoJS object through the Video Js API and displaying videos dynamically through JavaScript the site in question loaded faster and is more flexible for future updates.

The current site output the video HTML (36 video DOM elements nonetheless!) directly onto the webpage, as below. Dummy data has been used, a silly mammoth JavaScript closure and additional video setup options are omitted for the sake of brevity/sanity:
Continue reading The Video Js API – Referencing Video Objects

An Unexpected Selling Point …

angry-customerThis morning, I was part of a fairly normal client meeting discussing potential new work. The client started to discuss about what constitutes a good and bad service in relation to web development. In a similar fashion to lots of customers I encounter, they all have their own horror story of working with another developer or agency. This client was no different in that respect. The client had issues with work not being completed and promised missed deadlines in the past.

Continue reading An Unexpected Selling Point …

Bower – A Front End Package Manager Tutorial

bower tutorialRecently, I’ve been looking for ways to streamline and improve my workflow with frontend assets. This is the first article in a mini series, where I’ll be explaining my updated workflow with Bower and GruntJS. Part one covers Bower, a package manager for frontend assets and packages – this article is short Bower tutorial for the uninitiated.

Bower is comparable to Composer (a dependency manager for PHP), except for frontend assets. This is great news for any project as Bower allows for stress free management, tracking, finding and updating of all frontend assets for a project.

Previously, you may have manually copied in an updated version of say Twitter Bootsrap or JQuery into a skeleton project, or even have left and older version that has been blindly copied over. Even in medium sized projects, this process of manually setting up each package quickly becomes tiresome. Checking the version, downloading the package, updating references to any changed files etc. Instead, let Bower take away this work.
Continue reading Bower – A Front End Package Manager Tutorial

Microsoft Drop Support for Dated Versions of Internet Explorer

Drop Support - Dated IE

Web Developers & Designers alike can rejoice! As of 12th January 2016 Microsoft will no longer provide security patches and updates to dated versions of Internet Explorer. In an official announcement, Microsoft said:

.. only the most recent version of Internet Explorer available for a supported operating system will receive technical support and security updates.

Continue reading Microsoft Drop Support for Dated Versions of Internet Explorer

HotelHippo.com – Really?

hotelhippo-insecure

Recently, the latest website security saga in the news has been Hotelhippo.com. I won’t try and top Scott Helme’s article as he does an excellent job at explaining the saga in exhaustive detail, along with the other glaring issues he discovered. There’s another great article by Neil Stud that is definitely worth a read too. However, I’ll be covering the issue purely from a web development perspective, because as a developer myself, I find the whole situation scary/insane.

The issue I will be covering concerns an error that any web developer, even a junior, cannot excuse – the ability to change query string data and view private information without authentication. A site as big as Hotel Hippo and one that that stores a lot of personal customer information should frankly, be ashamed of themselves for such a basic breach.

Continue reading HotelHippo.com – Really?

Laravel 4 IoC – Bindings and the Application Instance

laravel 4 logoAt a recent business networking event I got talking to another web developer, who has just started using Laravel 4. We got chatting about Laravel in general and how awesome it is.Of course, the subject of IoC cropped up. The other developer commented on IoC, saying, “you need to be really careful with the IoC and passing an instance of the $app into the closure for performance reasons, the $app shouldn’t really be passed through at all ideally”. His argument also focused upon the fact that injecting the “Laravel 4 Facades” (config/app.php line 151) into controllers as it is faster.

Personally, I think he’d missed the point of IoC here. The only point he does have at a push, I assume, is if the object doesn’t need an instance of the $app, then don’t pass it through the closure – but that’s pretty obvious?

Continue reading Laravel 4 IoC – Bindings and the Application Instance

Mailcatcher & Laravel 4 – Sending Development Emails

During application development sending test emails can usually be a pain, even when using a modern frmaework like the excellent Laravel 4. During development it is very desirable to debug emails without actually sending them.There are a few options I’ve come across:

  1. Use Laravel 4’s Mail pretend feature. Simply set the configuration key “pretend” to true in app/config/mail.php. Laravel will now not send emails, instead write the content of each email to the application log
  2. Manually change the “to” email to your own so emails are delivered to your favourite email client – again, messy if sending lots of emails and if you ever made a mistake
  3. Print out the email data directly to the screen, but don’t send the actual email – the worst solution in my opinion

Options 2 and 3 are particularly fraught with issues. For instance, assume the application was to send out 1000 member renewal reminders and during development the route that sends out the emails was hit. Very soon, we’d have some very real (and confused, annoyed etc.) customers contacting you – disaster!

Continue reading Mailcatcher & Laravel 4 – Sending Development Emails

Route Patterns in Laravel 4

When using the excellent Laravel 4, writing DRY and SOLID code is something you’re well aware of. Unfortunately, it’s common for the routes file to get messy and repetitive as an application grows – enter the route pattern method. Even worse (in my opinion) is performing basic and repetitive validation of parameters in controllers.

Consider a routes file that responds to 4 simple URIs:

Continue reading Route Patterns in Laravel 4

SSH Access & Heart Internet, oh my …

ssh access heartinternetSSH, or Secure Shell is something any web developer will have come across. Personally, every single website I deploy involves SSH where I’ll upload and extract a single compressed archive. This is simply good practice and most importantly, much faster than normal FTP. There are a plethora of further benefits in having SSH access – I won’t go into these here though. However, as common a feature as SSH access is, gaining SSH Access on a Heart Internet hosting account surprisingly, turns out to be pretty darn hard to get.
Continue reading SSH Access & Heart Internet, oh my …