Saturday, June 28, 2008

C++: Avoid using assignments in constructors

In my post Coding better C++, I've suggested a list of techniques to improve C++ coding. I shall try to explain them one at a time in the future posts. In this post, I've talked about "4. Avoid using assignments in constructors, use initializer list to initialize members".

The initialize list is used to avoid double construction of a contained object. Take the following example:
Class Student
Student ( const char *_name)
name = _name;
string name;
We create an object of the Student, for example, in the following way.
 Student s (Abc);
The following executions take place:

1. string name is initialized
a. string::string() function is called
2. body of the Student::Student(const char *) constructor is called
3. the line name = _name is executed
a. string::operator=(const char *) function is called

A note to experts: we’ve ignored memory allocation steps and detailed assembly steps of the function calls to keep things simple.

As you can see the result of the step 1.a, string::string(), is discarded by step 3.a, string::operator=(const char *), the step 1.a is therefore redundant.

We can optimize this with the initializer list, in the following way:
  1 Class Student
Student ( const char *_name) : name (_name)
string name;
In this way, the string 'name' is initialized only once and with the value of _name and it calls the string::string(const char *) function directly.

Many optimizations require some kind of a trade-off. You often trade speed for clarity, simplicity, re-usability, or some other metric. But in this example, optimization requires no sacrifice at all. This constructor will generate the exact same Student object with the exception of improved performance.

Saturday, June 21, 2008

Project management thoughts - 3. Parallel development issues

This is a continuation of the "Project management thoughts" series. Please read the previous posts if you haven't already.

In this post, I shall talk about why the parallel development of prototype and real application is not a good idea in a case like ours.

Why prototype and real development should not be in parallel

The purpose of the prototype is to try out different brainstorming results of the client and solidifying requirements from it. Now, the scope of the new requirements and 'change requests' to already solidified requirements have no limits, officially.

Let's take a break and do some basic maths of project management. A project has three main key factors: Time (T), Material (M) and Resources (R). Time is proportional to material and inversely proportional to resources. This can be represented in the following way.

T = M / R
or T x R = M

Meaning: 1. If your time is fixed and if you increase your material, you also need to increase your resources, 2. If your resources are fixed and if you increase your material, you also need to increase your time, 3. If you material is fixed and if you change your resources, your time will get changed, and so on.

I'm sure most of us know this in one form or another and I only described in details for the newbies.

Now back to the prototype, if the prototype continuously gives us new requirements through out the whole project time line, we need to have time open ended, according to the simple math that we done above, but that not an option in the first place. This is fixed time project.

Besides new requirements, the prototype will also yield a list of small and large changes (large, in terms of task volume). These changes need to get reflected in the already built features of the real application. The changes, of course, are materials (M) which requires more time (T).

The changes imposed from the prototype will virtually have no limits. If we have already implemented, for example, 20 features in the real application that were previously solidified, those may require complete or partial reworks in a very short time. Adjusting major changes in the requirements makes a solid codebase messy, making it more vulnerable to major bugs. Re-structuring, re-designing (the software design) and re-implementing are probably the last things a development team wants to do. If requirements get changed every now and then, which we cannot guarantee, may end up with unexpectedly weak software design and codebase.

There are also other factors of why it doesn't seem to be a good idea to run prototype and real application development in parallel. One of them is the time it takes to solidify requirements from the prototype. If we assume that we shall get requirements solidified from the prototype at a constant rate (or at a good rate) then it would be very wrong in real life. In practical scenarios we may get some or many of requirements solidified from the prototype and we may also need to wait a significant amount of time to get something solidified as it is very much dependent on client's decisions. 'Waiting' on a dependency for uncertain period of time for a 'fixed time and resources' project like ours (or in any project), is just one of the failure factors.

The better solution

Our proposed solution was to complete the prototype application first, with the effort of the full development team, solidifying requirements from it, and then working on the real application, again with the effort of the full development team.

This solves a lot of problems, the ones that I mentioned above. The only concern with this way is, can we really complete the prototype with all ideas of the client in time and then can we finalize requirements from the prototype in time? Well, it requires effort from both of the side, the team and the client. Both parties need to work aggressively towards one goal, which is to identify requirements within a given time frame.

To be continued.

Coming up soon: The team formation, the technologies, the tools used, the prototype phase, the software design phase..

[I shall continue to talk about my project management experiences and thoughts about this project in regular posts. I hope you shall find them interesting or useful].

Friday, June 20, 2008

Project management thoughts - 2. The initial team and tasks

This is a continuation of the "Project management thoughts" series. Please read the previous posts if you haven't already.

In this post, I shall mostly talk about the initial tasks of the project TP and my thoughts about it.

The initial team

Even though the project now have 20 engineers, it began only with 2 engineers. The primary goals of the initial team were to understand high level requirements of the project and to estimate required resources for the project. The initial team members were:
  1. A senior engineer with around 2 years of experiences, skilled in C#, Java and PHP
  2. Myself
The initial team worked around for 3 weeks to capture high level requirements of the project, business goals of the client, preferred development process of the client, preferred technologies of the client and the time line of the project. The detailed requirements specification was not defined and one of the first goals of the project is to identify and solidify the requirements.

The initial plan

The client wants to identify the detailed requirements with a prototype project. The prototype project will follow agile development method and needs to have a weekly build on which the client would like to try out a few different ideas and solidify detailed requirements as the builds go on. Basically the prototype project will be a brain storming ground for the client and requirements capturing ground for us (ReliSource).

The client wants a separate development project to run in parallel to the prototype project and the solidified requirement sets should be sent to the development project team for real implementation.

The idea is to test different things on the prototype, solidifying them and to build them in the real application. Both of the prototype development and real application development needs to go in parallel and the project, actually the first release, needs to be completed within six months.

Sounds doable? Well, not exactly. I shall post about 1. why not, 2. how we proposed a different strategy which was doable and also made the client happy, in my next post.

Friday, June 13, 2008

Project management thoughts - 1. Introduction

I'm currently working with a team of size 20. I'm playing a dual role of project manager and technical lead at the same time. I'll try to share my experiences with this relatively large team and my thoughts on project management. The age of the project is two and half months and is currently scheduled for four more months.

I'm planning to blog about this live project as it goes on which I believe is a courageous step. I shall try to maintain the privacy and not to disclose sensitive project information here.

The team
The team has 20 engineers, including me, with the following distribution.
  • 14 developers
    • 9 developers have 1 year of experiences on average
    • 5 developers have 2 years of experiences on average
  • 4 SQAs
    • 1 release engineer/SQA lead, with 3+ years of experiences
    • 3 engineers with 1 year of experiences of average
  • 1 graphics designer
    • 2+ years of experiences
  • 1 project manager
    • that's me with 5+ years of experiences
All engineers are computer science graduates, mostly from BUET (Bangladesh University of Engineering and Technologies), NSU (North South University) and EWU (East West University). The designer is a graduate of Dhaka University.

All development engineers are good problem solvers, strong in C++ or C# or Java, strong in OOP and are dedicated. One of them even went to ACM world finals.

So, overall, it's a brilliant team.

The project
The project is a medium scale web application. I cannot disclose the description of the project but the type of the project is to build and manage networks between two groups of people.

The project is fresh development from the scratch where we do not need to work on existing codebase. Let's call the project 'The Project' or TP in short ;).

TP has two sub projects, let's call them:
  • TPX - which is for the first user group
  • TPY - which is for the 2nd user group
TP also has another sub project for a group of people who need to administrate the whole application. Let's call it:
  • TPZ - which is for administrator users
Three of the sub-projects TPX, TPY and TPZ will serve different target user groups as mentioned above.

The project is targeted towards massive user groups, say several thousand from the first user group and hundreds of thousands from second user group will use the application within a year of lunching the application. The project will have rigorous database transactions for most of the features and functionalities.

Professional and rich user experience is very important in this project. The project will have good looking UI components, for which we have a dedicated graphics designer.

To be continued.
[I shall continue to talk about my project management experiences and thoughts about this project in regular posts. I hope you shall find them interesting or useful].

Empowerment of SQA

This has probably become a hot topic recently. The 'scope of the empowerment' really needs to be defined. What 'powers' does empowerment include and what not? Whatever we say it 'includes', does it apply to all projects? even of different types?

SQA team, if empowered, needs definition of what they can do and what not. There can be some serious do's. For example, can they stop a software release which has many bugs? If so, can your team, your company or the client effort it? What is the real intention of this action, better quality even if it hampers project timeline and the business of the client?

There can be some less serious do's of SQA empowerment, for example: SQA team suggests to improve usability (a simple example of this: a numeric textbox takes all characters and validates and shows error later on if the input is not a number. SQA team suggests that the textbox should allow only number keystrokes in the first place). Now this sort of details may not be mentioned in the spec and so, in general, the developers argue with the SQA (may be because they feel lazy). According to empowerment do's, should the SQA be able to insist the developers to follow the suggestion?

If you want to empower SQA and try to draw some lines on their do's and don'ts then you're most likely to rediscover a simple fact.
In most of the companies, SQA teams are so much dominated by the development team that they (SQA) cannot raise their voices even if they see something is terribly wrong. It's the problem with a developer's perspective of the SQA team. In general, a developer feels much superior to a similar ranking SQA and feels he (developer) know much more and his work is the most important thing in the project's success.

So, now the empowerment is needed to make the developers feel that SQAs have some power too (!!) and a developer cannot just overlook their suggestions(?). Is this the main reason behind empowerment of SQA? if so, then let's look at the origin of the issue again. Is it again a developer's mindset and his careless or superior attitude towards a SQA? Can this be fixed? And is the officially declared 'SQA empowerment' the only way?

In Bangladesh, most of the SQA engineers cannot do programming or understand mature coding and the 'white box' is just too much for them. Some seriously lack knowledge of latest technologies, techniques and advance skills (for example, only few SQAs have ever built and installed a software on Linux command prompt, unless it's a project-specific task). So, SQAs, in general, fall behind technical capabilities of developers. This should be addressed and SQAs need much improvement in the technical areas to make a good impression with rest of the team.

Developers should learn the importance of others' comments. One developer sometimes doesn't value the suggestions of other good developers, let alone the SQAs. Horribly some seniors do that as well! This issue needs to be handled by the Project Manager or above. Developers should receive a 'clear message' saying: not to overlook other's suggestions and comments and to strongly collaborate with the SQA team.

If you can handle the root of the problem, 'empowerment' or other 'forceful' ideas might not be needed. Peaceful solutions are good for the project health and the forceful ones might not be so, rather they can introduce chaos.