PDA

View Full Version : Professional Classes & Objects Structure



webstylemedia
3rd August 2008, 19:27
Hello, All!

I am new to this site and really new to Qt (but I learned it for a half of year and read almost all most popular books about it). So I am newbie partially :-)

I have a question to real Qt professionals about correct and professional classes structure.

I do a development of software that in future will be marketed, so it needs to be coded correctly and professionally from the first line of code.

I need your advices how to call classes, and how to model them - make them as part of one big file, or as part of small files. Then how to name it better?

Here is what I have:
1) Software has a main window class (QMainWindow) with QTabWidget as central widget.
2) Software must work with projects and each project loaded in own tab on Tab Widget at main window
3) Each project has own Properties and several working Threads.

The good example of similar software is a Teleport Pro (that do a download of whole websites - and each project has own options, and then it can be saved/loaded/started)

I need your advice how to assign a correct class names and how to combine these classes.

I was read a "Designing Qt-Style C++ APIs" but didn't found all answers there.

Exactly questions are:
1) How to name a Projects class? Is "Project" a reserved word? If not is it good to have a class named "Projects"? Then if this class must be as collection of separate "Project" objects with own properties and methods like save/load? How better outline this? How you name your projects class?
2) Each project will have a results buffer that will be updated by Project Threads. Does these Threads must be in the same file as projects? Or separate?
3) Each project visually has own widgets at the Tab Widget (like progress bar, start, stop buttons etc). Do functionality to draw these widgets related to particular project must be a part of Projects file (I mean it will be like a ProjectWidget - with draw, properties and methods)? Currently I have it in MainWindow class - there is a method - CreateProject that do insert a new tab and add a widgets to tab.

Please help.

I know my questions maybe stupid, but I just want to have a professional software developed so need your help for every small detail. Just imagine that you creating website downloader. How you will make a classes model there? How you will name the projects and how to integrate them with threads and main window?

Thanks.

Dmitry

spirit
4th August 2008, 09:20
Did you read this book http://trolltech.com/developer/books/1 ?

webstylemedia
4th August 2008, 10:40
I contacted Spirit and he helped me with all my questions!

He's a MAN!

Thanks, Spirit!

I think this thread can be closed now. No more questions regarding this issues.

wysota
4th August 2008, 10:43
Your question has nothing to do with Qt really... It's more a question from the Software Engineering domain - how to split the system into modules and classes, how to call and reference them. There is no single recipe to doing that. A general rule should be that the naming scheme should be convenient for people implementing the software and clear enough so that if other people start working on it they won't have problems with understanding the structure of the system.

In general a unit name should have a singular form (class should be called Project and not Projects). An instance of that or similar unit can have a plurar form (so you can call a vector of Project instances "projects"). But remember it is just a convention and in practice you can name your classes and variables the way you like and find useful, even if the whole world does it differently.

webstylemedia
4th August 2008, 10:50
Thanks wysota!

Yes this question was related to software engineering. I just didn't know where to ask it.

I already found an answers with "spirit".

Next time I am sure I will have more qt-related questions related to QThreads, QHttp (maybe QTcpSocket because now dunno what better to use in Threads), etc.

Thanks, guys!

D