PDA

View Full Version : Recommended C++ QtWebApp architecture - more than just your tutorial



Szyk
20th May 2018, 21:43
Hi

[[THIS POST IS BASED ON EMAIL I HAVE SENT TO AUTHOR OF QTWEBAPP. AS HE SEEMS TO BE UNABLE TO RESPOND FOR SOME REASON.]]

I am fancy with C++, Qt, QtWebApp (http://stefanfrings.de/qtwebapp/index-en.html) and vision implementing www service using them. I want to write professional applications for my company. I want to introduce QWebApp to my boss as we will be started new projects soon.

I study your tutorial carefully and make some trying to implement mock www computer shop (just for studding purposes).

But I find some difficulties with this. I cover them in few points:

1. I want to use in my www server self describing and search engines friendly directory names and page names. So: I suppose to have addresses like this: www.myshop.com/products/monitors/iiyama-prolite-x2485ws instead: www.myshop.com/products/93939303.html

I suppose that the best idea is to have one template for www.myshop.com/products/monitors/ with out parameters, and two templates for every pages with some string after www.myshop.com/products/monitors/ in this case 'iiyama-prolite-x2485ws', as this will be showed in 2 modes: view (for customer) and edit (for operator).

But I have no idea how to design paths in flexible and efficient way... I want many categories like monitors, keyboards, memories, processors, and so on. I suppose to have subcategories like producer/trade mark, so my url should be like this: www.myshop.com/products/monitors/iiyama/prolite-x2485ws. More! As you can see my monitor is belong to brand 'prolite', so maybe sensible will be to have urls like this: www.myshop.com/products/monitors/iiyama/prolite/x2485ws.

How do you implement things like that?!?

2. I want to have multinational www server so I suppose to have:
www.myshop/en-GB/products/monitors/iiyama-prolite-x2485ws
or
www.myshop/de-DE/products/monitors/iiyama-prolite-x2485ws
or
www.myshop/pl-PL/products/monitors/iiyama-prolite-x2485ws
How to you think: Is this good approach to internationalization?!? Have you any better ideas?!? Do you think urls should be translated also?!? I mean some thing like this:
www.myshop/pl-PL/produkty/monitory/iiyama-prolite-x2485ws

3. I want to write time and memory efficient, object oriented, modular C++ programs, but: QtWebApp is of course mutithreaded, I keep it in mind and store everything on stack (to avoid mutex lock). That is mean that I use only plain functions instead objects. You may be ask why?!? I want to avoid memory allocation for every browser call. I don't know how to approach to this problem. Should I write my own memory buffering allocation for used objects?!? I mean for example: overload new and delete operators for some www related classes and store memory (let say) 25 last deleted objects in each class, and return them immediately instead use system allocator?!?

I suppose that good idea is: one class for one page, but I am not sure...

4. In real www pages headers and footers are the same for most of the pages in the www service. This is mean, that I have join some how headers (with session, and basket, and search options, and language settings) with rest of the pages. Do you store each part of the page in separate template?!? Or maybe you join every pages offline and fill them always as one page?!? The second option will slightly speed up server (I suppose). The second option can be done by server at its start. Or maybe there is some other solution?!? Please share ideas...

5. Plugins. Do you think is this sensible to implement www pages as qt plugins?!? I mean every page as plugin. I think this will be very cumber some (Qt Creator is very weak for multi projects systems), but maybe have some advantages like: good separations between pages, and possibility to adding new pages (or replace old one) in working server. The idea is that: to real directories (e. g. ~/www/pages/products/) add 3 plugins: 1) for list view, 2) for item view, 3 for edition. And 3 templates in directory ~/www/templates/en-GB/products/, and 3 others in ~/www/templates/de-DE/products/ and 3 others in ~/www/templates/pl-PL/products/

How do you think about this?!?

thank you in advance, and best regards

Szyk

ps. I wounder about how fast is QtWebApp compare to PHP - have you done some tests like this?!? Please share if so...

Added after 1 45 minutes:

Author of QtWebApp answered to my email today at 20:53. But your answers to this subject will be also appreciated.
I am not sure he allow me to publish his answer.
One of the issues arise is that I don't mentioned that I want to use QtWebApp for embedded environment.
Fell free to join discussion.