I am building a solution for the recruitment division of an organization. The requirement is to create new employee records in the organization's database for the applicants who have cleared the interviews and are joining the organization.
I have built an API to receive the 'Applicant' object from my HR system and create an 'Employee' record for the same. I am using Adapter Pattern to transform 'Applicant' object to 'Employee' object.
This transformation is a multi step process. Like
Step 1) Transform applicant's personal information. Step 2) Transform her educational qualifications. Step 3) Transform her previous experiences. Step 4) Transform financial records of the employee.
The above solution works good. Now the organization has to consider applicants who are being referred from a recruitment agency. In that case, most of the applicant's information such as personal information would not be available in the organization's database. But my Source object would contain an Applicant Id as well as an applicant type (denoting she is referred from recruitment agency), with which I can invoke a webservice to get the applicant's personal information and do the transformation.
So to describe it in a higher level, the proposed solution should decide which route to take based on the applicant type for certain steps in my adapter transformation, either to look for the information in source object or invoke a web service.
My question is how to introduce this condition based execution (based on the applicant type) for certain steps in the existing adapter pattern. My architect doesn't want to change to a different design pattern, rather we would like to achieve this conditional execution with the same adapters. Any suggestions to help us start with this could be of great help.
Thanks in advance. Happy learning !!!
ifstatements everywhere in your existing classes is not very scalable (development-wise).