Dependency between multiple classes

Posted by CliffC on Stack Overflow See other posts from Stack Overflow or by CliffC
Published on 2010-04-01T05:27:41Z Indexed on 2010/04/01 5:33 UTC
Read the original article Hit count: 386

Filed under:
|

I am confuse between the best way to organize dependency between multiple classes
assume i have the following classes Employee, Salary, DataAccess

Should i go for: Option1

Employee emp = new Employee();
Salary sal = new Salary();
DataAccess data = new DataAccess();

sal.Calculate(emp);
data.Save(emp);

or Option2

Employee emp = new Employee();
Salary sal = new Salary();

sal.Calculate(emp); //once salary has been calculated salary object will initialize  data access class to do the actual saving.

or Option 3

Employee emp = new Employee();
emp.Calculate(); // employee object will encapsulate both the salary and data access object

© Stack Overflow or respective owner

Related posts about oop

Related posts about c#