ADR Suggestion, replace UUIDS with string names in BORG #16
Closed
damskii9992
started this conversation in
Ideas
Replies: 2 comments 3 replies
-
Is it possible to change the |
Beta Was this translation helpful? Give feedback.
1 reply
-
Looks good. One question. You said
Imagine you create 3 parameters |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
General
In EasyScience, we have a global object called borg, based on the singleton Borg class. This object has an associated map object based on the Graph class, which contains weak references to all created object instances which inherit from BasedBase, such as any BaseObj or BaseCollection object. One of the uses of this map, is that any object can be found no matter where it lives and no matter how deeply nested in other objects it is.
Current implementation
Currently, when an object is created, the borg calcuates the UUID of the object, which is a unique identifier for any python instance consisting of a 128bit string of numbers and letters. This UUID is then converted into a pure number sequence and is saved as the key of a key-value pair in a weakref dictionary on the borg with the reference to the object. To query the borg to find an object currently, the following code is used:
borg.map.get_item_by_key(borg.map.convert_id_to_key(object))
Proposed implementation
Instead of using UUIDs as keys to object references, I propose to use unique strings i.e. unique "names". These unique names can be set by the user or developer, but will by default by generated according to the class name of the object and the number of those objects, such as: Parameter_0, Parameter_1 etc. With this implementation, to query the borg to find an object, the following code can be used:
borg.map.get_item_by_key(object.unique_name)
or if the name is known:
borg.map.get_item_by_key("Best_Parameter")
Advantages with new implementation
borg.map.vertices()
will become human-readable.Disadvantage with new implementation
Beta Was this translation helpful? Give feedback.
All reactions