Gunter said:
I'm starting to write a QT-program on Linux but I'm not very experienced
yet. (hang on, it will be on topic)
What is the best way to go to design the lower level classes?
Should I use the standard libraries as much as possible so I can reuse the
classes maybe in the future in non-GUI programs?
Or is it best to use as much of the QT-libraries from the beginning?
For example string <-> QString.
My personal experience on using GUI libraries is that you should,
obviously, separate what all the functionalities of the program which
you can into their own portable modules (this is rather obvious for the
simple reason that it's good OOD), but trying to abstract away the
non-standard GUI library completely from your program is usually more
trouble than it's worth.
I once tried this, and the results were less than satisfactory. My
intention was to make a clean abstraction of the underlying GUI library,
ie. hide everything in it inside its own module in a way that would
allow me to change the underlying GUI library easily to something else
(eg. from gtk to wxwidgets or to qt or to native Windows API or whatever).
While this sounds like a great idea in theory (and it still is), in
practice the whole system became awkward, limited and hard to maintain
and expand. At one point I simply noticed that I was basically
replicating the underlying GUI public interface in my own "abstract"
module. While I got something working, in the end I was not very
satisfied with the result. (And, rather ironically, the underlying GUI
library was never changed to anything else, so all that abstracting
basically went to waste.)
Sure, liberally using the GUI library everywhere in your code will tie
your code to that library in question, but whether that's better or
worse than the alternative is not clear at all. In some cases a clever
design could allow a clean abstraction between your code and the
library, but it's not easy.