Design Question - Repository Pattern

Design Question - Repository Pattern

Old forum URL: forums.lhotka.net/forums/t/6866.aspx


tna55 posted on Wednesday, April 29, 2009

All,

I have a design question and would appreciate any help by fellow developers.

Use Case: Get employee data for payroll processing

Objects & Responsibilities:

EmployeeList – Contain a list of employees to process payroll for.  Contain list of Employee object.

Employee – An employee for which payroll processing is required. Contain other objects:

BalanceList – A list of balances for the employee. Contain list of Balance object

Balance – A balance item.

So on...

It is a hierarchy of objects for a specific use case.

Now the question is that to fill this with data from database I have two options. One is to use something like deep data example. In which case EmployeeList (top level object) gets all data and passes the data to child objects which fill themselves.

The second option I came across recently is to use Repository type pattern where there is a set of classes that retrieve data and fill the object graph. E.g.

EmployeeList Employees = EmployeeListRepository.GetList();

The advantage I see in repository approach is that it seperates data access from business logic in BOs. I am just trying to understand which option is better in terms of design. Any thoughts and suggestions will help.

Regards,

Tahir

tna55 replied on Thursday, April 30, 2009

Any suggestions!

RockfordLhotka replied on Thursday, April 30, 2009

You might want to look at the ObjectFactory concept added in version 3.6. Also, read chapter 18 of the Expert 2008 Business Objects book where I discuss a range of data access techniques you can use with CSLA.

tna55 replied on Thursday, April 30, 2009

Rocky,

Thanks for the reply, I have read the suggested chapters now and yes they were useful in clarifying my concerns. Chapter 18 answers a lot of questions asked on these forums as well so anyone not clear about CSLA and Data Access or in general Business Objects and DAL should read that carefully.

Tahir

Copyright (c) Marimer LLC