Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Design

Status
Not open for further replies.

transparent

Programmer
Sep 15, 2001
333
GB
I am writing a bespoke Contacts Information system.

The system will allow the user to search for companies, employees based on the data stored about them.

Each company will have a core set of information. For example Name, Head office address, telephone number. Each company will also have a collection of employees.

So I have defined a base class called Company

class Company
{

private string name;
private string address;
private string telephone;
private string fax
private PersonCollection employees;


//Rest of code here

//CRUD methods
}
The type PersonCollection is a strongly typed collection of Person objects.

The Person Object is a base class which defines the core information/functionality:

class Person
{
public enum sex {male,female,other}

private string name;
private sex sex;
private int age;

//Other information

//contains CRUD methods

public virtual Read ()
{
//Grab data from the database
}

}
All the People that work for my company (Acme) are currently registered with our exchange server, so rather than duplicate this data, my code will talk to the exchange server directly.

In this case then I need to extend my Person and override the Read method so that it uses the exchange server

i.e.

class AcmePerson : Person
{

//contains CRUD methods

public overrides Read ()
{
//Grab info from the exchange server
}




}

To populate a companies Employees in the case of the acme corporation, once again I need to use the exchange server. Ordinarily I have to use a database, so I will extend the Company object

class AcmeCompany : Company
{

//contains CRUD methods

public overrides Read ()
{
//Grab info from the exchange server
}

}

This is a little verbose - I have to override the base classes everytime a different data source is used. However by placing the data access code within these classes I force all data to adhere to my business rules.

Anyway. I have just been informed that different people within each company will be required to have different blocks of data associated with them. They could have any number of these blocks of information.

Example blocks of info:

1st Aid Knowledge
Experience with particular software etc
Spoken languages and fluency.

Every person wouldnt have all blocks of information

For example, a Medical Writer will have additional information about their previous publications etc etc, but not neccessarily info about 1st aid

I dont want to create one huge class to store all this information. I may be required to define additional blocks of information.


To complicate matters further, some of an individuals data may be stored in exchange server, and some of it in the database.

So to me, this would suggest a base class called person (as previously defined) with an additional collection of blocks of information.

Each block would be responsible for grabbing its own data from which ever source.

Does this sound like a good design?

I'm not sure how a person search could be implemented using this appraoch that would include all the data held in the blocks - I dont want to have to load in all the data into the system and then search!

What do people think?
 
I'm not a designer, but it sounds like a good start.

Company - Might you not get several companies at the same address etc? Might they not have several telphone numbers? Will your 'Persons' every have addresses etc.

If in doubt, I would pull the addresses etc out and put them in some form of address book, so that the lots of customers, and people can share them.

Also; are these employees, employees of the Companies in the list or of your company? Also, note that the requirement is changing, so lift the design to a slightly higher more general level, because it will probably continue to change.

Party - A class that has addresses, faxes etc.
Company - a subclass that specialises Party to allow for staff types, training courses, etc
Person - a subclass that specialises Party to allow for sex and age and training and non-company things. Training is probably a list of objects from a class that describes training.

Then you can keep personal details of the Managing Director, the Sales Director, and the receptionist of a Company. These are all Roles within a Company; they are NOT types of people. A person may have more than one role; the MD may also be the CEO and the Owner. They are relationships between a person and a company.

Likewise, I guess you will need Roles within a Person; First Aider, trainer, social organiser, etc.

Then also you might have Roles on the Party. Being a Customer may be a role that can be applied to Companies and to Persons.

Each class of Party, Person and Company can have an aggregate of Party/Person/Company Roles. Each of these Roles is then specialised by sub-classes for each Role; trainers and first aiders may need different data say.

I list all these extensions, but suggest you think about each one and bin those that you feel are overkill.

With regard to access to your data source, I cannot advise as the questions sound quite specific.

Gil
 
<Each block would be responsible for grabbing its own data from which ever source.

This is fine, up to a point. It's not too scalable, though: think about what happens when you have several hundred data sources, and are extending your person and/or company class each time just to handle it. Furthermore, your company and person classes will be handling data access in the same way, implying a code redundancy problem.

You might consider adding a "level of indirection" between your business class and your data source. See if you can create a class that handles data access for your person and company classes. You can implement your business rules there.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top