Business object structure

M

^MisterJingo^

Hi all,

I have question regarding good practice. In the business layer I have
created, one object represents one part of the system. For example, if
I am manipulating clients, an instance of a 'client class' is
created. Sometimes I need to manipulate all clients in the database.
Would it be bad practice to create a method in client class which
allows the manipulation of all clients? For example, I have a page
which lists clients. To do this I have a method of client which returns
a dataset of all clients. So this method of a single instance of client
can provide data on all clients. To do this, client class can be
instantiated with a specific client Id (when working with a specific
client), or an 'empty' client object can be created to allow access
to all its methods which deal with all clients. I have to instantiate
the client class as the system uses an encapsulated database object
which is passed into each created object (and deals with all DB
connectivity).

Should I have separate objects to deal with single and all clients? Or
is this method acceptable?

Any opinions would be appreciated.
 
S

sloan

I try to keep the Client object isolated to what is germane to a Client.

You can find 1.1 and 2.0 example's of this at:


http://sholliday.spaces.msn.com/ 6/5/2006 5/24/2006 entries

I call mine "Controllers". Some people call them "Managers", but the idea
is the same.

(aka, if I have a Client object, I have a ClientController object )
 
T

Tim Van Wassenhove

Hi all,

I have question regarding good practice. In the business layer I have
created, one object represents one part of the system. For example, if
I am manipulating clients, an instance of a 'client class' is
created. Sometimes I need to manipulate all clients in the database.
Would it be bad practice to create a method in client class which
allows the manipulation of all clients? For example, I have a page
which lists clients. To do this I have a method of client which returns
a dataset of all clients. So this method of a single instance of client
can provide data on all clients. To do this, client class can be
instantiated with a specific client Id (when working with a specific
client), or an 'empty' client object can be created to allow access
to all its methods which deal with all clients. I have to instantiate
the client class as the system uses an encapsulated database object
which is passed into each created object (and deals with all DB
connectivity).

Should I have separate objects to deal with single and all clients? Or
is this method acceptable?

Since you want to manipulate Clients, i suggest that you add a class
Clients ;) (A container of Client)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,269
Latest member
vinaykumar_nevatia23

Latest Threads

Top