How to implement this case in C#?

P

PenguinPig

Dear Experts,

Could you please provide you comment to me? Thanks

An Exhibition has many Halls, and different Booth Types
If exhibition is not exist, hall and booth type will not exist too.

In the object level, my design like follow, is this design elegance?

Class Exhibition
//Assume setter/Getter method of halls is available
//Assume setter/Getter method of booth types is available

private ArrayList halls;
private ArrayList boothTypes;

Class ExhibitionController
public void addExhibition(Exhibition) {
//implement
}

public void addHall(Hall) {
//implement
}

public void addBoothType(Boothtype) {
//implement
}

public Exhibition getExhibition(exhibition id) {
// get exhibition from database
// get hall from database
// get booth type from database
// return exhibition
}
}
 
S

SP

PenguinPig said:
Dear Experts,

Could you please provide you comment to me? Thanks

An Exhibition has many Halls, and different Booth Types
If exhibition is not exist, hall and booth type will not exist too.

You have not stated if there is any relationship between the halls and the
booth types. Is there?
In the object level, my design like follow, is this design elegance?

Class Exhibition
//Assume setter/Getter method of halls is available
//Assume setter/Getter method of booth types is available

private ArrayList halls;
private ArrayList boothTypes;

Class ExhibitionController
public void addExhibition(Exhibition) {
//implement

Don't like the "controller" name here. This seems more like a Registry
object where you will add and retrieve exhibitions from with the possibility
of it delegating to a builder if the requested exhibition is not found in
the registry.
public void addHall(Hall) {
//implement

Don't like this either. It would seem that as a hall is part of an
exhibition that you would do
Hall hall = myExhibition.Halls.Add();
Although if halls are shared amongst many different exhibitions then again
keeping the halls in a registry object is okay assuming that the same hall
in different exhibitions is considered to have the same identity.
public void addBoothType(Boothtype) {
//implement
}

public Exhibition getExhibition(exhibition id) {
// get exhibition from database
// get hall from database
// get booth type from database
// return exhibition
}

this seems okay and you should delgate this to a builder type object.

SP
 
M

Matthias Heise

Good evening,

in your case you should better use the Interface IList given in
System.Collections or better the generic Interface IList<T> given in
System.Collections.Generic. Also use the name Collection for a
controller that has all exhibitions. That's commonly used by Microsoft.

See the following Code:

public class Exhibition
{
List<Halls> halls;
List<Boothtype> boothType;
}

public class ExhibitionCollection : System.Collections.Generic.IList
{
public void Add(Exhibition item)
{
}

public bool Remove(Exhibition item)
{
}
}

The interface contains several more methods that need to be implemented.
Use the mouse pointer placed over the interface name in VS .NET 2005. I
recommend that you organize the items within the collection by previous
and next pointers.

Bye

Matthias
 

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

Top