Choosing the Right Tool

Ian Baker

At work we get into discussions regarding the best tool for the job. It doesn’t necessarily have to be about programming. These are all good conversations to have, but there is a point where you have to make a decision and it might not be the best decision.

I am beginning to get to a point in my career where it doesn’t matter too much about the language we pick or which cloud service we use. It matters more to me that we are delivering on the customer’s needs and fulfilling our promises.

If you’re anything like me, when I started development, you will start looking at a few things. What is the best programming language? How quickly can I get something done? Do I need to learn Java to understand programming?

I’d encourage you to instead think about the problem. What do you need to solve for your customer? Don’t worry about the database or the code yet. What specific problem are we solving? Are you going to need real-world sensors to communicate with the customer’s manufacturing facility? Do you need to solve an inventory control issue? Do you need to publish product to an online store? Think about the problem first.

Once you have thought about the problem I encourage you to flowchart out what the solution is. It helps sort out the problem for your own sake and is an easy document to give to coworkers to validate an aspect of the problem. Have you notice we didn’t talk about which tool is the best tool to use yet? The only thing discussed was the problem at hand. I didn’t ask you to think about how the data is supposed to be stored, what language to use, what framework, etc, and honestly, it does not matter.

How to pick the right programming language?

Pick what you feel is natural and what you find accomplishes your personal goals. I originally chose PHP early on because it allowed me to create websites that could interact with a database and be dynamic. I continued using PHP until it was no longer capable of a customer’s demand: counting plastic pulleys rolling down a ramp.

For counting the plastic pulleys I chose an Arduino and learned the basics of C and eventually meandered over to Python. When Liturgical Publications had me evaluating the recent mobile application they purchased I made the choice to learn Angular and become more comfortable with Javascript.

I picked the language that I thought was best suited for the job at the time. You need to pick the one that is right for the job instead of debating over the perceived fallacies.

What Would Dad Do?

I am not sure why but I always imagine what my Dad would do. What tool would he use? He would definitely participate in the conversation or debate over a proper tool. In the end, Dad would not care what tool was used, he would only care that the job was done properly. I want to conclude with one of WordPress’s philosophies that highlights this point and am also curious what you think about this matter.

“Many end users of WordPress are non-technically minded. They don’t know what AJAX is, nor do they care about which version of PHP they are using. The average WordPress user simply wants to be able to write without problems or interruption. These are the users that we design the software for as they are ultimately the ones who are going to spend the most time using it for what it was built for.”

How to Migrate from SVN to Git

You’re still using SVN!?

Jim Blandy trembles as he watches Linus tempt you to come closer. Linus throws his VCS at you with horrible puns such as: ‘Git closer my boy’ and ‘In Git We Trust’.  He appears angelic while you are wondering why Jim ever captivated you in the first place.  Maybe it was the SVN charm?

You start forgetting the SVN commands. Worse, you start confusing Git commands with SVN when talking to friends. No longer will you be the only person answering yes to, “Does anyone use SVN?”. As soon you are done migrating to Git you will be denouncing SVN. You are starting to smile now and begin to think of ways to act like you’ve always ‘Gitted’ before.  SVN? What is that!?

Your smirk drops.

It dawns on you that you have to migrate your code repositories first and you have no idea on how to start.

Continue reading “How to Migrate from SVN to Git”

How to Separate Concerns with Legacy PHP Apps and Composer

logo-composer-transparent3Legacy PHP applications get a bad reputation.  They are constantly ridiculed for being hard to work on, lots of repetition, no unit testing, etc.  There is a straight-forward way to approach code when you come across it.  I’ll show you how you can start separating classes using Composer in this entry.

Continue reading “How to Separate Concerns with Legacy PHP Apps and Composer”

Using Silex to Refactor a Legacy PHP Application

We have a legacy application here where I work, MRS.  In my last post I talked about putting in place a front controller as the next logical step.  I started to take a different, more thoughtful, approach after discussing with my co-workers.  I used Silex.

Continue reading “Using Silex to Refactor a Legacy PHP Application”

Vagrant/Ansible causing ‘Too many authentication failures’

You might run into an SSH error that seems vague.  Here is the error

SSH Error: Received disconnect from 192.168.56.120: 2: Too many authentication failures for vagrant while connecting to 192.168.56.120:22

Your error will vary on port and IP address but it is all the same.  Here is how you fix it.

Create a file called `ansible.cfg` in the same directory as your Vagrantfile. Add the following to the ansible.cfg file:

[ssh_connection]
ssh_args = -o IdentitiesOnly=yes

That is it.  Now when you run `vagrant provision` you will see that Ansible has the correct settings to connect to the VM and provision the box.  You won’t need to do this when Vagrant 1.7.3 is released because they addressed this issue in the code.

Update 5/28/2015:

I found that making this small change allows host keys to also be checked.  Definitely a RTFM moment.  Still waiting for the 1.7.3 release to assist with too many identities.

ansible.host_key_checking = true

Upgrading from Zend 1.12.7 to Zend 1.12.9

Zend released 1.12.9 a bit ago.  At work I started looking into how to upgrade to the recent framework to keep as current as possible but still ran into some pitfalls when trying to follow the documentation for upgrading.

Zend Framework 1.12.8+ introduces some backwards compatibility issues and it isn’t documented too well (don’t even get me started on introducing BC in a minor version).  I was able to upgrade LPi’s product by making some minor changes.  Zend mentions:

 

#418 can introduce potential BC breaks in the presence of complex SQL statements (for instance using SQL sub-functions). To fix this, use Zend_Db_Expr in group(), order(), or from() method calls.

 

That is a little confusing for me without examples.

Continue reading “Upgrading from Zend 1.12.7 to Zend 1.12.9”

Refactoring legacy PHP code

Spaghetti Code - John Trainer Flicker
‘Spaghetti Code’ cc John Trainor – flickr

Spaghetti code is frightening, but it is something that we all have hanging out there on the Internet that our 14 year old self would be amazed by.  Spaghetti code is technically known as legacy code.  I struggled with refactoring a larger application I did into a MVC architecture.  It was about half of a million lines of PHP code.  Refactoring it was an uphill battle and was well worth it.  Wanting to call it quits was tempting and now I can share with you pitfalls and strategies to use when evaluating your next project.  I’ll go through the steps and thought process I had when it came to refactoring my PHP application.

Continue reading “Refactoring legacy PHP code”