Click here to Skip to main content
15,886,872 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

Suppose, my requirement is to build a salary calculation module, based out of department, how do I go about it?

For example, if my department is Sales, then my salary calculation has to go through a specific process viz., input fields, values, salary component calculation etc,.
If suppose it's Marketing, then a different calculation procedure has to be followed. How do I manage different calculation logic for different modules, based on the selected department?

I have experience in developing 3-tier applications already, so is there anything which I embed in the business layer or something? Please help.
Posted
Comments
Krunal Rohit 2-Dec-15 0:57am    
if...else maybe ?

-KR
Sergey Alexandrovich Kryukov 2-Dec-15 2:10am    
Sorry, the question is way too vague. The serious answer may require the whole architectural sketch of the project, to say the least; and it would inevitably pretty far from your particular functional model. Your concerns are quite legitimate; I would gladly help, but for me, it's hard to imagine a way to answer this question seriously and briefly enough (to fairly fit the format of this forum). It may take the whole essay on the topic "how to develop an application architecture?"

Considering your particular situation is nearly impossible, with your level of information. The effect of combinations of departments with salary calculation workflow can be solved in different levels. It depends on many factors. The effect can be simply demonstrated on just a small type hierarchy with just a few classes and/or interfaces; and dependency injection can be applied or not, or the workflow should be modeled in data. Or WWF can be used. And so on... Many things depend on how flexible the system should be to the possible changes, how similar are the steps in different departments, and so on...

Imagine for a second that I could consult you in person. I could talk with you and determine how much you could participate in the architecture of your module. I some cases I would advise you to learn something, in others I would desperately say "hire an application architect/designer", or would simply offer you some ideas. Right now, it's too hard to do.

—SA

1 solution

I think you need to abstract out calculation logic to concrete classes by creating a new interface for department.

You need to create an "IDepartment" interface with "CalculateSalary" method. This interface need to be overridden in concrete implementation for each department like for ex. "Sales" and "Marketing" classes with its own calculation logic.

So at run time you don't need to write "if.. else" but just need to call high level abstract method.

Hope this helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900