Question on Factory Method
I work on bus terminal project that website users can reserve and purchase bus tickets on. I have 2 levels of users: admin and other users. Admin and other users classes are empty and don't have any attribute. Their attributes are common and stored in their parent class (members super class). Child classes are different only in their methods (due to access permissions).
This hierarchy is stored in one table in SQL Server which consists of these fields: Memberid, Email (or Username), Password and Usertype. I don't have Usertype attribute in my parent class in class diagram. This field is just in the table on the database.
My first question is: How can I use Factory Method for detecting user type?
My second question is: Is it good that I create a class for permissions?
Yekta Yeganeh, Sep 03, 2010
Q1: How can I use Factory Method for detecting user type?
A1: For this scnerio I feel Factory Method not required.
Q2: Is it good that I create a class for permissions?
A2: U can have permission class, which will have Admin and Gust currently. In future if new role come you can add very well in this class its self.
Sakthivel Ganesan, Sep 20, 2010
Another workaround that does work is execute the MSI installation using the following format: msiexec /i 'c:\temp\DesignPatternFrameworkCS_4.0_1User\Design Pattern Framework 4.0 CS.msi' TARGETDIR="c:\temp\DOPatterns"
Nov 05, 2012
I don't see the need for you to use Factory Pattern. You can have a basic user class with all the needed parameters and methods. Any way to authenticate the user you need to pass the username and password to the database, along with this action you can get back the user class filled with the details and permissions which would tell you the user type. These are my thoughts and it is left to you to decide the best options available
Thanks and regards
Shashichandra K, Sep 06, 2010
while the workarounds are acceptable, it would be nice if you guys offered a download that was just the files... the install is nice for some people i'm sure, but it's really just the files we need. and in this case (no fault of yours of course), the install gets in the way of getting those files.
Jul 30, 2010
I am not sure whether I got your question correctly, but here my comments based on my understanding:
1. You can define the virtual function in parent class as GetUserType() and implement the same in the derived class
2. Generally for the permission, Enum is preferred datatype to use. Because it is value-type whereas class will be reference type which ask for more processing.
But at the end of the day it all depends on the requirements of your application.
Saurabh Saxena, Sep 06, 2010
Thank you Roman Rozinov!!! Your solution helped me get it installed.
Nov 13, 2012
It is simply not acceptable that the MSI has this flaw, regardless of whether it is a configuration error in Windows or not. Either supply the files in a zip or correct the MSI so it has another path as default.
Oct 12, 2012