I recently accepted a large project which was basically making a lot of CRUD (create, read, update, delete) pages for the database of a company. The reason the project was large was, there were a lot of tables, and there were a lot of fields in each table.
Envisioning that the project will take at least 10 days of work, I quoted appropriately to the client and got the job. When I got started, I had 2 options:
Write the add, edit, validate, pagination, etc for each database table (customers, contracts, etc) seperately, which will just be the same code all over but different fields.
Or write a class which handles all of the repetitive tasks, you just tell it the name of the table and the field names, and any other options.
So I took option # 2. The resulting classes took a bit less time than doing it the conventional way would have, but rather than having 10 files with their own edit(), add(), validate(), etc functions which were basically the same thing all over, I had code like this:
<?php
require_once(APPPATH.'/crud/Crud.php');
class Customers extends CrudController
{
function Customers()
{
parent::Controller();
$this->entityName='Customer';
$this->model='customer';
$this->url='admin/customers';
$this->setDefaults();
$this->addGridField('business');
$this->addGridField('lessor_name');
$this->addGridField('contact_name');
$this->addGridField('email');
$this->addGridField('phone');
$this->addGridField('mobile');
$this->addTextbox('business');
$this->addTextbox('lessor_name');
$this->addTextbox('contact_name');
$this->addTextbox('phone');
$this->addTextbox('mobile');
$this->addTextbox('email', '', '', 'valid_email');
$this->addTextarea('comments', '', '', '', '', 7, 50);
}
}
?>
For each table, I built a file like the one above and bingo, I had CRUD pages for all of these!
But the prob was when I told the client the job was done. Although they did pay me, and did pay me on time (they're an old client, I often work with them), they sent me this email:
<snip>
Just querying your quote - Did this really take 45 hours to develop?? That
crud system you have looks like it's very simple to do
mate.......................
Hopefully will be able to pay later today...
--
John doe | IT Manager
</snip>
So my question really is, if we notice an obvious flaw in how we work, eliminating which will decrease the time spent on a job a lot, should we try to correct it and get the job done faster? Or should we continue to make it take long because then we will take the longest time, and hence get paid the most???
Or, how can we convince our clients to pay for value rather than time spent? That even if on the surface something takes us 15 mins to do, there was a lot of time and thought that went into optimizing it, and we should be compensated for it?