Sunday, 30 October 2011

Programmer working hours (is 9-5 enough?)

This is an old post pulled from another blog for preservation


A while ago I heard the phrase "if they want to work 9-5 then why not just work in a shop?" applied to programmers, the implication being that programming is not a 9-5 kind of job. I have been thinking about this on and off and discussing with people when I get the opportunity, apart from the fact that many people in shops work very long hours there are a number of problems with what was being suggested here.

My thoughts

Computer programming is undoubtedly one of those professions where people are often expected to work long hours, usually without extra reward. A major problem is that we often don't know for sure how long something is going to take (more on why this is in a later post). Another problem is that there are many times where there is a shortage of staff. So many times programmers are expected to work long hours to address these two problems, and many programmers are prepared to put the time in. Sometimes however this doesn't work out, sometimes the programmer who is happily prepared to pull the occasional all-nighters in company X leaves company Y because of long working hours, what is the difference?
Here is one observation or possible reason: programmers like to feel they have some autonomy over what they are producing, they like to understand the reason they doing something and feel that it makes sense. Programmers don't like repeating their work for no good reason, spending long hours working on something that experience tells them will never be used or repeatedly patching and fixing something that they know full well (and will happily tell anyone who will listen) needs to be re-factored and repaired properly. Programmers may be resilient to a lot of the aforementioned woe if it occurs within normal working hours (somebody else is effectively footing the bill, and obeying orders is the path of least resistance), but if the wasted work that they cannot avoid means they also have to work extra hours then those hours hurt, that lost weekend bites deep.

My conclusion

I actually think that programming is a job that is hard to achieve with a 9-5 mentality, but that the hours outside the 9-5 are what people put in themselves, the things that programmers do for a hobby or to keep up to date with technology changes. Given the space many programmers will do things themselves and extend their own skills and knowledge in a way that ultimately benefits the companies they are working for. Sometimes programmers given appropriate autonomy will even extend part of what they do at work into this extra space.
Many programmers work in a challenging environment of constant change, it is hard to manage this kind of career on a 9-5 basis. You would assume that a language interpretor who gets paid 9-5 doesn't switch off and never use the foreign language outside of work (if he did it would be hard to maintain the level of skill required), I believe that programming is a similar profession.

MySql Definer problems

This is an old post pulled from another blog for preservation

Recently whilst moving a legacy application, I had to make it more secure. In trying to make the database more secure I ran into one particular error in some of our Java code java.sql.BatchUpdateException: The user specified as a definer ('root'@'%') does not exist

The definer ('root'@'%') is the root of my problem (pardon the pun). Our application was accessing MySql as root user (so a compromised application could take control of all the databases on the server), even worse having root@% as a user in the database means that root access is not just restricted to local access.

Having given the application it's own user and remove root access from anywhere everything was running fine until we hit a page activated a trigger. Definers appear in a number of places in MySql including triggers, stored procedures and views (not sure what if any problems occur with a view if the defined no longer exists but will make a point to find out). My problem was an easy fix there was just one trigger that needed altering.

Although I have not had to yet, next time I run into this problem I would be looking to take an approach more similar to this one somewhere in that post or the comments there should be a working solution there to remove the definers from a MySql dump. I assume (would check) that the default definer if set by MySql would be the user credentials used to load the database again.

Fortunately the problem was spotted on a test server first.