class design question

G

Guest

hey all,
i have an employee class that's part of an employee management system. If I
want to expose the employee's Leave time details (or any details of the
employee that's one-to-many) would I expose that as a property or a method?
Or does it matter?

thanks,
rodchar
 
M

Mike Hofer

hey all,
i have an employee class that's part of an employee management system. If I
want to expose the employee's Leave time details (or any details of the
employee that's one-to-many) would I expose that as a property or a method?
Or does it matter?

thanks,
rodchar

If the value is calculated, and doing so will trigger a series of
operations, or if doing so may take time, definitely implement it as a
method. Some examples might include querying a database, iterating
over a collection, or returning a clone of another object.

If the value is something that you want to be able to get or set,
implement it as a property. Also, if the value you want to return is
initialized during object construction, and likely isn't going to
change frequently over the lifetime of the object, a read-only
property might be suitable, especially if it's calculated before the
object is constructed.

When is the value calculated? Is it passed into the constructor?
 
G

Guest

Thank you for the generous help.

Mike Hofer said:
If the value is calculated, and doing so will trigger a series of
operations, or if doing so may take time, definitely implement it as a
method. Some examples might include querying a database, iterating
over a collection, or returning a clone of another object.

If the value is something that you want to be able to get or set,
implement it as a property. Also, if the value you want to return is
initialized during object construction, and likely isn't going to
change frequently over the lifetime of the object, a read-only
property might be suitable, especially if it's calculated before the
object is constructed.

When is the value calculated? Is it passed into the constructor?
 
S

susiedba

you don't need to do either.


you need to build a DATABASE and assigne permissions to the columns

OOP is a waste of time, kid
 

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

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top