Cherokee vs Apache : An alternative web server

As I have been developing for the web for over a decade, I have become comfortable with tools and technologies which have helped me get the job done. Some of these technologies I have seen evolve and progress into what are now essential and very powerful solutions. I have established an affinity with many of these tools and without doubt the Apache web server qualifies as such a technology for me.

Using Apache over the years as my main web server, I have produced all types of software solutions for many diverse businesses within many different industries.  Apache has served me well and I am an advocate of the old saying ‘If it’s not broken, why fix it’ (within reason). Until recently that is….

Over the past few years in the distant background I have heard mention of Cherokee as being a viable alternative to Apache, with some claiming it offers benefits. These have been whispers registering in the distance, but didn’t sound interesting enough to pursue and invest my time as Apache was doing it’s job well. However recently these whispers became a little louder following a few conversations with a work colleague singing Cherokee’s praises. What caught my attention most from the conversations wasn’t simply that Cherokee was faster, but that Cherokee was much easier to use and quicker to configure. As I don’t like ‘shaving Yaks‘, my approach was that if I start hitting obstacles, I’ll leave it for another day which contains more than 24 hours; after all Apache is working well for me.

My local lightweight development environment consists of a Linux VM (Fedora) which I operate using VirtualBox. I deliberately reduce my VM’s resource allocation such as setting my RAM allocation to 512mb on my VM to encourage good code and to identify memory leaks. I have the other usual stuff setup such as Zend Framework, xdebug, MySQL etc. This was the machine which was going to carry out the test switch from my trusted Apache to Cherokee.

I disabled Apache and installed Cherokee using the supporting well written user guide. Within minutes Cherokee was up and running and there we NO problems! I was expecting some configuration hurdles as per usual, but nothing. My sites were running as if I was on Apache and there were no noticeable differences. I configured the logs to act as the same as Apache and all was set.

As I delved deeper into the setup guide I was pleasantly introduced to Cherokee’s administration interface. This was a pleasant surprise as I’m so used to hard coding configuration information into httpd.conf. This interface presents configuration options for all the usual server settings such as ‘Virtual Servers’, ‘Directory Sources’, ‘Logging’, ‘Security’ etc. The beauty of this is not that it’s simply a little prettier than the command prompt, but it’s quicker to use. You can configure your server settings simply and quickly which are two good properties to have on your side.

Although I was impressed so far, the remaining challenge that Cherokee must live up to for me is it’s speed advantages. In the spirit of keeping things simple and to get a loose overview on performance advantages I thought I’d simply use ‘Zend Controller’ which is bundled with ‘Zend Server CE‘ to test how many requests per second both Apache and Cherokee could handle in turn upon my humble local virtual machine. From these tests I obtained the following results :

Apache Web Server Results

Zend Controller testing Apache requests per second

Apache requests per second on local VM

Cherokee Web Server Results

Cherokee web server

Cherokee requests per second on local VM

As you can imagine I was quite impressed with what the results presented. The results roughly show that Cherokee could handle 2.5 times more requests per second that Apache! That is no small margin!

What does this mean for me going forward? Well the first things that went through my mind understandably were cost and time savings. Potentially this could reduce the need for more hardware. Less hardware means less purchase costs and less maintenance time. Obviously there are other factors to consider before jumping the gun, but Cherokee certainly has my attention now. I will definitely be including Cherokee in my future plans. An exercise well worth the time.

If anyone reading this has done the switch, please feel free to reply to this post with any feedback

Related Link : alobbs.com

, , , , , , , , , , ,

3 Comments

Why buy an iPad and where does it fit in to the market place ?

Finally the long awaited iPad has has been released. For quite some time people had speculated what the device was going to be and what it would be capable of. This has been followed by some passionate underlying debates for what it should and needs to be for consumers. Well the device has been released, which has been met predictably by a mixed reception with continued debate. Following such debates, the key point of confusion standing out is people are unsure where an iPad fit’s into their lifestyle. This is the question I am trying answer from my own perspective and lifestyle, suggesting where an iPad would mainly suit me.

iPad doesn't replace PC's or smart phones

iPad doesn't replace PC's or smart phones

Being a Software Developer/IT Manager by profession I have pretty much access to a computer/device of some description most places I visit on a day to day basis. I currently use a ‘G1 Android phone’, have a ‘macbook’ for working on the move, iMac at home, and have a Vista machine at work, not to mention access to several remote linux servers holding my information. I also have an xbox360 which is linked to my media linked to the TV. With all these devices around me where would an iPad fit in and why would I want one?

To understand where an iPad would fit into my lifestyle, I have to look at my daily patterns and highlight where I waste time with a little ‘lean’ thinking. Pretty much most of the day I’m in front of a computer and I clearly don’t see and iPad as a suitable replacement/substitute for what I use these devices for. When relaxing in front of the TV, listening to music via the xbox360 and iMac, I don’t see and iPad offering anything against these devices. I certainly don’t want a 10 inch device to replace my mobile phone unless I was aiming to block out the sun. So what gap is leftwithin my daily lifestyle pattern?

Well looking at my daily patterns I quickly identified somewhere where I am wasting time which could be improved. As part of my day, I regular attend Scrum meetings, meetings with 3rd parties, and am often called for quick consultation from various parts of the business. Most of the time these can be quick meetings lasting no longer than 10-20 minutes. When called for any of these tasks, I find myself picking up my A4 notepad, rushing into a room and writing notes. Most of the time I then type up key points of the meeting on my PC. Sometimes however with interruptions I miss the odd one or two and end up being chased up by others where I have to then play catch up. For me, this is where I see an iPad fitting into my lifestyle.

If I could turn to the iPad rather than an A4 notepad this would mean I could take more information everywhere, makes notes once and most importantly of all for me is to free up my time. An iPad offers 10 hours of battery life and can stay on standby for a month! It is small, lightweight and quick to turn on and off which makes it a perfect fit to replace my A4 notepad replacement. I can make notes and pass it around the room with others to share information such as diagrams, images or notes, as easily as passing around sheets of paper. I have a macbook, but there is no way I could get it to fill this gap like an iPad could, otherwise believe me I would be already doing it. It’s overkill, less mobile, slower to turn on and involves launching full blown software packages. This is enough to say no and the A4 notepad has won every time. On the same note where I would use my macbook and smartphone, an iPad wouldn’t be a replacement for these. My macbook is good at being a macbook and provides me with the ability to have a mobile computer for developing code, running VM’s etc. My smartphone is too much of a compromise with such a small screen. Therefore I’m very glad Apple decided to make the iPad exactly what it is without a full OS trying to compete with the notebook/laptop devices. A purposeful and simple solution to fill an obvious gap in the market.

There are other obvious uses where the iPad would be a benefit and that is on the commute. I used to travel to work by train carrying at least one magazine, a book and a macbook every day. An iPad would have meant I could just carry a macbook with it, reducing the weight and giving me the ability to carry much more reading material. I don’t see the point spending on an ebook reader now when and iPad is just a bit more money for a lot more value in return. I could just pull out at any time to fill the short, but sometimes very long gaps between train journeys. If the train is 10-15 minutes late, I’m not going to boot up a macbook and find a place to sit on a very over crowded platform.

iPad replaces notebooks and ebook readers

iPad replaces notebooks and ebook readers

Obviously my viewpoint above is selfish to my lifestyle. Who else could use an iPad ? Well looking at my circle of friends and family, unlike me most of them are not tech people. However, they all have computers and laptops and I know this as usually I’m contacted at some point if they run into problems. Looking at their use it tends to be mostly shopping online, social networking, emails and sharing photos. Most of them also seem to be intimidated and frustrated with their computers to various degrees. They look boring and a computer probably reminds them of the office they just left in the day. For these users an iPad could be a good option as it’s cheap ‘ish’, simple, secure and most of all friendly. It’s a device that can sit on the coffee table and be picked up and used anytime just like a magazine. For less tech savvy users this is far more inviting to use and therefore likely to get more use. This is why I’m glad they made it more like an iPhone than a notebook. It makes much more sense for this device to be app based and would be much more attractive to already proficient iPhone users.

I’m sure it won’t be long before we see Google responding with a slate device offering Android, not ChromeOS.

, , , , , , , , , , ,

No Comments

Scrum Teams – Lean, Mean developing machine

In the past few years I have read about Scrum, Agile and watched many a tutorials and short videos on the benefits and how to implement it in the work place. After watching from a far I managed to get my hands dirty and get involved with applying it in the workplace. Over a period of many months, bit by bit we have implemented it into our development environment. I have to say it hasn’t been easy and it’s only possible with support from the business in my opinion. Developers and testers were the first to welcome the change as it empowered them and gives them recognition for their efforts as well as control. The business took longer as the change is drastic and involves them a great deal more in product development. However once involved, the agility and development speed and project transparency becomes something recognisable and desired.

During this implementation a common emphasis raised via many sources is to keep the teams small and focussed. Many comparisons have gone through my mind, including why and how to select certain people and create teams. One of the best comparisons and inspirations to make sense of this is to compare the military structure. The comparison that strikes me is that traditional waterfall teams which consist of large scaled divisions that progress in linear fashions with a great deal of resources and structure. They take a great deal of planning, authorisation and strategy to get momentum. When the momentum has started, it’s difficult to stop and change direction. These can be compared to a military invasion, invading in stages as one large force following months of planning and financial investment all moving towards a strategic location in mass. Scrum teams to me represent a different dimension to this, I see scrum teams as small, more precise well equipped units similar to special forces. Smaller teams which are empowered, focused and take more control over their missions who often find themselves more capable and agile. They can be deployed into many different environments, are quicker to adapt and are in and out of missions quickly, sharply getting maximum results.

Special Forces Scrum Development Teams

Like special forces, scrum teams are best kept small and varied. Many sources suggest that a team should consist of no more than 8 people to keep the team dynamic and I agree with that. Anything more and like most larger groups, you risk losing communication and focus.

When you have the balance in place and the team become used to this way of working, the business will benefit and get results. Results which require less investment over time and able to see the impact and return of having small, specialist teams. After all, we have all seen renditions of the battle of Thermopylae, which is basically a tale of a small force with superior weapons, training and passion taking on the might of an army. Although not a direct comparison I think there are similarities in structure do compare in very distant kind of way. The strategy depends upon the business’s plans and objectives, but ultimately every business wants to get more from it’s resources and wants to be able to be quick to respond to environmental conditions to stay ahead of the game.


, , , , ,

4 Comments

Common Misconceptions of PHP

As we have just rolled over to 2010 I thought I would compile a list of 4 common questions often raised against PHP from people within the IT industry (no particular user groups). Each of these 4 statements were mentioned to me within 2009, but stem back many years in some cases. Some of these questions demonstrate plain ignorance in some cases, others just a little confusion as a result of lack of understanding or exposure. Therefore I hope this contributes to clearing up some obvious misconceptions by my provision of some brief answers.

  1. PHP is not a secure language
  2. Believe it or not this was stated to me by a highly ranked person within the development community. I was very surprised that such a statement was put forward considering PHP is a scripting language and security is not a definitive answer, but an on going process in which every facet of IT must undergo constantly to remain secure. To clarify this is a case of blaming poor workmanship on the tools. Although some tools are better than others, in no way do I believe this statement to be true. PHP can be as strong as the best of them in terms of security and some of the worlds most secure systems including many systems of the financial services industry as an example which hold vast amount of sensitive information can be found to be written using PHP. When using a tool to build something, the end result is that of the craftsman effort, ability, knowledge and experience. Keeping the argument of operating system security out of this which would be hosting PHP, to obtain security you need good, experienced and security aware developers. I personally believe this misconception often raises it’s head because of other languages restrict development to the framework or coding environment and developers within these environments don’t have to confront some areas of security as a result of this. I don’t think it’s good for developers to rely upon security being dealt with away from their application by making it someone or something else’s responsibility. A good craftsman will make it their job to be aware of system security and test their application before release as well as include continuous monitoring and alerting tools to support the application. Obviously there are those which specialise in such areas and their knowledge should be referred to in times of doubt or curiosity via supporting texts and communities. PHP is as secure as the developer’s knowledge and testing/release procedure involved with it as with most other languages.

  3. PHP doesn’t have good support for OOP
  4. I’m surprised that some people still think this. Before the release of PHP5 including the Zend 2 Engine, which was 13/07/2004 this would have been true. However please keep up people, we are in 2010 now and OOP support for PHP has been in place for over 5 years! I haven’t written procedural code for years with the exception of the odd testing script and procedure. There are great libraries available as well for those looking to extend OOP ability including such libraries as SPL, PECL, PEAR to name but a few. There are also some very fast moving and powerful frameworks available fully supporting OOP including such Frameworks as Zend Framework, Symfony, CakePHP, Codeigniter. These are also become very popular and demand for such frameworks from the workplace is rapidly increasing (see my other post).

  5. PHP is slow
  6. Yes believe it or not I have heard people claim this. PHP is pretty damn fast as a scripting language written in C. If people say PHP is slow, I don’t believe the have looked at the problem or debugged their code well enough. There are so many factors that influence speed such as the OS, memory, debug code, logging scripts, the implemented code, other applications on the server etc. If your PHP code is running slow, debug it and find the problem. It’s likely that the problem could sit with any of the above or it could be badly written code. There are good debug tools out there such as Xdebug which could save you some time finding the problem. Remember PHP is so versatile you can even extend it in C. If you are doing something very complex in PHP and by taking it down a layer might reduce some of the functions taking some time, you have the option to write an extension if needed. I personally have never had to do this, but have seen it done for a workplace specific extension and it worked perfectly and very quickly.

  7. PHP is an amateur language
  8. With full OOP support and factoring in that it’s one of if not the most widespread scripting language and as mentioned briefly in point 1 above, you can find PHP in almost all industries. Now I am not one to suggest the best technology is the most widespread (no names mentioned). However if PHP was a amateur language why is it so popular in so many professional industries which demand professional results. You can write pretty much anything you want using PHP and it can be as simple and complex as you want it to be. I have used Java quite a bit in the past and often find myself using the same code design texts to reference my PHP objects as my Java objects. I even apply the same design pattern sources for both languages. An example is the built in observer pattern interface in Java, (java.util.Observer) PHP also has this (SplObserver). Again I feel that stating that PHP is amateur is missing the point that PHP it’s a tool for the job. If amateurs use PHP you might get amateur results by the same token if professionals use it you get professional results, which is obviously the same as any other language.

Overall I think some of the questions or statements raised above are raised as a result of lack of understanding. As with most things in life some people scratch the surface of an area of interest and call themselves experts. The same experts make such judgements which create barriers for others. This could reading a text titled ‘Learn PHP in 24 hrs’ then calling oneself an experienced programmer or taking your driving test after a couple of lessons in a controlled environment and calling oneself an experienced driver confident enough to race with the likes of ‘Jenson Button’ and expect to win. Personally I have been using PHP for over a decade now and I am still learning new things everyday, particularly through exposure of different implementations. The language is moving fast with PHP6 arriving soon as well as many new and exciting related projects becoming available such as the array of frameworks which provide common interfaces to integrate with many different technologies. I would encourage anyone to look under the bonnet and get to know PHP in more depth and hopefully you will see the true power and capabilities of it.

, , , , , , , , , , ,

3 Comments

PHP and the demand for frameworks from businesses

Over the past few years PHP has matured somewhat. Object support continues to grow and more demands for advanced web based applications/software have began putting PHP into a light of it’s own. The once simple scripting language has matured into a powerful OO web scripting arsenal which when combined with the right environments can run with the best of them. Those who push pass the beginners  boundary and delve beyond the simple tutorials and basic functionality, use the versatile properties of PHP with good design and OO knowledge who progress, achieve and develop great things and have fun in the process also.

With PHP being applied in new ways and object support it was only a matter of time before there would be an explosion of frameworks on the scene. Not least with such popularity and community support, the Frameworks that are out there are diverse and offer different development facets which can present developers and businesses many advantages in order to build complete professional solutions. With more and more enterprises demanding more from the web, frameworks are becoming more in demand and as such are snowballing in their release cycles to offer a toolkit that many developers and few workplaces can ignore. Many including myself having used frameworks find it difficult to develop without them due to the benefits on offer such as reduced development time and reusable code libraries

As a result of this PHP developers are presented with many frameworks to choose from, which can be a mine field. Although most frameworks are similar offering MVC based designs, some are quite different and vary in depths, versatility and complexity. These aspects should be considered by the developer when choosing the right framework for the job. I would personally recommend trying a few out to see what similarities there are, what suits your needs and what you feel you can mature with. I have tried CakePHP, Symfony and Zend Framework resulting in predominantly the later choice as I feel it suits my requirements as a developer better.

When choosing a framework in my opinion you should not only consider the current state of the framework, but also the support, community and demand for the frameworks you are considering from the business world. If your going to invest time learning, implementing and possibly contributing to a framework, knowing the demand from businesses should be an important factor as this could enhance your career prospects. This demand in turn can help secure a frameworks future as it influences support, training, functionality  through corporate recognition.

To help recognise which frameworks are in demand from the job market, I have called in a few graphs of the more popular frameworks to see the differences of demand side by side. I found it interesting and I hope you do to:

Obviously these graphs don’t represent quality in any way, but they should provide a general overview of demands by employment. This can indicate relevance as in most cases (Not All), demand should reflect some the benefits on offer from the framework.

, , , , , , , , , , , ,

3 Comments

Woopra raises the bar for web statistics/analytics

I have been meaning to write a review on Woopra for some time, but wanted to try out Woopra for a while first to ensure I got more of an in depth experience whilst looking through the web statistics. It’s not easy for any stats package to get much attention with the likes of Google Analytics (which I currently use) to contend with, especially since most web statistics packages require the user to embed tracking code into sites which can impact page load times and is another stepping stone for integration. However I started to hear rumours there was a new kid in town by the name of Woopra and decided to give it a chance. I proceeded to set it up on this blog and another e-commerce site for a varied user base.

Live Statistics

One thing which stood out straight away using Woopra over other analytics packages was the ability to view live statistics from actual users on the site. I have to say I was a little pessimistic about this feature, having used similar features in the past. I was expecting, inaccurate details, delays and it being riddled with bot visits which would dilute the overall detail. To my surprise it was quite the opposite. I accessed the site from several locations using various devices, browsers and OS’s, then tracked my movements through the sites. Each time, it managed to detect my exact entry point to the site, the referrer I used (including the search engine search term) as well as my exact OS and browser. As soon as I started using this feature my mind was full of ideas where this feature could be a benefit to a website. My first reaction was that I could use Woopra to quickly identify bottlenecks in a system. By watching the flow of users through a site live, I could see any issues on a granular level. This could be very beneficial if you have changed a stage in a process, for example introduced or altered a stage in the checkout process. This feature will allow you to identify such areas quickly on a per user bases and could even be integrated with customer support to get more detail from the user allowing you to offer a better service at a time of need. You can offer a very proactive approach to usability and navigation by using such a feature.

Analytics Reporting

Looking through the quality of the statistics Woopra gathered through the live user tools as well as the historic analytic reports I was very impressed by the level of detail offered by Woopra. I did not see any evidence of bot contamination in my visit stats. I compared some of the analytical data Woopra had collected over a given time period with Google Analytics. I noticed that there were concerning differences in the details. To cross check both these I examined the actual access logs on the server to quickly identify which system was more accurate for example, by looking at the number of unique agents, visits and referrers. To my surprise the analytics seemed to favour Woopra in some cases although not all. There were areas of concern I noticed in Woopra particularly relating to the source by IP of the visitors. Although IP by Country seemed fine, I wasn’t confident that the IP to City locations were accurate and hence this affected some features which heavily integrated such data. Woopra had confirmed though the IP database being used in the beta program was being replaced and the current solution was temporary included due to financial constraints :

“We’re working up upgrading the IP address system. To save money, we went with an older, free version.” (twitter.com/woopra)

There were some differences where Google Analytics offered some data that Woopra doesn’t. However what I must say is where Woopra offered the same information as Google Analytics, I personally think Woopra presents the data in a more concise, detailed and purposeful manner. I started to find I had more interaction with the statistics offered on Woopra which allowed me to see some of the collected data in new ways. The level of detail shown particularly around referring domains and search terms in Woopra is excellent. You can instantly see a visual representation on a search phrase with the graphical detail helping you identify patterns and trends quickly. However there are areas which I didn’t test in much detail and that was based around PPC campaigns and such. It would be interesting to see what dedicated SEO specialists think of Woopra where PPC is heavily integrated into analytical campaigns.

Desktop Application & User Interaction

Analytics aside I was also very impressed with the desktop application to which I was using to retrieve statistics from my sites. The application is fast, well designed and offers a broad range of tools and filters which you can use to customise and extract data with. Since I have installed Woopra on my desktop I have actually found it to be quite addictive. It’s so accessible and easy to interact with I found myself constantly switching back and forth to find out more information.

Customer Feedback

As I have been testing Woopra out as part of the Beta program, I have been tweeting some of my finds on twitter. What impressed me was Woopra’s dedication to respond. I can confidently say that pretty much every tweet I mentioned, I had a direct response from @woopra with a constructive answer. This to me shows great product support and commitment by Woopra to make a strong product even stronger. This feedback and interaction process could really help Woopra get into a good market position quickly and I’m sure will also help the product develop into something the users really want.

Overall

To conclude this review, I was overall very impressed with Woopra. I would highly recommend anyone using or considering web statistic packages trying this out! The only issue I have left before fully committing to this package relates to the fact that this product is in beta and the final package price to my knowledge has not yet been released. Hopefully by spreading the word this could help reduce the price as I certainly want to carry on using Woopra. Watch this space, I think Woopra is going to be around for a good while!

Please feel free to add your comments to this post, I appreciate all feedback.

To find out more visit : http://www.woopra.com/

You can also follow Woopra on twitter at http://twitter.com/woopra

, , , , , , , , , ,

3 Comments

Upgrading SVN on Linux (CentOS)

The following series of events were carried out on CentOS 5 and were a success. If you are using a RedHat based systems such as CentOS or Fedora, the following series of instructions should allow you to upgrade svn in the same way.

Please note you must investigate your own server settings and in no way should you make any changes to your systems suggested here unless you are 100% confident that these changes will not result in problems to your system.

Recently I ran into a problem when using TortoiseSVN and the command line on CentOS. It appeared that after upgrading my version of tortoise I was being presented with errors on the command line when trying to run simple svn commands. Further investigation revealed that I was using an older version of svn on my server which was resulting in conflicts between my server and tortoise when quering the same repository. So I decided to record the procedure I went through to upgrade my version of svn and share it here. The most recent version of svn was which was 1.6 at the time of writing.

  1. Run ’svn –version’ on the command line to confirm that you running an older version of svn than 1.6. In my case his revealed : ’svn, version 1.4.6′. Upgrade needed.
  2. Check that YUM doesn’t have the version you require using the by running ‘YUM upgrade subversion’. In my case I received the response ‘No Packages marked for Update’.
  3. Make sure you have priorities installed by running ‘YUM install yum-priorities’
  4. Ensure that the priorities plugin is enabled by editing : ‘/etc/yum/plugincont.d/priorities.conf’. Then set ‘[main] enabled = 1′.
  5. Edit the .repo files in ‘/etc/yum.repos.d/*’ by adding ‘priority=N’ where N is 1 to 99 depending on your system.
  6. Priorities that I used :

    • Base, add-ons, updates, extras = 1
    • CentOS plus, contrib = 2
    • 3rd party repos such as RPMForge = N (Where N >=10)
  7. Download the RPM release package from : ‘http://apt.sw.be/redhat/el5/en/x86_64/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
  8. Install DAGS GPG Key ‘rpm –import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
  9. Verify the package download by running ‘rpm -K rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
  10. If the package is verified, install the package ‘rpm -i rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
  11. Test that the package installed by running ‘yum check-update’. Look for ‘loading priority plugin’ and ‘excluded packages’ due to the priorities plugin being present.
  12. Add the following to the [base] and [update] sections of the centos.repo files in /etc/yum.repos.d/ (You may wish to add this to other 3rd party files in this directory as well):
      ‘exclude=subversion’.
  13. Now yum will behave as if there’s no package named subversion in the core repositories and will install the latest ‘1.6′ from RpmForge.
  14. Run ‘yum install subversion’ and you should now see the latest subversion being installed. After which you can run ’svn –version’ just to be sure.

Now you should have the latest version of subversion on your system.

, , , , , , , , ,

1 Comment

How to explain MVC to a business and convince them it’s something they need

A common occurrence many development teams will encounter is a where an older system not designed to scale well, will need to consider scale to support business demands. Businesses need to move quickly and purposefully to cope with consumer demand upon services as well as innovation induced development to compete within the market place.

It could be that your current system was designed to meet previous business goals and the extent of the specification was simply to complete a given task. You might be finding that recent business demands are taking a great deal of time to implement and that the smallest change is having huge impacts on the existing code structure. This could be as it is in so many systems, a result of tightly coupled code which is infected with design debt, or it could simply be that the original design of the systems structure didn’t consider growth and re-usability beyond the scope of the original spec.

If this sounds familiar to you, you’re probably spending a great deal of time on system maintenance and testing. The smallest changes are having huge impacts not only with relation to system integrity, but having a negative impact on the professional image of the development team. Depending on how far you have gone down this road, the business could be seeing IT as a wasteful, incompetent resource.

As you’re reading this post, it is likely that you’re thinking that to make things better you are looking at introducing MVC (Model, View Controller) into your system architecture. This MVC structure maybe something that is being encouraged by a chosen framework or simply a structure you wish to introduce into your existing system whilst refactoring your code. Either way to gain project time in most cases the business have to recognise the need for such a change and allow resources to be allocated to move towards this place where the grass is said to be much greener.

Now you are in a situation where the business already blames development teams for slower production times and pretty much for all problems and bugs that are inherit from a system which may have been subject to the ‘Big Ball of Mud‘ scenario. How can you go to the business asking for more time and resources to work on a project which unlike a product development has no physical delivery. After all if you are moving your system to MVC and/or using a framework there maybe no physical difference in the end product initially. Why would the business want this? Where is the ROI?

Respect the old code and the business

When approaching the business it’s best to be honest and upfront. There is no gain to be had blaming individuals for the current state of the system. It not only looks as if you’re diverting attention, but your colleagues aren’t going to appreciate you pointing the finger away from yourself in their direction. You should also remember at this point that it’s this system which has supported the business to date and is likely to be the same system that is supplying the current revenue stream. Although the system may need work, it has done it’s job to date.

Don’t hide the facts and don’t cushion the blow

The first rule here is to respect the business and tell them the truth. I’m sure you will be surprised to how much they actually know and that could be your first factor in common to working together towards the solution. There are plenty of examples out there on the web of successful companies who are and have been in the same situation of introducing MVC and/or Frameworks. It would be a good idea to use some of these examples as this will not only provide a knowledge pool of what did or didn’t work well, but will reassure the business that the problem the system is suffering is very common and there are clear paths forward. There is no gain to be had by raising an alarm defining how bad the current system is without researching and demonstrating clear ways forward. This won’t aid your case of supporting the development of a new structure. Use real cases and put forward some other success stories where this change has been successful to inspire the business.

How did we get into this mess

The old saying ‘Learn from your mistakes’ is relative to this exact moment. However to learn from your mistakes, you must recognise that you have made mistakes.

There are thousands of reasons why systems can incur significant design debt. Many of these reasons are comforting to know as they can happen naturally by the very nature of simply being active within successful business. It’s very likely the reason your looking to for a framework or MVC structure is that you want to support growth. Business growth has taken you to this point in time and that business growth is a commendable asset and a reassuring factor to be presented with.

Common factors of business growth that influence systems and incur design debt could be the following:

  1. The business has grown so fast, very little resources have been available to maintain the design.
  2. Corners have been cut in development to ensure products are released in a short time and therefore generate income quicker. The short cuts have never been revisited and therefore they become permanent. Additional development therefore have inherited the previous problems.
  3. The purpose of the system today is very different to when it was originally designed and limited effort was proposed to make the transition. Instead quick fix cultures were applied to change the identity of the system.
  4. Customers have become larger. As a service grows you might have moved from B2C to B2B or both. This can drastically change the demands on the system and the original business intentions/system did not consider this change or scale of change
  5. Limited knowledge available. In fast growing businesses the developers are expected to know all the answers without been given time to research. Therefore applying solutions are done through a limited knowledge base which is not given time to increase through training and investment.

No matter what your reasons are it would be a benefit for IT and the business to share and understand some of the reasons. Both sides understanding these will help prevent mistakes being repeated in the future, but will also contribute towards design and research to be key elements in future solutions.

Remember if your system is cracking at the seems as it can’t scale well, this could be because the business is growing fast. You would do well to respect the business for this and at the same time use this fact as a reason for current system problems. If the business is successful it’s likely they will take this on board and appreciate that speed of growth has affected development. This could provide you with the opening of working with the business to get the systems into a more robust agile condition.

Introduce MVC

Remember the business are non-technical and using jargon like frameworks and MVC is likely to confuse the listeners and as a result put up barriers. The reason you are proposing MVC as a solution is that you probably want a clear system structure which will be provide an environment which is easier to develop and maintain. However before you start getting this message across you need to explain what MVC is and what benefits it will offer.

Define the existing structure clearly

One of the reasons you might be looking for an MVC structure is that your current code structure involves code where the interface incorporates business logic, or the business logic is coupled with system logic and so on. Ignoring the reasons for this as we have briefly mentioned them above, explain this is the case to the business. The better you get the business to understand this situation the more likely they will sympathise with you and understand why there is higher maintenance times and deployment issues.

Some further reading can be found here:
http://en.wikipedia.org/wiki/Spaghetti_code
http://www.laputan.org/mud/
http://www.codinghorror.com/blog/archives/000589.html

Define MVC in layman’s terms

Remember you’re technically minded and close to the code. MVC to you is as clear as day, but saying to the business ‘Model, View, Contoller’ could give them the impression that you are suffering from some form tourette syndrome. MVC won’t mean much to the business even after you define them in relation to the code. To get the business to understand why this is the answer and least of all what it is, can be more of a task than expected in my experience. Even some fellow developers have difficulty understanding this on occasion.

To get the listener to understand what MVC is and why it works what I have tried in the pass is to apply MVC to a different industries where the listeners have had more involvement. An example that has worked for me in the past in a comparison to the property or even the vehicles. Most people have had dealing’s with builders, carpenters, plumbers, electricians or have watched the flood of property shows on the TV. This experience is a good platform to use and to explain why separation such as MVC works. I know you’re probably thinking that won’t work as it’s not the same as in software, but remember you’re not trying to train the business to become developers or have an in depth understanding of MVC, simply explaining to them that separation in production is required and that’s what an MVC structure offers.

To give an example of how you could describe this I have very briefly explained how separation works in property. Keep in mind this is focused on using the system not developing which could be a completely different angle of explaination.

View

The view in MVC is the presentation layer. This is what the end user of a product will see and interact with. A system can have multiple views of all different types ranging from command line output to rendered HTML. The view doesn’t consist of business logic in most clear designs. The interface is fit for purpose and is the area of interaction. Therefore you could simply output HTML for consumers to interact with or output SOAP/XML for businesses to interact with. Both use the same business logic behind the system otherwise known as the models and controllers.

In the world of property you could think of the view as the interior of a property or the outer layer of a property that the inhabitants interact with. The interior can be customised for purpose and the same property can have many different types of tenants. For example a property of a particular design could contain residential dwellings. The same internal space could easily be used as office space, where although in the same property has a different purpose. However the property structure is the same. Therefore the environment in which the users interact does not interfere with the structure of the building.

Controllers

The controller is where the magic happens and defines the business application logic. This could be where the user has sent a response from the view, then this response is used to process the internal workings of the request and processes the response back to the user. Taking a typical response where a user has requested to buy a book. The controller has the user id, payment details, shipping address and item choice. These elements are then processed through the business logic to complete a purchase. The data is passed through the system into the model layer and eventually after the entire request satisfies the business definitions, the order is constructed and the user receives their item.

If we compare this to a property, we could compare the ordering of a book online to turning on a light switch. A tenant will flick the switch to on just like ordering a book. The switch itself is an element in the view layer which sends the request to the controller just like clicking a checkout button on a web site. The business logic in this case is what the electrician installed and are embedded within the property designs. The switch is flicked, which completes the circuit. Electricity runs through all the wires including the fuse box straight through to the light bulb. Just like the user receiving a book, in this case the tenant receives light. The whole process behind the scenes involving the electricity cabling is not visible to the the tenant. They simply interact with the switch within the space and from there the controller handles the request.

Models

The models in MVC are the bottom most layer and handle the core logic of the system. In most cases this could be seen as the layer that interacts with the data source. In systems using MVC, the controller will pass information to the model in order to store and retrieve data. Following on from the example above controller definition, this is where the order details are stored. Additional data such as stock levels, physical location of product of the book amongst many things are all stored here. If that was the last book in stock ordered, the next request for this item may check if it’s available and disallow the order as the item is no longer available.

Sticking with out example of turning on a light switch, this level in our structure could be the electricity supply. When the tenant flicks the switch, the internal circuit must request electricity to power the request which is similar when the user requested data from the database, as in data is needed to process a request. If the dwelling isn’t connected to an electric supply, it cannot complete the process.

Business benefits from using MVC

After you get the message across explaining what MVC is, you will then have to see what benefits can be obtained from it. I’m not going to go into a huge amount of detail here are I’m sure you can apply benefits more accurately which are directly related to you actual situation. To list just some of the common benefits of an MVC based system here are a few examples:

  1. Different skill levels can work on different system levels. For example designers can work on the interface (View) with very little development knowledge and developers can work on the business logic (Controller) with very little concern for the design level. Then they simply integrate together on completion.
  2. As a result of the above separation projects can be managed easier and quicker. The designer can start the interfaces before the developer and vice versa. This development process can be parallel as opposed to being sequential therefore reducing development time.
  3. Easy to have multiple view types using the same business logic.
  4. Clear route through the system. You clearly know where there different levels of the system are. With a clear route of the system, logic can be shared and improved. This has added security benefits as you clearly know the permitted route from the data to the user and can have clear security checks along the route.
  5. Each layer is responsible for itself. (Relates to point 1) This means that you can have clean file structure which can be maintained and managed much easier and quicker than a tightly couple system where you may have lots of duplicate logic.
  6. Having a clear structure means development will be more transparent which should result in reduced development time, maintenance problems and release cycles if applied properly.

Get the message across

If you’re still reading this article you maybe either thinking the example above is a good idea or that it’s just plain silly. No matter what you’re thinking, the goal here is to get your message clearly. If this example doesn’t work for you, try finding a solution which will have the same affect. The point is for the business to support you and to consider repaying the design debt you will need them to understand what problems the current system suffers from and how you can improve things. MVC is just one of many ways forward, but they will need to understand MVC to give you the green light and have time to implement it and factor it in future projects.

This has been written from my own personal approach. However if you have something to add to this post in order to give it value, please provide some feedback. It will only improve things for the next reader.

Related Links

Working-Effectively-Legacy-Robert-Martin

Design Debt

MVC Defined

GUI Architectures

Big Ball of Mud

, , , , , , , , , ,

5 Comments

Installing PHP5 on Leopard with pdo_mysql & iconv() support

I recently took the plunge a level further into the Mac world and purchased an iMac running Leopard. Although I have been running a Macbook for years, I decided that my main machine which I develop on was going to be something I have to spend less time configuring than my previous Linux machines (Although my servers will remain Linux). My main goal was to get a slick dev environment running PHP, MySQL and Apache.

Being naïve, I expected Leopard to provide me with a suitable stable release of these technologies straight out of the box, after all Leopard comes with Apache, MySQL and PHP right? Well this maybe true, but this is not exactly what I expected. Soon after building my little world of development I realised that the distribution was insufficient. Disappointingly I learnt that the PHP distribution was missing ‘pdo_mysql’! How could they have missed this I asked myself? The extent of use of ‘pdo_mysql’ usage should have made this a fundamental module, even Zend Framework, one of the worlds largest PHP Frameworks uses this as a standard. Anyway this is the crossroads, do I recompile the distributed version and risk the Apple support or do I download and compile my own version. Well I thought, lets install it via macports, that will save me a bit of hassle. This also meant that I could maintain a separate series of installs to what came with leopard.

After downloading and installing macports I installed the following:

sudo port install php5 +apache2 +mysql5 +pear

port install jpeg

port install libpng

port install freetypeport

port install libmcrypt

After updating my apache configuration located ‘/opt/local/apache2/conf/httpd.conf/’ to suit my needs including pointing the my sites directory located in ‘Users/craigstrong/Sites’ I thought I’d give it a whirl on my web apps.

sudo apachectl restart

Everything seemed to work fine. I loaded up a few static pages from one of my Zend Framework projects, then I thought I’d try my login script. Boom! Guess what, no ‘pdo_mysql’ module installed. Arrggghhh!

Well off I went to get PHP 5.2.9 as this was the most stable recent release at the time. I convinced myself this is the solution I should had tried first. I downloaded this version and strapped myself in for a bit of compiling.

Within my extracted directory ~craigstrong/Programs/PHP-5.2.9 :

./configure
\
–prefix=/Users/craigstrong/Programs/php-5.2.9/
\
–with-apxs2=/opt/local/apache2/bin/apxs
\
–with-xsl=/usr’ \
–enable-mbstring
\
–with-gd’ \
–with-jpeg-dir=/opt/local 
\
–with-png-dir=/opt/local
\
–with-zlib-dir
\
–with-curl=/usr \
–enable-sockets \
–enable-exif
\
–with-mcrypt=/opt/local
\
–enable-soap
–with-mysql=/usr/local/mysql \
–with-pdo-mysql=/usr/local/mysql/bin/mysql_config
\
–with-mysql-sock=/tmp/mysql.sock
\
–with-freetype-dir=/opt/local
\
–with-openssl=/opt/local \
–enable-cli

The configuration went well, so I thought lets start compiling and run the following:

make

Followed by :

sudo make install
sudo mv /usr/bin/php /usr/bin/php.distro
sudo ln -s /Users/craigstrong/Programs/php-5.2.9/bin/php /usr/bin/php

All seemed to go well, and I went through my application again. This time when I go to the login form I was greeted with a new problem saying that the application could not find the function iconv(). Absolutely great I thought, another obstacle! After a bit of reading around this problem I found this link confirming my problem was real and what actually was attributed to a problem in the configure script on Leopard (http://www.mail-archive.com/php-bugs@lists.php.net/msg120323.html). I made sure to add the following 2 lines to the configure script pointing at my macports location.

–with-iconv=/opt/local
–with-openssl=/opt/local


As soon as I got to the ‘make’ command I was greeted with the following output:

Undefined symbols:
\\”_iconv_close\\”, referenced from:
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_mime_decode in iconv.o
__php_iconv_mime_decode in iconv.o
__php_iconv_mime_decode in iconv.o
_zif_iconv_substr in iconv.o
_zif_iconv_substr in iconv.o
_php_iconv_stream_filter_dtor in iconv.o
_zif_iconv_mime_encode in iconv.o
_zif_iconv_mime_encode in iconv.o
\\”_iconv_open\\”, referenced from:
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_mime_decode in iconv.o
__php_iconv_mime_decode in iconv.o
_zif_iconv_substr in iconv.o
_zif_iconv_substr in iconv.o
_zif_iconv_mime_encode in iconv.o
_zif_iconv_mime_encode in iconv.o
_php_iconv_stream_filter_factory_create in iconv.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1

Well at this point I was getting more annoyed and again started cursing Apple for not sorting this out with the distribution of Leopard. Have to blame some one I thought.

Anyway after a long think a good time reading around the web I convinced myself to download php5.3 and go through the process again. I went through the same process of downloading, configuring and compiling it using exactly the same configuration script as above. I wasn’t expecting a high chance of success with the previous events. However to my amazement it worked. I went through my site and I finally achieved my goal of having PHP with ‘pdo_mysql’ and ‘iconv’ support! Although frustrating following the process, it was satisfying getting a result.

As I use Zend_Framework the only thing that needed to be resolved is that my date() function was throwing an error saying something on the lines of ‘best not trust the systems timezone’. I then added the following function to the bootstrap date_default_timezone_set(’GTM’) and my problem was solved. I now have a development environment I can enjoy.

Useful Links Relating to this post :

  1. http://seancoates.com/php-5-2-5-on-leopard
  2. http://www.mail-archive.com/php-bugs@lists.php.net/msg120323.html
  3. http://drewish.com/node/110
  4. http://www.malisphoto.com/tips/php-on-os-x.html

, , , , , ,

1 Comment

Common svn commands using the command line

Over the past few months I have been switching between operating systems which have included, Cent OS, Fedora, Vista and Mac OS X. When switching through these operating systems I am very aware of cross compatibility when using OS dependent software. Other than the obvious differences which include such things as file systems, one thing I have been quite frustrated with is interacting with SVN whilst moving between these operating systems. Why this has been frustrating it’s because for each of the OS’s above there is dependent software such as Tortoise SVN on windows. This is a great SVN tool and really does make things easier. However this is a Windows SVN tool so I can’t use it on other OS’s. Although there are tools available on other OS’s, I don’t want to keep switching between OS specific software as it can be time consuming and takes you a step further away from the source/task.  

Why use the command line ?

As a result of the restrictions imposed when moving around different OS’s, I have reverted my svn interaction back to the beloved command line for most svn tasks. Now I know some of you reading this may see this as a step backward in the world of modern UI, but there are a few good reasons why I have made this decision:

  1. With the exception of running putty on Windows to interact with my svn repository which sits on Linux, the command line makes you closer to being OS independent when it comes to svn.
  2.  

  3. Running svn commands on the command line is much quicker as it doesn’t have to go through the rendering process or additional layers of the OS or a series of extensive third party code. There is much less clutter, it’s just plain and simple (WYSIWYG).
  4.  

  5. I have had problems with the OS network cache, such as when ‘subclipse‘ or ‘Tortoise‘ tell you that you are working within a branch when you are actually on the trunk! As you can imagine, this can have problematic knock on effects and this is where the command line doesn’t lie. You don’t need to click refresh on your working copy directory to get the truth, you simple ask it once and it tells you there and then, no caching involved.
  6.  

  7. You don’t have to learn how to use each OS’s svn tool’s navigational menus and can therefore spend the time learning the commands plain and simple, saving you time in the long run.

 
Now I’m not saying that UI svn clients don’t have a value, the visual advantages can be extremely significant, especially when merging and looking at diff’s etc. You might find yourself going back now and again to use these tools for these advantages alone. The point is for general usage the command line has a significant value for me and for general svn interaction entering simple commands can be a time saver.

Everyday SVN Commands

For  those who are interested and for an online resource I can frequent to compensate for my poor memory, I have listed a few of the common commands I use on a day to day basis below:

Note: For the purpose of these commands I will express the path the repository as $REPO

 

svn log –revision 55:90  

Shows the log history from revision 55 to revision 99

_____________________

svn log -r 66:44

Shows the log history from revision 66 to revision 44 in reverse order

_____________________

svn log -r 81

Shows the log specifically for the chosen revision 81

_____________________

svn log $REPO/branch1234

Shows the log history for a specific branch

_____________________

svn log -vr 1234

Shows the modifications for a particular revision

_____________________

svn log –stop-on-copy | grep-i “update”

This will show the commit history up until it finds the phrase ‘update’ in the commit log

_____________________

svn list $REPO/branches/branch-123

lists the directories/files within the selected branch-123

_____________________

svn switch $REPO/branch/branch123/siteA

If you are in your working copy site directory, this command will switch your current location to the branch you require. For example if you are in my/working/copy/siteA which is checked out to the trunk, this command with switch you over to your selected branch. Note : You can also enter this command as “svn switch $REPO/branch/branch123/siteA /path/to/your/siteA”.

_____________________

svn mkdir $REPO/branches/branch333

Creates a new directory within the repository. Within my example I have created a new branch.

_____________________

svn cp $REPO/trunk/siteA $REPO/branches/branch456/siteA

Checks out the site ’siteA’ to a selected branch ‘branch456′.

_____________________

svn diff –summarize –old=$REPO/trunk/site –new = $REPO/branches/branch333/siteA

Shows the list of files that are different between the two versions selected.

_____________________

svn merge –dry-run -r123:200 $REPO/trunk/siteA

carries out a dry run of a merge between the head of branch ‘r123′ and the head of trunk ‘200′. (A merge can be between any two revision numbers)

_____________________

svn commit -m “A brief, but informative message here”

This will commit any changes to your trunk/branch accordingly and record a message in the commit log. Remember you will be reading these log messages often. If you are working within a team ask yourself if someone else looked at the commit log could they work out what your commit involved from your message. Although sometimes seen as a repetitive task entering messages, these are there for a reason. It might be good practice to employ a message standard within your workplace to keep messages consistent.

_____________________


svn info /path/to/site/in/workingcopy

This will output the information for the file/directory within your working copy. You can know exactly where your working and the current status from this. Example :

craig-strongs:~ craigstrong$ svn info ~craigstrong/working_copy/

Path: /Users/craigstrong/working_copy/

URL: svn+ssh://craig@repo/my/path

Repository Root: svn+ssh://craig@repo/my/path

Repository UUID: 12345-12345-12345-12345

Revision: 875533

Node Kind: directory

Schedule: normal

Last Changed Author: craig

Last Changed Rev: 875533

Last Changed Date: 2009-03-25 16:46:59 +0000 (Wed, 25 Mar 2009)

_____________________

svn status /path/to/working_copy

This will list the current status of your working copy. If you have switched any files/directories, you should be seeing these listed within the results back. Other information such as if you have any uncommitted files will also be listed here.

_____________________

I’ll restrict the list to the above for now as these are what I consider to be the most common commands that I use on a day to day basis. If I find myself often writing other such commands regularly I’ll add them to the above.  If you feel you would like to add to this list, please feel free to reply to this post.

, , , , , , , , , , ,

1 Comment