I am working on an application which contains code in lot of places where certain objects are created based on certain condition. The code is something like the following:
if(affectedObject == "Customer")
Customer c = new Customer();
else if(affectedObject == "Salesman")
SalesMan s = new SalesMan();
// Do some processing.
// Do another processing.
I have gone through design patterns once but I am not able to figure out how I can use a pattern to replace my code.
Can any one please help me with this? Any practical code sample would be of great help (code without refactoring and refactored code) so that I can understand it better.
Thanks in advance.
View Complete Post