Re: advice about Interfaces

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"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


.



Relevant Pages

  • Info. on your Services
    ... Register your business in the Support Services directory on K12 Academics. ... Register now and receive an additional four month listing for a total of 16 months. ... Quarterly Traffic Reports for your profile listing ...
    (freebsd-questions)
  • Legal Copies of Software (Was: "What are you running DOS on?")
    ... many friends in the computer business. ... > situation where my attempt to "register" (meaning along with paying money) ... However, morally, they should support the ...
    (comp.os.msdos.misc)
  • Re: Employer Identification Number
    ... You must register with the Illinois Department of Revenue if you conduct ... Register with IDOR before you make any sales or when you hire an employee. ... prominent location in the place of business to which it applies. ... A Federal Employer Identification Number (FEIN) is not required for all ...
    (misc.taxes)
  • Re: whats wrong with being a Sole Trader ??
    ... If however you start working for yourself, you must register with HMRC ... your business income is counted alongside your existing ... You will also pay income tax ... If your income from self-employment is low (below £4,635 in the tax ...
    (uk.consultants)
  • Re: whats wrong with being a Sole Trader ??
    ... If however you start working for yourself, you must register with HMRC ... your business income is counted alongside your existing ... You will also pay income tax ... If your income from self-employment is low (below £4,635 in the tax ...
    (uk.consultants)