Results 1 to 3 of 3

Thread: Scope dilemma.

  1. #1
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Scope dilemma.

    Hello!

    I have a dilemma when creating cross-platform library for Qt.
    Library combines pieces of code from different OS (eg, Windows, Linux).

    The implementation and structure of classes in a library made in the "Qt Pimpl" style.

    BUT! This style can also be implemented in two variants:

    1. This is a "simple", without hiding the scope of the platform-dependent data types and constants
    (eg, HANDLE, termious, etc.).
    An example of this approach is Qt: QSettings.
    2. This is a "complex", with hiding the scope of a private helper class such as "engine".
    An example of this in Qt are: QFile, QAbstractSocket.

    I attached the enclosure to test projects (currently only for Windows)
    "scope_bad" and "scope_ok" which showcased two of these approaches:

    scope_bad - no hidden type HANDLE in the base class implementation.
    scope_ok - with a hidden type HANDLE in the base class implementation.

    Please Voice your opinion on the feasibility of these two approaches.

    PS: I'm more inclined to approach through the hide of scope.
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Scope dilemma.

    Method 1: This is adding a layer of abstraction, and gives a consistent interface to the application, which in sufficient for a simple library, you can go with it if you don't need abstraction internal to library.

    Method 2: This adds more than one layers of abstraction, and still gives the same consistent interface to application (as in Method 1), this will be useful if your library is complex and has a possibility to reuse OS abstractions internally, i.e if you have some other classes in the library, which re-use BaseEngine.

    I have quickly drawn something, conclusion is that if BaseEngine, is something which has a possibility to be re-used internal to library then go with Method 2, else I would be simple and go with Method 1. It some cases if BaseEngine is not re-usable as is, then it might be possible to fine grain BaseEngine, and separate the reusable parts of it, and still go with Method 2. Basically it is something how you design the framework internal to the library...

    scope.jpg

  3. #3
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Scope dilemma.

    Thank you.
    I consulted with our team and we have chosen a method â„–1 as the most optimal for this particular problem.

Similar Threads

  1. destructor dilemma
    By Petr_Kropotkin in forum General Programming
    Replies: 3
    Last Post: 17th March 2010, 15:58
  2. out of scope
    By mmm286 in forum Newbie
    Replies: 3
    Last Post: 23rd October 2009, 11:23
  3. Scope of UI
    By Dumbledore in forum Newbie
    Replies: 6
    Last Post: 15th November 2007, 10:43
  4. Caching QAbstractProxyModel dilemma
    By Alessandro in forum Qt Programming
    Replies: 2
    Last Post: 11th April 2006, 19:51
  5. enum scope
    By illuzioner in forum General Programming
    Replies: 1
    Last Post: 15th February 2006, 05:39

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.