Thursday, February 18, 2010

Primitive Obsession

Primitive data types are the building block of any data representation. So, practically anyone can represent any data with primitive data types. We study programming logic by using primitive data types in school. So, everyone in software development world is comfortable to use primitive data types. It's easy to use, fast to execute and uses minimum memory.

But in object oriented programming using primitive data type to represent data makes huge complexity. Using primitive data types is the main reason to have code smells in the code. It is one of the main reason for duplicate code, large class and long method code smells. In most cases using primitive data types breaks most of the design principal.

If you feel that something is very wrong in your code, code smells like duplicate code, large class, long method all together then try to find if there is any primitive obsession exist in your code. If you find it and refactor the primitive obsession then that would help you to easily refactor other code smells.

Primitive obsession code smells is not limited to data types provided by any compiler. An object like XmlBuilder, StringBuilder, HashTable , Dictionary, Lists are also creates primitive obsession. So, use all these objects intelligently to avoid primitive obsession.

Sunday, February 14, 2010

Dead Code

We all love our code. So, we usually don't delete our code even if it is not referred anywhere in the system. Sometimes we comment the unused code. May be we will need that soon. All these are dead codes. Because these codes are never used and in most cases it will never be used. To manage the history of our code there are some other tool available. Source Control can archive all our code. Why do we need to keep the dead code in the working code? We can find any version of our code in the source control.

If a system have some dead code then there is a chance of spending time and effort while refactoring some production code. You might have to re-factor in dead code because compiler would complain in the dead code because of your refactoring. It becomes worst if you fail to identify the code is a dead code or not.

So, delete your dead code even if you spend big effort and created a beautiful logic. Don't hesitate. You may come-up with a better idea if you solve the same problem again. If you feel that the you might need the code in future then add a label in your source control. But delete the dead code.

Saturday, February 13, 2010

Technical Debt

We always write code which needs to be improved to insure better maintenance and readability of the code. That becomes the Technical Debt. It matches exactly to the financial process we used to follow. We always face in a situation where we need financial debt. From our experience we all agree that if we don't manage our debt in time we might face in a situation that we had to pay a huge interest. It happens in software. If we don't give enough time to minimize our technical debt then we face in a situation of project failure or redesign completely.

It's better if we agree that we always make technical debt, hence we have to minimize it regularly. Minimizing the technical debt should have equal priority as developing new features or fixing bugs.

So, learn to minimize technical debt and that skill will make you a real software professionals.

Friday, February 12, 2010

Long Method

A method is not easier to read or understand what it is doing. It has nothing to do with the size of the method. But if the size of a method is huge then obviously it is not easier to understand what it is doing. Naturally shorter method is easier to read. So, try extracting more shorter method to get rid of the long method.

Friday, September 18, 2009

Agile movement at KAZ Software

After we attended a three days workshop about Agile and another three days workshop about Refactoring code smells, design principal and design pattern, the whole motivation about software development changed in my mind. Thanks to Naresh Jain and BD Jobs to offer such a good workshop.

After the workshop we discuss about that in our team meeting, launch table and whenever we get some time. We looked at our code and feel the code smells. The workshop motivated us so much that we felt that every one of us should join. We offered Naresh Jain to do similar workshop for our company. But it was too late. He did not have visa and lots of other problems.

So we decided to organize similar workshop inside our company by ourself. But it was not so easy.
First Topu Bhai (Project Manager) planned to facilitate the prototype of the agile project management workshop. I'm using the term prototype because we did exactly same exercise, presentation and discussion. Topu Bhai did a very successful workshop on agile project management. If I mark Naresh Jain's workshop 100 then I will not mark Topu Bhai's workshop less then 80. His workshop changes a lot on our discussion topic. Everyone is discussing about agile and agile.

Then it was my turn to prototype the second workshop. I did lot of study one Naresh Jain's workshop and practice a lot with his material. As Naresh Jain explained a new way of writing code, new way of thinking about programming I did the same in Re-factoring Code Smell and Design Pattern & Design Principal workshop to others. We feel that refactoring is a new skill. Everyone doesn't have that even if he is a very good programmer. It needs a lot of practice.

Both the workshop made a huge change on us. Our management decided to introduce agile in our process. We formed a team to find a way to do that. Though we started in a limited scope but it was a good start.

I thanked our Knowledge Team and Tech Support to help us to organize such a wonderful workshop. Our tech team managed to setup 10 pair station in our meeting room with a projector. Finally I thanked our administration to facilitate everything we demanded.

Friday, October 06, 2006

Problem with sending SMS to Banglalink numbers

Some of my friends informed that they are not receiving SMS from my site. Here is the solution for that.

  • This system works with email service for the cellphone, so you need to subscribe that.
  • To subscribe for email go to Menu->Banglalink->SMSemail->Signup
  • It will charge for an SMS. This is the only charge you need.

Saturday, September 16, 2006

Facial Recognition Using Eigan Face

Face is an important biometric feature for personal identification. This paper describes a brief idea about face verification method based on principal component analysis, eigenface technology because it is widely implemented and well known for its simplicity and computational efficiency.

How it works?

The task of facial recognition is discriminating input image data into several classes (persons). The input images are highly noisy (e.g. the noise is caused by differing lighting conditions, pose etc.), yet the input images are not completely random and in spite of their differences there are patterns which occur in any input image. Such patterns, which can be observed in all images, could be in the domain of facial recognition the presence of some objects (eyes, nose, and mouth) in any face as well as relative distances between these objects. These characteristic features are called eigenface in the facial recognition domain (or principal components generally). They can be extracted out of original image data by means of a mathematical tool called Principal Component Analysis (PCA).

We can represent a training image as a two dimensional image having MxN dimensions. We can represent the same image as a vector having MN coordinates. A vector having MN coordinates can be thought as a point in a MN dimensional space. Now if we find the distance between two points in MN dimensional space, which is the representation of the image then we will find that the similar images are placed in the nearer location in that space. The problem with this technique is that the input images are very noisy. So, there is a chance that a different image is placed in the closer location. Principal component analysis solves this problem.

An eigenvector of a matrix is a vector such that, if multiplied with the matrix, the result is always an integer multiple of that vector. This integer value is the corresponding eigen value of the eigenvector. This relationship can be described by the equation M u = ? u, where u is an eigenvector of the matrix M and ? is the corresponding eigen value. Eigen values are the characteristic features of a matrix, we can reconstruct the original matrix from its eigen value and eigen vectors. The eigen vector having maximum eigen value represents the maximum characteristic features of the matrix. So, if we take the eigen vectors having larger eigen values and reject the eigen vectors having lower eigen values we construct an approximation of the original matrix having maximum characteristic features. In principal component analysis the eigen vectors are called as eigenface. By selecting the eigenface having larger eigen values we can construct a space having lower dimension from the higher dimensional training set where the maximum characteristics feature is present. Thus we can eliminate the unwanted features, which are not the part of the object. For example we can calculate MN eigenface from a MN dimensional space. If we take first T eigenface having larger eigen values, where MN>>T, then we can construct a space having T dimensions. This space is called as eigen space. So, the eigen space is constructed from the maximum characteristic features of the training image set.

As the images are represented as a point in a MN dimensional space, we can find the co-ordinates of a test image into the eigen space by projecting the image into the eigen space. Then we can find the distance between the two projected points on the eigen space projected from two different image by Euclidean distance.

We can set a threshold value theta, which will decide the classification of the test image.

Flowchart of face recognition is as follows..

Eigenface