A Theory of Project Costs

Lately I’ve been giving a lot of though to the way costs for projects are estimated. It always seems a very hit and miss affair. One designer I used to work with used to work out the costs as accurately as he could and then double whatever number he came up with – this worked as well as anything – and fairly accurately reflected the time / cost of what he was doing.

I think a lot of the problem is to do with the way projects scale – a £10,000 project is not necessarily 10 x more complex than a £1000 project, but more importantly it is far easier to scope a static webpage with 10 pages and a contact form than website where the client guidance goes something along the lines of we want it to be a bit like Facebook {edit as applicable} but aimed at Pig Farmers {edit as applicable}.

The trouble with building complex applications is that it is often hard (if not impossible) to anticipate problems until you come across them. I suppose this has a lot to do with the rise Agile Development – using it as a way of getting away from specifications that often rapidly loose any relationship to the project they define.

Development is really an evolutionary affair and clients will change their minds in response to what they see – but God is (as they say) in the details – and it is often genuinely not possible to know how a project will go once it starts to take shape. Good project management I suppose the art of reconciling these evolutionary forces with budgets, clients and what is actually possible.

Right now in my current job I don’t really have any say in how projects are costed – and they are costed as well as anywhere else I have ever worked – which is to say as accurately as possible – but of course I have to work with budgets and liaise with clients over all the technical nitty-gritty – so I have lots of time to observe.

My current theory goes something along these lines (BTW all figures are just made up)

c = minimum cost
t = cost per database table
i = number of database tables

total cost = c + (t x i)

BUT this isn’t right yet there a number of additional factors that I am trying to work into the equation so far I have:

p = Client Knowledge – an overly knowledgeable client cause as much trouble as an IT somebody who is IT illiterate – ideally we need somebody who understands what you tell and has ideas of their own but can also understand advice.

z = a factor to fine tune t x i

For Example: if i = 10 then the total cost might work out as 1 x (t x i) but if i = 60 then total cost = 0.7 x (t x i)

I wonder what ever happened to my old graphics calculator…

To be continued…

widgEditor is back…

Over the weekend I found out that Cameron Adams aka The Man in blue has just released a new version of the fabulous widgEditor – an easy to use and easy to modify WYSIWYG editor mad with XHTML and JavaScript.

It has been 3 years since he released the 1st version so it is great that he has released an update and the ven better news is that he is working on version 2 (I can’t wait).

The great thing about widgEditor was that unlike all of the usual WYSIWYG suspects, it was easy to go into the code and change things about to get it to work how you wanted – a case of a limited feature set being an advantage as the end result was pretty elegant.

If you have never heard of or used widgEditor – check it out.

jQuery – watch a checkbox field

This is a simple function I wrote that will monitor a <checkbox> field on a form. If the <checkbox> is ticked then it will show a specified <div> and if the <checkbox> is un-ticked then it will hide the specified <div>.

View the working example

Initially I thought that I might be able to use the .toggle() function – but I when users returned to a form I needed the <div>s to show or hidden according to stored values.

I also have a very similar function that does the same thing for <select> fields. Logically you might then combine the functions into a single function or a plugin that could monitor checkboxes, radio buttons, select menus and show or hide <div>s accordingly – but at what point does the complexity of the just using the function outweigh the simplicity of using it? This is something I haven’t decide on yet.

At the moment I can just call it like so:

1
2
 
testCheckbox('id_of_checkbox', 'id_of_div');

If I were to combine these functions I would likely loose this speed / clarity – for instance a <select> might want to show or hide different <div>s based on different selected values and then I would need to start passing arrays to the function – loosing the initial simplicity. The only answer is to go ahead, write one and see what happens.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
<script>
   $(document).ready(function(){
 
 
 
   testCheckbox('showHide', 'targetDiv');
 
 
 
 
   function testCheckbox(key, target){
 
    if($('#'+key).is(":checked")){
     $('#'+target).show();
    }
    else {
     $('#'+target).hide();
    }
 
    $('#'+key).click( 
 
 
 
      function()
       {
 
        if($('#'+key).is(":checked"))
         {
          $('#'+target).show();
         }
        else
         {
          $('#'+target).hide();
         }
       }
     );
 
 
   }
 
   });
</script>

Note When I wrote this function it seemed logical to use the .change() function – but I have had to chnage this to .click() because .change() seems to fail silently and unpredictably in IE7.

DELETE with LEFT JOIN in MySQL

in MySQL using a LEFT JOIN is a simple way of find records that exist in one table but which have no corresponding records in another table. An example might be in a JOIN table that exists between two other tables e.g.

A user can have many notes and notes can themselves have many users – a HABTM relationship.

Tables

If you delete a note or a user you could end up with orphaned records in the notes_users table – to find these orpahned records you might use a query like this:

1
2
 
SELECT notes_users.* FROM notes_users LEFT JOIN notes ON notes_users.note_id = notes.id WHERE notes.id IS NULL

You would imagine that to delete all of these orphaned records you could simply use the following query:

1
2
 
DELETE FROM notes_users LEFT JOIN notes ON notes_users.note_id = notes.id WHERE notes.id IS NULL

However this won’t work – you actually need to indicate which table you want to delete the records from:

1
2
 
DELETE notes_user.* FROM notes_users LEFT JOIN notes ON notes_users.note_id = notes.id WHERE notes.id IS NULL

Yesterday in MySQL

Sometimes the simplest things just won’t stay in your head. Personally I can never remember code for date based calculations, and it easier to find what I want here than look it up on http://dev.mysql.com/doc/.

Here is a very simple way of comparing (or getting) dates:

Example delete all records older than 1 day from the notes.

1
2
 
DELETE FROM notes WHERE created <= DATE_ADD(CURDATE(), INTERVAL -1 DAY);

Read the manual entry for the MySQL DATE_ADD function.