Re: advice about Interfaces



Hi Joanna, Nick, Clint and Christian...

First of all sorry for my later response....

I read all the messages, but i see that i have a low level of this :-), but
i will try to explain myself, what im trying to do.

As i say, i have two clases that are in two diferent .cs files, and are like
this:

- 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....

- Class bussiness: This class will be very similar, a person will fill some
textboxes (about a bussiness), and will click into a button, then i will add
to the database this preregistration too, and send an email to the bussiness
to complete the registration.

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
}

As you see could be good create an interface with this three methods, and
then implement this interfaces in both classes. Then add code for each method
in each class.

My real problem its that i dont know if this way to do this its a good way.
And if its a good way, i dont know what its the best name for this interface.

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
with the profile of a user or a bussiness, or anything than can be delete,
added, or modify...

Thanks a lot to all.
Kind Regards.
Josema.




"Clint (cmueller@xxxxxxxxxxxxx)" wrote:

> I think what she means is that if you use your method, the classes go
> through the task of registering themselves, whereas if you use her
> means (IPortal, for example), the Portal itself handles registration of
>
> the users/businesses. In this case, You'd have something like:
>
>
> PortalClass.Register(User user);
> PortalClass.Modify(User user);
> PortalClass.Remove(User user);
>
>
> PortalClass.Register(Business business)...
>
>
> You get the point. Here, if businesses and users use the same code for
> adding, modifying and removing, it might be helpful to use an interface
>
> or some kind of interface to define common properties needed for
> business and users to be added, etc. Thats where I'd see the
> IRemovable, IModifiable, IRegistrable existing. At the same time, if a
> Business is just a User with some added functionality not related to
> removing, adding, or modifying, you can create the business class with
> User as a base class, then you'd only have the first three method
> declarations above.
>
> Clint
>
>
.


Quantcast