Re: advice about Interfaces
- From: "Joanna Carter \(TeamB\)" <joannac@xxxxxxxxxxxxxxx>
- Date: Mon, 25 Apr 2005 16:09:46 +0100
"Josema" <Jestrade@xxxxxxx> a écrit dans le message de news:
38ED1301-3D90-49FD-A947-046A2AF92EBB@xxxxxxxxxxxxxxxx
> - Class user: I would like to use this class user to register a user into
> the portal, this user will fill some textboxes, and will click into a
button.
> Then i will add to the database this preregistration, and send an email to
> the user to complete the registration....
I have taken time to think about what you are really trying to do, so see
what you think of the following :-)
Naming a class 'User' indicates that you want this class to describe a User,
not things like registration, databases, etc.
>From what you have said, you have at least two other classes involved in
this scenario, and they are the Register in which the Registrations are
kept, and the Registrations themselves.
Otherwise, how are you planning on coping with the same User being
registered more than once ?
The same applies to the Business class; this represents a Business and both
the User and the Business classes should be a separated from a Register
class, but linked to the Register by the use of a Registration class.
> As you see the two cases are similar, but the properties of fields of each
> classes are very differents. User has username, password, email,
nationality,
> receiveinfo, etc...
> Bussiness has Name of the bussiness, contactperson, password, address,
> email, city, receiveinfo.
>
> Both classes has to have three methods:
>
> Add()
> {
> //add code
> }
> Modify()
> {
> add code
> }
> Delete()
> {
> add code
> }
These methods do not belong in either of the USer or Business classes, they
are functionalities of the Register and Registration classes :
abstract class Profile
{
}
class User : Profile
{
}
class Business : Profile
{
}
class Registration
{
private Profile profile;
private WhateverTheRegistrationIsFor x;
public Registration(Profile profile, WhateverTheRegistrationIsFor x)
{
...
}
public void Modify()
{
if (profile.GetType().IsAssignableFrom(typeof(User)))
{
// edit User
}
else
{
// edit Business
}
}
}
class Register
{
public void Add(Registration registration)
{
...
}
public void Delete(Registration registration)
{
...
}
}
> Joanna, when you say call to the interface IPortal, i dont understood,
cause
> for me the portal cant be registered, modified, or deleted. Maybe could be
> good call to it IProfile. all the actions (add, delete, modify) are
related
Methods like Add and Delete do not apply to the thing that is being added or
deleted, they apply to the container to/from which the things are being
added/deleted.
Does any of the above make anyh more sense ?
Joanna
--
Joanna Carter (TeamB)
Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker
.
- References:
- advice about Interfaces
- From: Josema
- Re: advice about Interfaces
- From: Joanna Carter \(TeamB\)
- Re: advice about Interfaces
- From: Josema
- Re: advice about Interfaces
- From: Joanna Carter \(TeamB\)
- Re: advice about Interfaces
- From: Nick Malik [Microsoft]
- Re: advice about Interfaces
- From: Joanna Carter \(TeamB\)
- Re: advice about Interfaces
- From: Josema
- advice about Interfaces
- Prev by Date: string format
- Next by Date: Re: DLLImport and Marshalling
- Previous by thread: Re: advice about Interfaces
- Next by thread: Re: advice about Interfaces
- Index(es):
Relevant Pages
|