Dofactory.com
Dofactory.com
 Back to list
Views:   13.8K
Replies:  3
Archived

Question on Factory Method

Hi all,

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
Reply 1
Hi Yekta,

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.

Thanks,

Sakthi.
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
Reply 2
Hi Yekta:

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 
Shashi
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
Reply 3

HI Yekta,

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
which returns their own type.

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

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
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.