Generic


Author
Message
Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I read an article and found this code.



IPersonFacade Facade = FacadeFactory.CreateFacade();



public interface IPersonFacade : IFacade { }





What does it meant? What is the meaning of ? What is the advantage of doing so?



Thank you
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
This is referring (I assume) to the facade design pattern. Here are some articles on it:



http://en.wikipedia.org/wiki/Facade_Pattern

http://www.dofactory.com/Patterns/PatternFacade.aspx

http://www.codeproject.com/KB/architecture/csdespat_3.aspx



This is one of the classic GOF design patterns. It's intent is to simply a more complex class to make it easier to use. Hopefully this will be helpful in answering your questions.



Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

Thank you for reply.

I think that is mistake on the code snippet. The bolded part was missing.



IPersonFacade Facade = FacadeFactory.CreateFacade<IPersonFacade>();



public interface IPersonFacade : IFacade<Person> { }




My question is more on usage on Generic in this sample code. What does it meant? What is the pros of doing so? What is the difference compare with "new" statement? Why not using type casting?



Thank you
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Chan,

I am not sure of the extent of your background in regards to Generics, but we use them often.  Now this is not a good place to get into a training session on Generics as this can become quite deep.  However, I highly recommend using Generics in this type of situation because it is all strong-typed and drasticaly reduces and streamlines code.

If you want to see some places within the framework that uses Generics so that you have a point of reference, you can look at the GenericBusinessBindingSource (Custom BBS) which allows you to pass in a BO and then from that point forward all references within that class are typed as that BO.  That would be my recommendation in trying to understand and get started with Generics.  There are also a lot of samples out on the web...but yes...I would definitely use Generics.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search