Results 1 to 6 of 6

Thread: Facade design pattern implementation

  1. #1
    Join Date
    Sep 2012
    Posts
    31
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Talking Facade design pattern implementation

    Hi, I am currently working on a project where I must implement the facade design pattern.
    Here is the general set up of the project.

    The Qt project is composed of sub projects all grouped into one subdirs project.

    I have a QtMainProject in which the purpose is to load the main container UI and load the other sub projects via plugin loader.

    I have a QtTemplateProject that holds the main user interface of the project. Some modules inherit the user interface for reusability.

    The other modules are loaded via pluginloader. I'm a bit new to the facade design pattern and would want to know how I could make it work in such a way that the objects of the modules loaded can interact with one another.

    e.g.

    int main
    {

    //load plugins here
    //declared Facade class here?
    }




    class Facade
    {

    public:

    private:
    ClassModule1 _varName1;
    ClassModule2 _varName2;
    ClassModule3 _varName3;

    };

  2. #2
    Join Date
    Jun 2010
    Location
    Pretoria, South Africa
    Posts
    22
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Facade design pattern implementation

    Your example is a bit vague. If you have control over the design of the QtTemplateProject plugin class, then I suggest creating a set of signal and slot functions to act as communicating channels that are connected together by the Façade class.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Facade design pattern implementation

    A facade is everything that hides a number of low-level interacting interfaces behind a single (more high-level) interface. For instance QPainter is a facade for QPaintDevice and QPaintEngine. The fact whether you use plugins or not is totally irrelevant to the design pattern. I think it is plugins you are having problems with, not the design pattern. Without knowing the details of interfaces and their interaction it is hard to suggest anything.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Sep 2012
    Posts
    31
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Facade design pattern implementation

    thanks for the replies, will try to research more and provide a clearer example.

  5. #5
    Join Date
    Sep 2012
    Posts
    31
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Facade design pattern implementation

    hi guys, follow up question.

    Most of the examples I have seen so far declare the Facade class in int main() {}

    It is always necessary to do this?

    If for example I have a different class and this is what I declare in int main(), would it be okay if I declared my facade class there?

    example:

    int main()
    {

    MyClass1 *NewClass= new MyClass1();

    }


    and in MyClass1, I call several functions first before calling my Facade class.


    could anyone advise me on the matter? thanks!

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Facade design pattern implementation

    You can create your objects anywhere you want. Facades are no different here.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    ehnuh (4th November 2012)

Similar Threads

  1. Implementation considerations for data flow pattern
    By redBeard in forum Qt Programming
    Replies: 20
    Last Post: 12th January 2011, 00:25
  2. design pattern for supporting multiple DB's?
    By scarleton in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2010, 15:33
  3. Design pattern of qwt library
    By Hogwarts in forum Qwt
    Replies: 1
    Last Post: 4th June 2010, 11:04
  4. GIS design pattern
    By olosie in forum Qt Programming
    Replies: 2
    Last Post: 19th May 2009, 17:19
  5. Observer Design Pattern
    By joseph in forum General Programming
    Replies: 1
    Last Post: 21st January 2008, 13:17

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.