How to Build the Safest and Most Scalable QT project
-
Hi, gurus! Thank you for considering my post.
I have been involved in QT project development for many years, and I have asked this question every time I build and develop a project. However, I still cannot find a perfect answer.
Of course, there is no such thing as perfect, but there must be a good way.
I always thought that whenever there is something to refactor during development, I will consider it as an experience and apply that method to build the project next time, but I still have not figured out a clear way.That is why I came here today to talk with QT experts and enthusiasts.
So how can we create a safe and scalable project? And how should we structure the project in the most appropriate way for that?
-
@crimson1023 said in How to Build the Safest and Most Scalable QT project:
I still cannot find a perfect answer
Because you're asking a quite generic question.
There is a lot of information about this topic including books, so not sure what kind of answer you expect to get on a forum. -
Thank you for reaching out. But if you are on the situation to build the project from the scratch, you might make sense how to architect the project. If the project is built smoothly, you will know what to add to what part without any further thought. I would like to hear that point from you. How does that sound?
-
@crimson1023
I am afraid it sounds just as "generic" as your original post. A forum like this is not going to offer useful thoughts/simple answers on "how to architect the project", that is a general software engineering question for which thousands of books/posts are available, precisely because it's a big question without simple answers.If the project is built smoothly, you will know what to add to what part without any further thought
It is never the case that one can program, modify or add anything to a software project "without any further thought"! That is a recipe for problems. If one could do that we would not need developers.
-
So, if you were to develop a chat app project similar to Discord or Telegram, how would you structure the project and what parts could be updated? Is this question also absurd?
-
I would start from a user's perspective:
- What benefit does the product/service bring to the end user?
- How does it compare to existing similar products and services? What would be the main differences / unique selling points?
The better you understand what you want to achieve, the better your chances of finding an architecture that fits.
You might want to write a really fast prototype to test out some ideas and technologies. But make sure the prototype code does not creep into the end result (or only after very thorough scrubbing)There are also technical questions to consider:
- What platform(s) should this run on?
- What parts does the whole product/service consist of? E.g. I would expect a client and server. But maybe you'd consider additional parts, and if so, how do they fit into the whole picture?
- How should the product scale? If your goal is to have a custom chat app for a few hundred users at a time, or for 100 million, that's a totally different story architecture-wise
-
Basically, ask questions until you can no longer think of meaningful questions, and come to the conclusion that you "need to try something out". But then you already have an idea what you need to try out.
-
Hi, again. thanks for all.
How can I effectively set up a modular architecture for a chat application? What functional areas should be separated into different modules (e.g., user management, messaging, notifications)?
And also as the project grows, how do you recommend organizing the codebase to maintain clarity and ease of navigation? What folder structures or naming conventions have worked well for you?
Are there any specific frameworks or libraries that you find particularly beneficial when building a chat app with Qt (or generally) that enhance scalability and maintainability?
Can I feel that my story continues to lead to project design?
I think so. I think that web projects have their own design methods, and QT has its own QT method. I think that each project has its own unique method, although general, based on its own language uniqueness, project purpose, and interaction with users. Isn't that right?
That's exactly why I want to discuss the composition of QT projects with you.
-
I also can only give you a generic answers.
For projects that I start form scratch I usually do some interface prototing first. I start by adding small functionalities. I try to create a folder structure that makes sense to organize the files (what ever that means :).
I try to make good names for variables and functions (what ever that means :) )As the projet grows, I try to make reusable components, many times I use object oriented programing with derived classes for that. From a first basic component, I start adding funcionalities and create a component version 2, and 3, and ..., and .. , and ... Sometimes I am lazy and I take a while to replace the old components, so I end up with code like this: SomeComponent(the first and messy) SomeComponent2( this is better structured), SomeComponent3 (this component rocks, I will remove all the old instances in a near future, when I have the time, and will rename this to SomeComponent :)
A good way to developed a component, is start by writing the API first, I learn this from this precious book https://www.cs.vu.nl/~jbe248/api-design.pdf from a Trolltech dev. Pure gold book.
I usually do that, I write a API that makes sense, then I develop the components to work that way.
Sometimes I have very ugly code that works and I keep thinking how can I improve it to make it clean. The code is ugly when I keep forgeting what I have done and it is a nightmare for me to reuse it. Sometimes it takes me weeks and I keep refactoring untill it makes sense and it is easy to use. Sometimes I write coments with a API example of how to use the components that I have done, this is actually good and usefull coments.Check other peoples projects to learn what they have done, this is a good way to improve your skills.
Regarding your specifics questions about your chat application, sorry I dont know nothing about it so I can not help you.
I will end with a joke, sometimes only two people in the universe kown how your code works, you and God, and sometimes only one people in the universe knows how your code works, and it is not you :)
Happy conding... -
@crimson1023 said in How to Build the Safest and Most Scalable QT project:
Are there any specific frameworks or libraries that you find particularly beneficial when building a chat app with Qt (or generally) that enhance scalability and maintainability?
It's fun how people see Qt as kinda programming language or middleware for creating every app of choice :D
Some really huge apps use Qt for their GUI... among dozens of other tools/libs... so it's always a composition of many things.
The fact that Qt has become quite powerful and provides more functionality, beyond "just a GUI Framework", supports that.
On the other hand it's a double-edged sword... a big pro (for me personally) towards Qt is the amount of other things (i.e. modules) that come with it.
You start your app with an empty window... add logic, widgets and more... then you think... well... some serial communication would be great here... you linkQt6::SerialPort
, include what you need... done.
Instead of searching the internet for a proven library or asking people what they can recommend or what they use themselves.However for the exact same reason you can argue that Qt is bloated and not a just a "GUI Framework". These people tend to use something like ImGUI...
Back to your question:
As my previous speakers have already said, it is not very helpful to look for general solutions for app design or scalability in a Qt Forum.If you ask people around the world what sound a dog makes, you will get more than just a couple answers...
@crimson1023 said in How to Build the Safest and Most Scalable QT project:
And also as the project grows, how do you recommend organizing the codebase to maintain clarity and ease of navigation? What folder structures or naming conventions have worked well for you?
And stuff like this, you have to figure out yourself... as it is based on experience and personal preferences...
There might be some lunatic that is like:
(exaggerating)
"I writeyxcvbnm
in front of every member variable and useasdfg
for pointers...."Well... if it works for these individuals to write good code... just leave it to them :)
Since you are not a complete beginner, you should know the "guidelines" and recommendation on naming and organizing your code base... what you end up with, or if you use your own style, which is totally fine, is up to you :)
That being said, you will find the answer to most of your questions between your ears ;-)
-
@crimson1023 said in How to Build the Safest and Most Scalable QT project:
But if you are on the situation to build the project from the scratch, you might make sense how to architect the project. If the project is built smoothly, you will know what to add to what part without any further thought.
It'll be different than when I started a project last time. I think I'm quite experienced, but I still learn new things. The last project I started I thought I'd like to try CMake, Visual Studio Code and C++20. Because I didn't know any of these I had to put in a lot of thought about how I wanted to start the project. There are a lot of decisions you should make upfront. So, don't start without thinking. And every time you start a project your focus will be something different. Don't stop learning.
At my alma mater there is an institute for experimental software engineering. They try to figure out the perfect method to engineer software projects in a way to perfectly estimate the project's cost. The only thing they have figured out is that software engineering will always be experimental. You always have to adapt with the next project you start with all the mistakes you have made last time. You are trying to engineer your software, but science says it is not working. BTW, the biggest question is waterfall or Xtreme Programming, i.e. going agile or not? Each method will have you start a new project differently. In a perfect world the waterfall method is (one of) the best methods you can use: plan the architecture, design the software, write the source code according to the specifiction, ship the software (without ever going back one step). We don't live in a perfect world, so strict adherence to the waterfall model will result in failure of your software product.
I personally lean towards agile. Prototyping, as suggested, seems to be a good method. Figure out the best solution for your code. If you have the time, throw away the prototype and then rewrite that functionality with everything you learned so far.
-
Thank you all—you've hit the nail on the head.
I think the reason I started asking questions that were not complete is because I started asking questions below the level it needed.
To truly begin anything worthwhile, we need a rock-solid foundation—just like we can’t build a house on thin air. Your insights have made me take a step back and reevaluate where I should begin.Thanks again for helping me see things more clearly!
-