Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Coffee corner » Architectural and C++/Upp questions
Re: Architectural and C++/Upp questions [message #54927 is a reply to message #54912] Tue, 29 September 2020 08:46 Go to previous message
mirek is currently offline  mirek
Messages: 14265
Registered: November 2005
Ultimate Member
Xemuth wrote on Mon, 28 September 2020 15:44
Hello, I'm currently working to improve the package I introduced here : https://www.ultimatepp.org/forums/index.php?t=msg&th=111 48&start=0&

To improve it and add new functionnality / modularity I started to write bunch of new class:

One of them is named Context and hold a private Vector of Scene Object. Some of public methods allow user to Create/Remove/Get all the scene object depending on ID (int):

Scene& CreateScene(); //Return the fresh created scene
bool RemoveScene(int sceneId);
Scene& GetScene(int sceneId); //Return scene depending on ID

2 questions come in my head when reviewing this code
-First one : Is it good to return reference of Scene in CreateScene() ? the fact a Vector is holding Scene mean the reference can get dereferenced at next creation/ destruction, on other hand returning the ID of the scene in CreateScene() force user to call GetScene(int sceneId) (which could lead to the same behavior) May I should use Array instead of Vector and return Reference ? What you think ?


Definitely use Array here.

Quote:

-Second one : Since ID is (in term of human view) less simple to remember, is it a good idea to swap int ID to String name, and use name to identify all Scene ?


Maybe you could also make CreateScene return int id instead. Something like nodes in TreeCtrl...

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: some U++ stuff on reddit/cpp_question
Next Topic: About Nuller and Null
Goto Forum:
  


Current Time: Tue Jul 08 06:21:18 CEST 2025

Total time taken to generate the page: 0.04104 seconds