Design question...

  • Thread starter Thread starter M
  • Start date Start date
M

M

You have a security collection and an employee collection. The security
collection has a bool for each property of the employee collection, which
states whether or not a particular user has access to each employee property
(i.e., user can see ssNo property, but not salary property).

What sort of design pattern would you use to develop such an app?

Application: on user login, each page has a list of employees, and each
employee has information/properties that the security collection knows the
security setting for. You have to block out salary info for each employee,
but nothing else, for example.



My guess is the following pseudocode, but it looks memory intensive because
for each employee in my employee list, I have to run this loop for the
security check. How can I make sure a security look up is only necessary
once for the whole list of employees?

This is pseudocode:




class empInfo
{
string ssNumber;
decimal hourlyRate;
DateTime dateOfBirth;

securitySetter(empInfo)
{
securityCollection = security.getSecurity(empInfo);

foreach (property prop in empInfo)
{
foreach {securityItem sItem in securityCollection)
{
if (sItem.access(prop))
{
set.prop = "Not accessible";
//or set a code that I can read in the asp.net/forms interface in the
datagrid
}
}
}
return empInfo
}
}


Thanks.!
 
I would implement the security object as a HashTable with each property name
of the employee as the key and the bool as the value. The pseudocode will be
something like:

class EmpInfo
{
string ssNumber;
decimal hourlyRate;
DateTime dateOfBirth;
HashTable security;

// Constructor
public EmpInfo()
{
// Disable access to all properties by default (or enable access to some
if you want).
security = new HashTable();
foreach (property prop in EmpInfo)
{
security.Add(prop.name, false);
}
// Oher init code
}

public HashTable Security
{
get { return security; }
set { security = value; }
}

// some method
void MethodA()
{
if(security["hourlyRate"])
DisplayHoulyRate();
}

}

The security manager code can construct a security HashTable for each
employee or each group of employees, then set the Security property of the
corresponding employee(s).

Angie
 
Back
Top