User forums > General (but related to Code::Blocks)
How not to write C++
Krice:
--- Quote from: sodev on July 04, 2018, 09:30:54 pm ---I see people who never coded a GUI application or have seen an event loop ...
--- End quote ---
I have programmed a light-weight GUI on top of SDL2. It means I have made menus, dialogs, buttons etc. myself from scratch. It's not something I would recommend if you can avoid it, but it's a good way to understand GUI in a deeper level. And in fact I find even today there aren't many GUI libraries that work with C++ and aren't a size of an operating system (way too large).
--- Quote ---Yes, it is wx magic, dont delete stuff or the event loop might access deleted objects.
--- End quote ---
The object should be an instance of Splash in this case, not anything it owns. If wx is doing something that breaks C++ then it may have been designed for C in the first place. You should be able to keep an instance in memory during the event loop. If wx has some magical memory management it's a sign it was written for C and that it has a bad design. The problems people have with wx would suggest such things to be true.
--- Quote ---I always thought OOP is about attaching behavior to data instead of beeing just plain data?
--- End quote ---
You got this one right, but the problem is that programmers don't always follow that rule the way you should. The Splash class here is a good example of it: if you give away the ownership of something in the class, why have a class in the first place?
--- Quote ---You don't happen to work in one of these consulting companies and are more busy tying a tie than coding code?
--- End quote ---
You should stop guessing, because you are not good at it.
stahta01:
--- Quote from: Krice on July 05, 2018, 05:17:27 pm ---
--- Quote from: sodev on July 04, 2018, 09:30:54 pm ---I see people who never coded a GUI application or have seen an event loop ...
--- End quote ---
I have programmed a light-weight GUI on top of SDL2. It means I have made menus, dialogs, buttons etc. myself from scratch. It's not something I would recommend if you can avoid it, but it's a good way to understand GUI in a deeper level. And in fact I find even today there aren't many GUI libraries that work with C++ and aren't a size of an operating system (way too large).
--- End quote ---
If you wish to complain about GUI toolkits not following C++ OOP ways I suggest you look at Qt5 because they are more C++ OOP than wxWidgets. That is likely because they do not have much legacy code from when C++ compilers were much less feature complete.
The wxWidgets toolkit is improving their C++ OOP usage; but, it is very slow to improve. And, the C++ Compilers seem to be moving faster. But, since you seem to have never used an C++ GUI toolkit; I suggest you remain silent instead of risking being thought a fool on the subject. NOTE: SDL is neither a tookit nor C++. Edit3: SDL is a graphics library.
Edit2: GUI Libraries and GUI Toolkits are not the same thing; wxWidgets and Qt5 are GUI Toolkits.
Tim S.
Krice:
--- Quote from: stahta01 on July 05, 2018, 06:48:52 pm ---But, since you seem to have never used an C++ GUI toolkit; I suggest you remain silent instead of risking being thought a fool on the subject.
--- End quote ---
I think it should be obvious that if the library (or whatever) doesn't work with the language itself then why use it in the first place? It's surely not going to help write stable source code. If you ask me all these memory management things built on top of C++ are the worst. C or C++ was not designed to have automatic memory management, but notably in C++ if you strictly follow constructor/destructor rule (preferably with ownership rule) it's going to be much easier to avoid memory management bugs.
Navigation
[0] Message Index
[*] Previous page
Go to full version