Design question...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • M

    #1

    Design question...

    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)
    {
    securityCollect ion = security.getSec urity(empInfo);

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


    Thanks.!


  • Angie Ye

    #2
    Re: Design question...

    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(pr op.name, false);
    }
    // Oher init code
    }

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

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

    }

    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


    "M" <minnow31@hotma il.com> wrote in message
    news:9qadncPon4 vuK-6iU-KYuA@comcast.co m...[color=blue]
    > 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[/color]
    property[color=blue]
    > (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[/color]
    because[color=blue]
    > 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)
    > {
    > securityCollect ion = security.getSec urity(empInfo);
    >
    > foreach (property prop in empInfo)
    > {
    > foreach {securityItem sItem in securityCollect ion)
    > {
    > if (sItem.access(p rop))
    > {
    > set.prop = "Not accessible";
    > //or set a code that I can read in the asp.net/forms interface in the
    > datagrid
    > }
    > }
    > }
    > return empInfo
    > }
    > }
    >
    >
    > Thanks.!
    >
    >[/color]


    Comment

    Working...