Tips for clients when choosing a web development company

A while back I wrote a post about tips for freelancers …

http://www.jamesbarnsley.com/site/2016/11/27/tips-for-freelancers/

My goal at the time was to later write an article on tips for clients choosing a web development company. I thought at the time this would be a straightforward article to write but the more I thought about it the less straightforward it become.

Some typical indicators to decide whether a company is worth choosing could be as follows, How many employees does the company have? Are the companies premises any good? How long the company has been in business? Does the company have a decent looking website?

The majority of the above indicators are really indicators as to how well the business is doing. A lot of people will except that if the final product looks and feels right and it works then they are happy with the final product. With a large number of people accepting this as the basic premise most businesses can survive for a long time on this premise.

So what is it I am getting at here? In short, it is the underlying code powering the web development project. It is this area that as the client you will have no ability to judge without programming experience.

Neither did any of the previous clients of the long standing businesses, so the business may be big, the business may have been around for a long while but this does not mean that either you or the previous clients ever got a good product in terms of the code powering the web development project.

How the product looks and to some extent whether the product works or not is merely a coat of paint over the real engine powering the web development product.

A Ford car can look and work right, a Rolls Royce car can look and work right but both have huge differences in the price tag. How do you know whether you are getting a Ford or a Rolls Royce? The quality of the components? In a web development project whilst some of the components may stand out such as the design, some of the components do not stand out i.e. the code.

This article has been born from observing different web development projects with different qualities of code being sold at vastly different prices. The higher priced projects do not nessacarily equate to higher quality code although the project may be of a better quality in other areas.

As a client how can you ensure you are getting quality code? I have thought about this and I am not sure there really is an answer. You could get a programmer contact or external company to inspect the code but then how can you be sure that the external company is any good at programming code, especially since the same applies to the external company which applies to the primary company?

Conclusion
As a client without programming experience maybe it should be excepted that if the company can produce a product which “looks good” and “works right” then the company is acceptable. The quality of the code is hard to determine for the general client and getting the code verified by a third party simply means you have transfered the trust from the primary company to the external company.

Yii 1 to Yii 2 differences and enhancements part 1

A number of months ago I made the switch to the Yii 2 framework from the Yii 1 framework. My intent in this post is to outline some of the differences and enhancements I have found from switching to the latest Yii framework.

A framework is a set of code written to help in common programming tasks for example handling data, creating forms and data tables etc.

When I first started programming I did not use a framework as I did not understand the benefits properly of using a framework. The above tasks would have been written from scratch and would have essentially duplicated code that was already out there for solving these common tasks.

When I first started using a framework it made my life much easier and the end product was of a better quality to time ratio than not using a framework. The same quality could be achieved without the use of a framework but would take longer and the programmer would be essentially writing code for common problems that already have a solution.

I would also like to mention that frameworks provide a consistent structure to the code that a programmer writes so that one way of solving a problem at one end of the code would be the same way the problem was solved at another end of the code. This makes it easier for other programmers to understand the code base.

After using the Yii 2 framework here are some of the differences and enhancements that I have found …

User Identity

In Yii 1 a “User identity” is a class that extends “UserIdentity” and handles the authentication and identity of the logged in user. I would create a class that extends “UserIdentity” create some predefined methods and let Yii handle the authentication.

In Yii 2 a similar approach is used except I do not create an extended “UserIdentity” class but instead I “implement” “IdentityInterface” in my User class. In Yii 1 I would have a “UserIdentity” class and a “User” class, in Yii 2 I just have the “User” class. Similar to Yii 1 I create some predefined methods in my “User” class and let Yii handle the authentication.

Active Record

Active Record has some key differences going from the Yii 1 framework to the Yii 2 framework. In Yii 1 Active Record was used like so …

Or …

Or …

In Yii 2 Active Record is used as follows …

Or …

Or …

Basically in Yii 1 there where a lot of methods that where created for specific purposes “findAll”, “findByPK”, “findByAttributes”, “findAllByAttributes”, “deleteByPK”, “deleteAllByAttributes” etc.

Yii 2 can do all of the above purposes but the syntax is much more flexible in that it does not have methods for each purpose but flexible syntax that can be used for flexible purposes.

Also note how in Yii 1 I used array() and in Yii 2 I used []. That is because at the time of Yii 1 array() was the PHP syntax used for creating arrays and at the time of Yii 2 [] could also be used to create arrays. Not really a Yii issue but still the array syntax looks better in the more modern version of PHP.

Use

Due to the Yii 2 framework being written at a time when the version of PHP was later and more modern the Yii 2 framework has made extensive use of the “Use” statement and “Namespaces”. Yii 1 did not make use of these at all probably because they where not implemented in PHP at the time the Yii 1 framework was written.

Nevertheless I feel the “Use” statement and “Namespaces” give the code a more professional feel and it means that the code is only made use of when the code is needed.

I will be updating the blog with more articles on Yii 1 to Yii 2 differences and enhancements as I go a long. I already have plenty of differences lined up but I will be saving them for the next article in this series.

PHP exceptions, try, catch not working

I was porting over some code a few days ago from a standard standalone PHP script I had written some time ago. I was wanting to use the code inside a larger new web application I was building for personal use.

I was absolutely certain I had copied all of the code line by line into the new program and refactoring it as I went along making sure I did not do anything to break anything.

Everything seemed perfect until I came to run the code and was left baffled by “Uncaught exception” PHP error messages. These error messages did not occur all of the time but only some of the time which made debugging worse.

However due to the nature of the functionality of the code was to be expected as their were aspects of the code that were dependent on an outside source and could be variable.

So I looked through my code and all of the try / catch statements were there and the exceptions as far as the code was concerned should have been handled correctly. I had reached a block that I could not get past, at least for a couple of hours.

After doing some research on Google the answer came to me. I had written my try / catch statements as follows …

The problem was due to name-spacing of the application I was porting the code into. The old standalone PHP script did not use any name-spacing so this was never a problem. The new PHP application did use name-spacing so the try / catch code needed to be written like so …

Notice the “\” symbol. That would be telling the Exception to escape to the global space. After adding these corrections to the code it worked perfectly.

TTS Engine turn off page listen

Recently I installed a WordPress plugin called TTS Engine. TTS Engine allows readers / users of the website to listen to the content of posts and pages. This is all good but some website owners may not want the user to be able to listen to pages but only posts.

I personally thought the “listen button” looked silly on the pages and I only wanted it to appear on the blog posts.

At the time of me writing this there is no setting in TTS Engine to turn off the listen for pages and have it only display on posts. To solve this problem I set about customizing the TTS Engine code to not show the listen button on pages.

To accomplish this I added the following code …

Right above the following code comment …

In the “tts-engine-post-to-speech/tts-engine.php” file. To access the file click Plugins -> Editor in the WordPress admin menu.

Thought I would share this with the world in case anybody else wanted to turn off page listening after installing the TTS Engine plugin.

Update: I no longer use this plugin on my website but the code presented in this article will still work if you decide to install the plugin.