Wednesday, June 29, 2011

What are the characteristics of a good requirement?

while different organizations and authors may describe a slightly modified list, the following characteristics are generally accepted as those defining a good requirement.
Cohesive:  The requirement defines a single aspect of the desired business process or system.
Complete:  The individual requirement is not missing necessary or relevant information.  Additionally, the entire set of requirements should cover all relevant requirements.
Consistent:  The requirement does not contradict another requirement.
Modifiable:  Like requirements should be grouped together to allow similar requirements to be modified together in order to maintain consistency.
Correct:  The requirement meets the actual business or system need.  An incorrect requirement can still be implemented resulting in a business process or system that does not meet the business needs.
Observable:   The requirement defines an aspect of the system that can be noticed or observed by a user.  This is often referred to as “Implementation Agnostic” as the requirement should not specify aspects of system architecture, physical design or implementation decisions.   These aspects of a system should be defined separately as constraints.
Feasible:  The requirement can be implemented within the constraints of the project including the agreed upon system architecture or other physical design or implementation decisions.
Unambiguous:  The requirement is written objectively such that there is only a single interpretation of the meaning of the requirement.
Verifiable:  It can be shown that the requirement has been met by the final solution via inspection, demonstration, test, or analysis.

Sunday, June 12, 2011

LZW Compression

LZW compression is a lossless compression technique, in which the quality of compressed data stills as good as the original, and the compressed data is reversable to exact original data. LZW Compression is named after its inventors Abraham Lempel, Jacob Ziv, and Terry Welch.
LZW compression is always used in GIF image files, and offered as an option in TIFF and PostScript.
A particular LZW compression algorithm takes each input sequence of bits of a given length  and creates an entry in a table (called a "dictionary" or "codebook") for that particular bit pattern, consisting of the pattern itself and a shorter code. As input is read, any pattern that has been read before results in the substitution of the shorter code, effectively compressing the total amount of input to something smaller.
The following flow chart illistrates the process of compressing data using LZW Compression:
and the following is the C# code of LZW Compression:
public List<int> LzwCompression()
{
try
{
int dictSize = 256;
var dicList = new List<List<int>>();
for (int i = 0; i < dictSize; i++)
{
var d = new List<int> {i};
dicList.Add(d);
}
List<int> w = new List<int>();
for (int i = 0; i < gifImage.Count; i++)
{
int c = gifImage[i];
List<int> temp = new List<int>();
int m = 0;
foreach (int z in w)
{
temp.Add(w[m]);
m++;
}
temp.Add(c);
if (ListIncluded(dicList, temp))
{
List<int> wc = new List<int>();
int n = 0;
foreach (int z in temp)
{
wc.Add(temp[n]);
n++;
}
w.Clear();
int q = 0;
foreach (int z in wc)
{
w.Add(wc[q]);
q++;
}
}
else
{
result.Add(GetIndex(dicList,w));
List<int> wc = new List<int>();
int n = 0;
foreach (int z in temp)
{
wc.Add(temp[n]);
n++;
}
dicList.Add(wc);
string sum = "";
foreach(int item in wc)
{
sum = sum + " " + item.ToString();
}
w.Clear();
w.Add(c);
}
}
if (w.Count != 0)
{
result.Add(GetIndex(dicList, w));
}
return result;
}
catch (Exception)
{
throw;
}
}