-1

I recently started learning C++ and wxWidgets. Now I'm doing a calculator. When I start writing code, everything is ok, but when code gets bigger and bigger, it becomes a mess.

I want to know any C++ GUI code architectures, design principles and patterns that will help to write clean, flexible and scalable GUI applications.

Michael Chon
  • 142
  • 2
  • 12
  • 2
    This is a really big question and probably not focused enough for SO. However I try to keep the GUI code as separate as possible from the application code. I like to write an application "engine" that performs all the tasks through a programming interface (API) and then all you have to do (hopefully) is plug whatever GUI you are using into your "engine". So you could build your calculator entirely without using a GUI, completely test and debug it (through the API) and then add the GUI code later. Things are not always as clean cut as that but that is the ideal I like to strive for. – Galik Jun 29 '20 at 09:36
  • The above comment is an excellent advice. For the code organization, following the usual convention of having one file per (GUI) class is not the worst thing you can do. – VZ. Jun 29 '20 at 18:16

1 Answers1

1

Your question certainly is broad, (like your code!) which makes an answer challenging. There are a couple of specific things I’d suggest that might help you.

  1. Learn the SOLID Design Principles. They will help guide you through focusing on how to divide your code into manageable classes.

  2. Learn how to write unit tests. They will encourage you to divide your code into smaller units, so that they’re easier to test.

  3. To learn how to apply both of these things, I recommend the book Refactoring by Martin Fowler. You will learn a ton about it in very small, easy to learn steps and practices.

John Deters
  • 4,295
  • 25
  • 41