Results 1 to 4 of 4

Thread: A programming style question for you experts...

  1. #1
    Join Date
    Jan 2011
    Location
    Richmond, VA
    Posts
    94
    Qt products
    Qt4
    Platforms
    MacOS X Windows
    Thanks
    14

    Default A programming style question for you experts...

    Hello all --

    I come from a functional programming background to trying to do a project in Qt/C++ -- 28 years worth of that background -- with the closest to OO being years of Ada and PL/SQL and using them in a simulated OO manner, so I'm curious about you how you experts out there approach your coding...Trying to learn Qt/C++/OO in a short time frame is proving to be, um, adventurous...

    With PL/SQL you can encapsulate processing and data within procedural specs and bodies in a similar nature to classes...I'm used to main programs calling packages which do a LOT of the work and very little of the work themselves, but all the examples that I've been thru tend to split processing...For example:

    I need to create a DB login screen and when the user logs in I need to verify credentials, and notify them if they can't log in...In something like PL/SQL all that processing, error and exception handling is hidden in the package -- where do ya'll commonly put that processing in Qt? I created a database management class to manage opening the DB, creating the tables (if it doesn't exist), and I'm basically wanting to put all the SQL processing there, but I'm interested to know where you put your error handling for that? In the mainmenu.cpp that accesses that class, or the class itself? Logically and stylistically, what do ya'll recommend? Generate error dialogs from the data management class or mainmenu? Does it really matter?


    scott

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 69 Times in 67 Posts

    Default Re: A programming style question for you experts...

    It is the GUI layer that asks for input and provides error dialogs to the outside world. Any worker objects should just try to work with the input and report failure to their gui layer caller. The database class should not be involved with GUI issues (neither input nor output). The main menu could be the place, although in a Qt based project the calling widget (when working with menus, probably the main window) should do user interaction.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Jan 2011
    Location
    Richmond, VA
    Posts
    94
    Qt products
    Qt4
    Platforms
    MacOS X Windows
    Thanks
    14

    Default Re: A programming style question for you experts...

    Huh -- lost my follow-up post...

    Thanks for the reply -- you make the exact argument I was making with my co-worker on this very subject who actually has more experience with this style of programming...I've been in a world of Oracle forms for a number of years that has embedded application processing and it's a BEAR to deal with...Finally, the vendor is extracting that out into APIs, separating the user interface from the actual processing, which makes a helluva lot more sense...My co-worker was arguing that *anything* related to the DB transaction/processing should be encapsulated together...

    thanks again!


    scott

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 348 Times in 333 Posts

    Default Re: A programming style question for you experts...

    Your should refer your co-worker to the Model View Controller pattern.

    http://en.wikipedia.org/wiki/Model%E...0%93Controller

    After all, in a future version of the project, there could be multiple views, so the data must be kept completely seperate from it.

Similar Threads

  1. Difference of Programming Style
    By alphazero in forum Newbie
    Replies: 4
    Last Post: 16th November 2010, 15:30
  2. Replies: 2
    Last Post: 9th February 2010, 17:27
  3. Model/View Programming: a question about data
    By QAlex in forum Qt Programming
    Replies: 1
    Last Post: 10th December 2009, 19:43
  4. A question about Model/View programming
    By awhite1159 in forum Qt Programming
    Replies: 5
    Last Post: 15th June 2008, 16:38
  5. quick question on model/view programming
    By locus in forum Qt Programming
    Replies: 1
    Last Post: 2nd February 2007, 11:04

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
  •  
Qt is a trademark of The Qt Company.