473,322 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Way to build classes

Hi,

Im make an application to register users...

This application first check if the user exists, and if not, add the user to
database.

I have:

------------- class database---------------:

- A method to verify if the user exists.
* if the user exists call a method that fire an event (UserExists event)
* if the user dont exists call a method that fire an event
(UsernotExists event)

- A method to add a user.
* IF the user was added call a method that fire an event(Useradded event)
* IF the user was added call a method that fire an event(Usernotadded
event)

----------------class User---------------------:

- this class is suscribed to the UserExists and UserDontExists events.
- this class is suscribed to the UserAdded and UsernotAdded events.

- A method called Manage User:
* Makes an instance of the database class, and call to the userexist
method

----------------------------------------------------

I would like to know what its the best way to do that, cause following this
way i follow, i need to have 4 events in the database class (user exists,
user dont exists, user added, user dont added), and comunicate this events
with the class user, and then have another 4 events for the user class to
comunicate these events to the WebForm.aspx.cs that its the page that makes
an instance of the User Class when the button of register its clicked.

Any advice would be grateful.
------------
Thanks
Regards.
Josema
Nov 16 '05 #1
2 1027
The key to your question is in the name of your "events". Events should
indicate actions or changes - i.e. past tense verbs.

"Exists" or "does not exist" is a yes/no fact, not a verb. Though "added"
is a verb, it is also a yes/no fact. Either way, you aren't really looking
to respond to that event, you're looking for a yes/no value indicating the
success of the add operation.

Because of these considerations, you should:

1. Consider using a boolean property for Exists and testing for, and
setting the value of, that property in your constructor.
2. Consider returning a boolean value from your AddUser method and
responding to the return value rather than to an event. In the AddUser
method, set the Exists property based on the success or failure of the
AddUser method.

HTH

DalePres
MCAD, MCDBA, MCSE

"Josema" <Je******@ocu.org> wrote in message
news:E1**********************************@microsof t.com...
Hi,

Im make an application to register users...

This application first check if the user exists, and if not, add the user
to
database.

I have:

------------- class database---------------:

- A method to verify if the user exists.
* if the user exists call a method that fire an event (UserExists
event)
* if the user dont exists call a method that fire an event
(UsernotExists event)

- A method to add a user.
* IF the user was added call a method that fire an event(Useradded
event)
* IF the user was added call a method that fire an event(Usernotadded
event)

----------------class User---------------------:

- this class is suscribed to the UserExists and UserDontExists events.
- this class is suscribed to the UserAdded and UsernotAdded events.

- A method called Manage User:
* Makes an instance of the database class, and call to the userexist
method

----------------------------------------------------

I would like to know what its the best way to do that, cause following
this
way i follow, i need to have 4 events in the database class (user exists,
user dont exists, user added, user dont added), and comunicate this events
with the class user, and then have another 4 events for the user class to
comunicate these events to the WebForm.aspx.cs that its the page that
makes
an instance of the User Class when the button of register its clicked.

Any advice would be grateful.
------------
Thanks
Regards.
Josema

Nov 16 '05 #2
Hi DalePres,

Thanks for this clear explanation, i modify my application to use boolean
variables to see if the operation its completed or not, with a little
difference. I observed in some websites that its good to use for this kind of
stuff ref variables... And works perfect, a method of class can call to a
method in another class passing a ref bool variable to another method in
another class, and so on... This way when i make the first call to the method
passing the variable by reference, i can see if the operation was sucessfully
complete...

Thanks DalePres.
Kind Regards.
Josema.
"DalePres" wrote:
The key to your question is in the name of your "events". Events should
indicate actions or changes - i.e. past tense verbs.

"Exists" or "does not exist" is a yes/no fact, not a verb. Though "added"
is a verb, it is also a yes/no fact. Either way, you aren't really looking
to respond to that event, you're looking for a yes/no value indicating the
success of the add operation.

Because of these considerations, you should:

1. Consider using a boolean property for Exists and testing for, and
setting the value of, that property in your constructor.
2. Consider returning a boolean value from your AddUser method and
responding to the return value rather than to an event. In the AddUser
method, set the Exists property based on the success or failure of the
AddUser method.

HTH

DalePres
MCAD, MCDBA, MCSE

"Josema" <Je******@ocu.org> wrote in message
news:E1**********************************@microsof t.com...
Hi,

Im make an application to register users...

This application first check if the user exists, and if not, add the user
to
database.

I have:

------------- class database---------------:

- A method to verify if the user exists.
* if the user exists call a method that fire an event (UserExists
event)
* if the user dont exists call a method that fire an event
(UsernotExists event)

- A method to add a user.
* IF the user was added call a method that fire an event(Useradded
event)
* IF the user was added call a method that fire an event(Usernotadded
event)

----------------class User---------------------:

- this class is suscribed to the UserExists and UserDontExists events.
- this class is suscribed to the UserAdded and UsernotAdded events.

- A method called Manage User:
* Makes an instance of the database class, and call to the userexist
method

----------------------------------------------------

I would like to know what its the best way to do that, cause following
this
way i follow, i need to have 4 events in the database class (user exists,
user dont exists, user added, user dont added), and comunicate this events
with the class user, and then have another 4 events for the user class to
comunicate these events to the WebForm.aspx.cs that its the page that
makes
an instance of the User Class when the button of register its clicked.

Any advice would be grateful.
------------
Thanks
Regards.
Josema


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stuart MacMartin | last post by:
Looking for tricks for speeding up builds... We have an application with about 970 of our own classes of various sizes plus a fair number of routines. Over the past year the compile/link time...
1
by: lester | last post by:
I'm using a C++ dll and need to allow unsafe code because the dll function takes char *. I am using Visual Studio.NET 2002. Everything I've seen says to go to the project properties page, then the...
6
by: Marco Zapletal | last post by:
hi list, i have an c# project, which contains some additional classes (nunit testclasses), which are not needed in a release build? is it possible to exclude them in the release build process? ...
8
by: ucasesoftware | last post by:
Is a software exist to help us to build our class ?
3
by: musosdev | last post by:
Hi guys Okay, I've setup my projects to open and compile fine in VS2005 using FPSE and remote web, but it's *really* slow. So I thought I'd have a go at doing it the normal way, by loading from...
5
by: Doug Kent | last post by:
Sorry if this isn't really the proper group to which to post this topic, but ..NET is my development community, and I'm sure a lot of you might have something to say about this. :-) Scenario: ...
2
by: keepyourstupidspam | last post by:
Hi, I have a strange build problem. I am building an exe, this exe links to a number of static libraries maybe 20 in all and all are built from my code. I am using the gmake build system...
12
by: Ilias Lazaridis | last post by:
Another topic has raised the need of a deeper teach-in. Where can I find _compact_ documentation about * Differece between New Style / Old Style Classes Are there any documents available...
2
by: Nick | last post by:
So, this link: http://msdn2.microsoft.com/en-us/library/54dwfbb7.aspx says, "The build order is inferred from the top-down order of the codeSubDirectories collection. The App_Code directory is...
7
by: Charles D Hixson | last post by:
I'm sure I've read before about how to construct prototypes in Python, but I haven't been able to track it down (or figure it out). What I basically want is a kind of class that has both class...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.