Facade Design Patterns and Subclassing

Posted by Code Sherpa on Stack Overflow See other posts from Stack Overflow or by Code Sherpa
Published on 2010-03-22T19:03:50Z Indexed on 2010/03/22 19:31 UTC
Read the original article Hit count: 413

Filed under:
|
|

Hi.

I am using a facade design pattern for a C# program. The program basically looks like this...

 public class Api
    {
        #region Constants

        private const int version = 1;

        #endregion


        #region Private Data

        private XProfile _profile;
        private XMembership _membership;
        private XRoles _role;

        #endregion Private Data


        public Api()
        {
            _membership =  new XMembership(); 
            _profile = new XProfile();
            _role = new XRoles();

        }

       public int GetUserId(string name)
       {
            return _membership.GetIdByName(name);
       }


}

Now, as I would like subclass my methods into three categories: Role, Profile, and Member. This will be easier on the developers eye because both Profile and Membership expose a lot of methods that look similar (and a few by Role). For example, getting a user's ID would look like:

int _id = Namespace.Api.Member.GetUserId("Henry222");

Can somebody "illustrate" how subclassing should work in this case to achieve the effect I am looking for?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about facade-pattern