Three layers Achitecture in Qt



  • Can three tier Achitecture be implemented in Qt? ie
    I need to know how to implement the
    Data,
    Bussiness Logic &
    the UI

    Can i Develop the ui may in some other language and Use the same Bussiness Logic?

    thanks in advance



  • Why do you assume that changing language between the layers gives you better separation?

    Of course you can implement a layered architecture using Qt. And yes, if you do that right, you might be able to for instance easily exchange your Qt Widgets based UI layer for a QML based one later on.



  • Changing languages itself will not contribute to better separation at all, it will only increase complexity because of the necessity to use wrappers/bindings/native interface APIs and whatnot.

    It only makes some sense to have a different "language" for the GUI which doesn't really need to be any programming language but a descriptive/structure language, you can use XML, QML or even implement your own way to describe the UI and pass it to your own UI builder.

    How good the separation between the layers is - that is something defined by their design and implementation, changing the language will not give you better separation but more isolation, which will make it harder to work with and maintain your application.

    There are many languages that support calling native C++ (which Qt essentially is) but just because you can doesn't mean you have to.



  • Ok thanks. if i decide to use layers architecture in the same language,ie in Qt. i think that i would create a subdirs project which represents a great project.
    In which i will create 3 subprojects ( DAO,Business Logic, and UI).
    i think that the both first DAO and Business Logic are library project(.dll) and last will be an executable project(GUI project).
    In brief, as in C# .NET Business Logic project must use DAO's dll, and UI project use finally the Business Logic's dll .
    Can I process like that?
    What precautions should I take in terms of safety for success architecture and easy updates.
    [quote author="Andre" date="1348577115"]Why do you assume that changing language between the layers gives you better separation?

    Of course you can implement a layered architecture using Qt. And yes, if you do that right, you might be able to for instance easily exchange your Qt Widgets based UI layer for a QML based one later on. [/quote]



  • Of course you can do that. Not sure if actual different shared libraries would make sense though. We use static libraries for this purpose.

    I am not sure what you mean with 'safety' here.

    I get the feeling that you have picked up on this layer architecture thing somewhere, but you don't quite understand the ideas behind it. It is not a one size fits all kind of solution. Of course it is good to separate your application into different responsibilities, but it is not always the case that that results in three layers with the relations that you sketch out. Also, it will be more difficult than you think in practice to determine where the exact boundaries between the layers should be.



  • ok thanks. if i understand you well, you think that i could do that with static librairies but you doesn’t trust shared librairies.And it’s not always three layers architecture, i could have n layers architecture with n=3,4,5,6…..etc.

    [quote author="Andre" date="1348586872"]Of course you can do that. Not sure if actual different shared libraries would make sense though. We use static libraries for this purpose.

    I am not sure what you mean with 'safety' here.

    I get the feeling that you have picked up on this layer architecture thing somewhere, but you don't quite understand the ideas behind it. It is not a one size fits all kind of solution. Of course it is good to separate your application into different responsibilities, but it is not always the case that that results in three layers with the relations that you sketch out. Also, it will be more difficult than you think in practice to determine where the exact boundaries between the layers should be.[/quote]



  • You will spend more time trying to figure out the boundaries of those n layers than on the application itself. To be honest, you kind of create the impression you don't know what you are talking about, just heard something somewhere and picked it up.

    DAO is not a layer it is just an interface to the data layer and at least I consider it to be part of the application logic, you can have different DAOs to interface to different type of data layers and still use the same logic. Data is always a separate layer, whether you want to or not. Qt is not a language, it is a software development framework that uses the C++ language. Dynamic libraries have nothing to do with layers, you can have all your layers in a single file you can have every class in a different file, it's basically what makes sense. You can make your DAO a DLL so that you can easily distribute different data interfaces or update them without having to change the base application. You can even use the QPlugin APi to make a really modular architecture and compartmentalize the different blocks of your application, based on layer, based on functionality and whatnot.

    All in all, you sound like you are gearing up to do something that might turn out to be far too complex, at least that is the impression you create, and if it is not complex, then you don't really need all those considerations. Those types of concerns are typical for big projects with lots of experienced experts, not for people who don't even know what they are talking about. Take a step back, develop, learn from your mistakes, improve your designs, don't try to deal with stuff it is not yet time to deal with.



  • [quote author="maxoreli" date="1348595295"]ok thanks. if i understand you well, you think that i could do that with static librairies but you doesn’t trust shared librairies.And it’s not always three layers architecture, i could have n layers architecture with n=3,4,5,6…..etc.
    [/quote]

    It might not even be layers. There might be more layers, some layers may really consist of different area's, it all depends on the goal of your application. To get a quick impression, look what Google turns up if you search for "images of software architecture":https://www.google.com/search?num=10&hl=en&site=imghp&tbm=isch&source=hp&biw=1366&bih=667&q=software+architecture&oq=software+architecture&gs_l=img.12...0.0.0.2866.0.0.0.0.0.0.0.0..0.0...0.0...1ac.vqojMSPW9WI Do you notice how few of these consist of the three layers you talked about?

    Other than this, I agree with utcenter on this one. If you want to learn about software architecture, go and study that topic seriously. Nowadays, you can find excellent courses for free from renowned institutes like MIT, so there really is no excuse not to study anymore if you ask me.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.