Saturday, November 16, 2013

QA - Classic Software Testing mistakes

Classic Software Testing mistakes – An introduction

Have you ever heard the expression “Been there, done that!”

Well…I have many times and when it comes to mistakes the above expression can be at least bit annoying, don’t you agree?


This is my point: We human beings are prone to mistakes have the habit of inadequately communicating and in most cases we are bad listeners as well.

Add the above flavors to the “Time vs Budget” recipe and you end up with a tasteless “This is not what I ordered” meal.

So what did go wrong? 
Have you come across the “Quality Triangle”?


Quality x Time x Money, if you had to select 2 out of the 3 which would you pick?


Generally speaking, the “winners” tend to be Time and Money. What about Quality you may ask? Well, that is something that we will try to squeeze in with as little resources as possible to execute as many tasks as possible within a time frame that is incorrect.  

Furthermore, if you contemplate the fact that the “Quality” element has been damaged it is plausible to assume that the entire SDLC could be at risk.

So if you are a tester like me you are probably saying…”been there, done that!”

When I look at the subject “Testing Classic mistakes”, I usually but not always blame the budget restrictions. If you as a company want to save some cash in the project you can within other options 1. Start cutting corners and/ or 2. Reduce overhead costs by hiring “Cheaper” labor.  That in turn could mean you have under skilled stuff.

Think about this:  Testing is a skill, it won’t just pop up from somewhere!  You need specific testers for a specific testing effort. You need a unique mindset, attitude, approach, work frame and methodologies that only testers can provide.

If not enough hard cash is made available for a suitable Software Development Project (as every project will have its own specific requirements), and as a consequence the project lacks the stuff and skills, maybe it’s time to hold back for a while.

Top management must clearly understand about the cost of software defects as a function of time.

There is a great article about this topic written by Donald Firesmith at the LinkedIn website.




Obviously, budget restrictions are not the only barrier when it comes to point the finger at the mistakes in the SQA environment, of course not.  There are quite a few that we must consider:

“…Most of the classic mistakes have seductive appeal, which is part of the reason they've been made often enough to be considered classics. Do you need to rescue a project that's behind schedule? Add more people. Do you want an earlier delivery date? Just set a more aggressive schedule. Should you keep a key contributor who's aggravating the rest of the team? Yes, the project is too important to let him go…” by Steve McConnel.

I will broadly write and briefly describe a list of mistakes which I think are at the core of the “Classic Mistakes” or as I like to call it “The Immortals”, let’s have a look at them: 

All the below examples will be better explained and analyzed on my next article.

1.      Testing Tasks and Responsibilities: A first major mistake people make is thinking that the testing team is responsible for assuring quality. Remember this short sentence “ Finding bugs important to customers”
2.      Prepare your testing effort correctly: test plans biased toward functional testing – make sure to cover cross functional areas - Insufficient diversity in test strategy -
3.      The work force: Make sure you have the right people to the right job!
4.      Let’s crack! Testers at work: Paying more attention to running tests than to designing them together with poor bug reporting are both classic mistakes.
5.      Test Automation: Attempting to automate all tests is not always cost effective and correct!

Apart from the above specific SQA issues, I would like to add a few more: (Why not?J)

6.      Bad-mannered Team members: Failure to deal with such problem can undermine the morale and motivation of the rest of the team and potentially increases stuff turnover, product quality and productivity.

7.      Abandoning planning under pressure: ran into schedule difficulties? Ditch the plane!  I mean the plan! No mitigation plan means the entire project is now in a chaotic state.


8.      Cutting corners: Projects that are in a hurry try to cut out nonessential activities, such as analysis, architecture, and design. From the Quality Assurance point of view the cuts will be executed by eradicating reviews and test planning.



The Ax cutting effect: Cuts at the QA activities early in the project means extra QA hours at the end of it.
The question now is how much it will cost to get it fixed?

9.      Lack of Change Control: How much of the software requirements can or probably will change until release?  

10.      Location and infrastructure: Too many people! Broken chair? Hard to concentrate?

That’s it folks, I hope you have enjoyed reading this article and looking forward to seeing you again soon.

Friday, October 11, 2013

C# - Working with the String Builder class

Overview

The String builder class allows us to manipulate strings without affecting the memory allocation while running the application. To use a “String Builder” you first need to initialize a new instance of the class, using one of the following options: 


Option 1: Creating instance and initialize it with a default value
static void Main(string[] args)
        {
         StringBuilder example = new StringBuilder("The String value");           
        }

As you can see, we created a new sting using a string builder which equals to:

String example1 = "The String value ";

Option 2: Creating instance without initialization

StringBuilder EmptyString = new StringBuilder();
           
Option 3: Creating an instance with expected string length
You can specify the size of the expected string, by specifying it you can reduce the default memory allocation when declaring the new builder.

StringBuilder ExpectedLength = new StringBuilder(100);

Builder Properties and Methods

Like the ‘string’ class, the builder class uncovers few methods and properties that can be used while manipulating the initialized string, the next few examples will demonstrate how to achieve the best from them.

Append, AppendLine and AppendFormat methods
This three methods allow you to add additional syntax to initialized builder, the following example demonstrate how to use thus methods.

Example 1:
Append – add syntax without moving to next line

static void Main(string[] args)
        {
            StringBuilder PhoneNumber = new StringBuilder("My Name is : ");
            //Adding values directly (Option 1)

            PhoneNumber.Append("David\n");  
            PhoneNumber.Append("My Phone number: ");

            //Adding values using loop (Option 2)

            for (int i = 0; i < 9; i++)
            {
                PhoneNumber.Append(i);               
            }
            Console.WriteLine(PhoneNumber);
        }
    }

Result:
My Name is: David
My Phone number: 012345678

Example 2:
Append Line – Add syntax and start a new line

class Program
    {
        static void Main(string[] args)
        {
          StringBuilder PhoneNumber = new StringBuilder("My Name is : ");

            //Adding values directly (Option 1)

            PhoneNumber.AppendLine("David");  
            PhoneNumber.AppendLine("My Phone number: ");

            //Adding values using loop (Option 2)

            for (int i = 0; i < 9; i++)
            {
                PhoneNumber.Append(i);               
            }
            Console.WriteLine(PhoneNumber);
        }
    }

Result:
My Name is: David
My Phone number: 012345678

Example 3:
AppendFormat – this method allows you to modify specific values in your builder, as a result the code become much clearer for reading.

class Program
    {
        static void Main(string[] args)
        {   
            string BestMovieEver = "Rambo 2" ;
            string BestTvShow = "Oz";       

            StringBuilder FormatBuilder = new StringBuilder();
            FormatBuilder.AppendFormat
            (@"{0} is the Best Movie Ever!!!
            {1} is the best Tv Show", BestMovieEver,BestTvShow);
            Console.WriteLine(FormatBuilder);
        }
    }

Result:
Rambo 2 is the Best Movie Ever!!!
Oz is the best Tv Show!!!

Replace method
The ‘Replace’ method allow you to change values in specific string, the value can be simple char or long string (just like the ‘String’ class).

Note!
The only thing you must remember that this method will replace all instances and not a specific one.

class Program
    {
        static void Main(string[] args)
        {
            //Example 1:
            StringBuilder ReplaceValue = new StringBuilder("My name is : None");
            ReplaceValue.Replace("None" ,"David .T.");
            Console.WriteLine("Example 1 : " + ReplaceValue);

            //Example 2:
            StringBuilder ReplaceMultipleValues = new StringBuilder("0-1-0-1-0-1-0");

            ReplaceMultipleValues.Replace("0", "2");

            Console.WriteLine("Example 2 : " + ReplaceMultipleValues);        

        }

    }

Result:

Example 1: My name is: David .T.

Example 2: 2-1-2-1-2-1-2

Builder as ‘Char’ array
Like the sting object, the string builder is construct from a ‘Char’ array

 class Program
    {
        static void Main(string[] args)
        {
            StringBuilder CharsArray = new StringBuilder("aD");    

            //using builder as char array

            Console.WriteLine("Example 1:");

            Console.WriteLine("Changing specific char to Upper : " + char.ToUpper(CharsArray[0])); //Change single char to Upper case(a -> A)

            Console.WriteLine("Changing specific char to Lowe : " + char.ToLower(CharsArray[1])); //Change single char to Lower case(D -> d)                       

            //Moving builder into char array

            char[] CA = new char[CharsArray.Length];
            for (int i = 0; i < CA.Length; i++)
            {               
                CA[i] = CharsArray[i];                  
            }
            Console.WriteLine("\nExample 2:");
            foreach (var item in CA)
            {
                Console.Write(item);
            }
            Console.WriteLine();
        }
    }

 Result:

Example 1:
Changing specific char to Upper: A
Changing specific char to lower: d

Example 2:
aD

Clear method
The ‘Clear’ method will remove all data from a builder.
  class Program 
    {
        static void Main(string[] args)
        {
            StringBuilder clearvalues = new StringBuilder("1984");
            Console.WriteLine("Before : " + clearvalues);
            clearvalues.Clear();
            Console.WriteLine("After : " + clearvalues);
        }
    }

 Result:
Before: 1984
After:

Remove method
This method allow you to remove specific range of characters based on builder indexes.

class Program
    {
        static void Main(string[] args)
        {
            StringBuilder Remove = new StringBuilder("123456789");
            Console.WriteLine("Before : " + Remove);
            Remove.Remove(6,2);

            //Starting the removal from index 6
            //Remove 2 characters from index 6

            Console.WriteLine("After : " + Remove);
        }
    }

Result:
Before: 123456789
After: 1234569

Working with specific indexer
As explained, string builder construct from single chars, therefore we can use this issue to manipulate specific chars inside the builder.

class Program
    {
        static void Main(string[] args)
        {
            //Step 1: Creating builder
            StringBuilder changebyindexer = new StringBuilder("ABCD");

            //Step 2: Printing builder based on indexer
            Console.WriteLine("Original Builder : ");
            PrintingValues(changebyindexer);

            //Step 3:Changing value for indexer 2 and 4
            changebyindexer[1] = '1';
            changebyindexer[3] = '2';

            //Step 4: Printing builder after modification
            Console.WriteLine("Builder after modification : ");
            PrintingValues(changebyindexer);
        }

        private static void PrintingValues(StringBuilder changebyindexer)
        {
            for (int i = 0; i < changebyindexer.Length; i++)
            {
                Console.WriteLine("Indexer : {0}, Value :{1} ", i, changebyindexer[i]);
            }
            Console.WriteLine();
        }
    }

Result:
Original Builder:

Indexer: 0, Value: A

Indexer: 1, Value: B

Indexer: 2, Value: C

Indexer: 3, Value: D

Builder after modification:

Indexer: 0, Value: A

Indexer: 1, Value: 1

Indexer: 2, Value: C

Indexer: 3, Value: 2

Press any key to continue . . .

My Presentations