Jump to content

Ultra App Kit - Source structure


chicolitto
 Share

Recommended Posts

Hi,

I'm a new user of Ultra App Kit. I looked the tutorials and something important is missing imo.

Examples about good organisation / file structure practices. 

When I look at the tutorials I just ask myself "how can I avoid to write everything in the same file?". I'm no C++ expert and didn't use it in a very long time.

 

Could someone give any advices on the topic? Some example of code organisation and project structure? That could give a good inspiration to put beginners on the right path. Of course it's a very "personal" approach but I'm sure there are things to do right. 

 

Thanks in advance

Link to comment
Share on other sites

Just a few ideas can be done in many ways

1.

I just use functions in different files , like handlers for simple projects.

some_button_handle_action(button type, etc)

I pass the widget to the function and thats it.

You could also have an array of pointers to functions.

 

2.

Derive from the UAK widgets and add your own handling.

 

3.

Composition, you have a panel with several widgets and you create a class (file)  that initialize all those widgets,

and handles the interaction.

 

4.

Some kind of finite state machine.

Have a look at this article:

https://gameprogrammingpatterns.com/state.html

 

I made this with Leadwerks/UAK:

Structura Stacky Desktop Edition

Website:

Binary Station

Link to comment
Share on other sites

Thanks for your answer.

 

I will read the link with attention. I was actually thinking about a state machine to start with.

But I have a bit trouble of understanding what you mean with the 3 other points. Could you maybe elaborate with code examples? It would be great. As I said my C++ is very rusty :)

 

Thanks

Link to comment
Share on other sites

Class with several widgets declared in it that are somehow related in the functionality.

So you can put that to a separate file.

class RocketControlWidgetGroup
{
  std::shared_ptr<UltraEngine::Widget> ignitionButton;
  std::shared_ptr<UltraEngine::Widget> selfDestruct;
  std::shared_ptr<UltraEngine::Widget> selfTest;
  
  etc
};

The usual object oriented example is a Car with different objects in it Engine,Wheels, Doors etc

 

I made this with Leadwerks/UAK:

Structura Stacky Desktop Edition

Website:

Binary Station

Link to comment
Share on other sites

I get the general idea.

I'm still a bit lost because there is infinite way of doing this I'm just looking for an exemple to get started.

For exemple good practices, like :

 - When you start a new project you need to create folders for your Headers and your Sources files.

 - When you have multiple Panel in your application try this : (*any advice possible and how structure the corresponding file*)

 

@Josh The tutorial on complexe interface is wonderful but why there is not any kind of exemple about good organisation of all this code? Nobody will want to make a big monolith in the main like that.

 

I'm sorry I know this might seems a bit dumb, I just want to start working on an app without falling into easy avoidable pitfall. 

 

Thanks

Link to comment
Share on other sites

Your header and your cpp file should always be in the same folder. I put everything in a /Source folder by default. Don't create additional subfolders unless you have a lot of subcategories and files, like maybe more than 20 code files.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...