Wednesday, June 25, 2008

Few Software Development Knowledge

What are the benefits of OOD?
o Object oriented design facilitates “Reusability”, “Extensibility” and “Modularity” of the software. We can divide the software into many components/classes so that “Abstraction” can be done on the changing part and non changing part to support the “changeability”. Plus Inheritance, Composition and polymorphism will always help in implementation.


Explain how the Garbage Collector works in C#
o The GC of the C# (.Net rather) is a cool component in .NET framework. Being a C++ programmer, I truly understand the importance of it. I don’t need to worry about allocating /freeing the memory once I use it in .net.
In c#, all the object memory management is done in “Managed heap. GC collects the unused memory based on metadata information which gives the memory layout of the created object. It performs the collection in two phases.

Mark -> GC first finds the root of each object and traverse to the bottom of it adding each object and make a graph of it. It does not add the object already in the graph. The object not in a graph considered as a garbage.


Compact -> in this step, GC pushes the entire live object down to the heap re-arranging the pointers and making the free space on the top of the heap. It corrects the pointers in moving the object here and there.

What's the difference between Dispose and Finalize?
o Dispose and Finalize are both to remove the unmanaged memory allocated by the object. Dispose is an explicit way and programmers need to implement Idisposable interface where as finalize is the implicit way to free the memory and called by GC. Developer is not supposed to call the finalize method on an object but he/she can call dispose method. Microsoft recommends that we implement both Dispose and Finalize when working with unmanaged resources. The correct sequence then would be for a developer to call Dispose. The Finalize implementation would run and the resources would still be released when the object is garbage collected even if a developer neglected to call the Dispose method explicitly.

What are the drawbacks in using the String class in C#?
o String class in C# is immutable and new memory is created whenever value of it is changed. If we do some operations of String object, a new memory is created and value is copied over there. This is a major problem if we use the long/huge string and manipulate it in C# Program.


How does StringBuilder improve on that?
o StringBuilder is a Mutable class and new memory is not referenced when it value gets changed.


What is an abstract class and when would you use it.
o Abstact class is a class having at least one abstract method/property on it. Abstract class cannot be instantiated and is a base class for other classes. We cannot use “sealed” keyword on it to prevent other classes to inherit from it. It is used when Common methods are implemented in a base class but other methods/properties will be changed in child classes.


Test a stapler, provide all the test cases
Requirement test:
Size (length, breadth and height) of it.
Color of it.
Weight of it.
Size of Pin in it.
Does it have stapler indicator?
What type of metal used to make it?
It is magnetic?
Functional test:
what happens if you put bigger stapler pin?
What happens when it is jammed?
How does it work when there is no pin? Does it produce sound? or indicator blinks?
Does it have a base?
Does it have a body?
Does it have a rear pivot?
What is the max depth it can be used.
What happens if the size of the pin is smaller or bigger?
Does it have a staple exit?
What happens if I staple materials other then paper?
Usability Test:
can blind person use it?
Can a person with one only one hand use it?
What is the age limit to use it?
Does it contain harmful materials?
How much different size of Staplers it can use?
Do you need manual to use it?
Mass testing
All the staplers are of the same size and same functionality?
Do they have same materials?
Stress Testing
What max temp it can bear?
What is the min temp its spring can bear or work?
How much pressure needed to break it ?
Does it break if it falls from my desk or from the running vehicle?
Performance Test:
. How many staples can be stapled in the stapler's use-full life?
How many staples can be stapled in a sec or a minute?

Rule Test:
Do you need license to use it?
Does it harmful to the minor?
Do you need to tell which country is it made?
Does it expiration date? (Note: this is funny)



Test an API called FormatURL which takes as an input a http URL string and replaces all special characters eg: space with %20 etc.,
o Test cases:
FormatURL(http://www.yahoo.com?name=deepak%20dhakal)
FormatURL(http://www.yahoo.com?name=%20%7Bdeepakdhakal)
FormatURL(http://www.yahoo.com?name=%20%7Bdeepakdhakal%20%5D)
FormatURL(http://www.yahoo.com?name=%21%7Bdeepakdhakal%20%5D) //non existence code
FormatURL(http://www.yahoo.com?name=%20)
FormatURL(“”)
FormatURL(“%7D”)
FormatURL(“%AAAA”)
FormatURL(%%%)
FormatURL(http://www.yahoo.com? %%%)
FormatURL(http://www.yahoo.com)