0.19: Why is there a ID in document object?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
onekk
Posts: 381
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: 0.19: Why is there a ID in document object?

Postby onekk » Tue May 05, 2020 7:07 am

UUID are a decent solution maybe for hardware and in "limited environments" a unique identifier will identify each FreeCAD object as unique?

some little calculation wiht "average number of FreeCAD users" X "Number of FreeCAD documents created by an user" X "average number of objects created in a FreeCAD documents" will led to a very big number, how many digits are needed to hold this number, and for how many years this uniqueness will be guaranteed.

not counting that maybe in the process i delete some objects, and if the UUID is working this UUID created has not to be reused.

plus How to achieve that uniqueness? a centralized database, some bitcoin like distribuited blockchain.

A better solution is a "unique id" on a document basis, and some "smart" routine on copying between documents, maye some "uniquity" check if there will be some tools that could "merge" or "copy" between FreeCAD documents that are not FreeCAD itself.

BTW, there is some documentation about the FCstd file format around?

Regards

Carlo D.
adrianinsaval
Posts: 343
Joined: Thu Apr 05, 2018 5:15 pm

Re: 0.19: Why is there a ID in document object?

Postby adrianinsaval » Tue May 05, 2020 4:48 pm

Classic case of asking if you can before asking if you should ;) . What is even the need to have absolute uniqueness? If a short integer suffices why complicate things.
User avatar
tanderson69
Posts: 1538
Joined: Thu Feb 18, 2010 1:07 am

Re: 0.19: Why is there a ID in document object?

Postby tanderson69 » Tue May 05, 2020 6:22 pm

onekk wrote:
Tue May 05, 2020 7:07 am
some little calculation wiht "average number of FreeCAD users" X "Number of FreeCAD documents created by an user" X "average number of objects created in a FreeCAD documents" will led to a very big number, how many digits are needed to hold this number, and for how many years this uniqueness will be guaranteed.
A generated duplicate uuid in of itself is not a problem. It is only when these duplicated uuids enter the same context(document, assembly ...). That being said, after generating 3.26*10¹⁶ you have 99.99% probability of uniqueness That is: thirty-two quadrillion, six hundred trillion. That is one hell of context.



onekk wrote:
Tue May 05, 2020 7:07 am
plus How to achieve that uniqueness? a centralized database, some bitcoin like distribuited blockchain.
No. A UUID, or Universally unique identifier, is intended to uniquely identify information in a distributed environment without significant central coordination.




onekk wrote:
Tue May 05, 2020 7:07 am
A better solution is a "unique id" on a document basis, and some "smart" routine on copying between documents, maye some "uniquity" check if there will be some tools that could "merge" or "copy" between FreeCAD documents that are not FreeCAD itself.
IMHO: "smart" routine is a nice way of saying "complex" routine. I remain skeptical.
realthunder
Posts: 1635
Joined: Tue Jan 03, 2017 10:55 am

Re: 0.19: Why is there a ID in document object?

Postby realthunder » Tue May 05, 2020 11:05 pm

tanderson69 wrote:
Tue May 05, 2020 6:22 pm
A generated duplicate uuid in of itself is not a problem. It is only when these duplicated uuids enter the same context(document, assembly ...). That being said, after generating 3.26*10¹⁶ you have 99.99% probability of uniqueness That is: thirty-two quadrillion, six hundred trillion. That is one hell of context.
You are missing the point here. Just think about the case where the user duplicates a file (not using FC, just regular OS copy and paste), and then uses both in an assembly. This is a common use case, and we must support it obviously. With that in mind, what advantage does UUID have over simple integer?
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
chrisb
Posts: 25897
Joined: Tue Mar 17, 2015 9:14 am

Re: 0.19: Why is there a ID in document object?

Postby chrisb » Tue May 05, 2020 11:10 pm

In Germany we have the saying of shooting with canons on sparrows. Of course you can kill a sparrow like that, but is it really appropriate (not speaking about the killing of sparrows in general)?
User avatar
tanderson69
Posts: 1538
Joined: Thu Feb 18, 2010 1:07 am

Re: 0.19: Why is there a ID in document object?

Postby tanderson69 » Wed May 06, 2020 5:30 am

realthunder wrote:
Tue May 05, 2020 11:05 pm
You are missing the point here. Just think about the case where the user duplicates a file (not using FC, just regular OS copy and paste), and then uses both in an assembly. This is a common use case, and we must support it obviously. With that in mind, what advantage does UUID have over simple integer?
To answer your question, nothing in that scenario and I didn't mean to suggest it would. But that doesn't mean they don't have benefits in others. I know you already have things implemented and I am not trying to get anybody to change. I was responding to arguments that uuids are an inferior solution.
onekk
Posts: 381
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: 0.19: Why is there a ID in document object?

Postby onekk » Wed May 06, 2020 7:36 am

The point is not the way UUID guarantee the uniqueness.

The point is why use such a complicated way to achieve a simple task?

And for the other consideration, why have a Unique ID for each object in a FreeCAD document?

the pourpose is to have a unique reference that permit FreeCAD to refer to "this particular" object with this "ID". stop.

When I'm copy an "object" from a document to another, ii want that if it is a complex objects all the childrens are copied, in an exact way.

What is the purpose to copy even the "internal reference", if you are in need of a sort of PN (Product number) why not ask for a new way to add some properties for this scope.

As usual, the abstract thinking has to be managed with a more concrete "code" try to explain with a piece of code what is the problem that "ID" properties will cause to you code?

Regards

Carlo D.
triplus
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: 0.19: Why is there a ID in document object?

Postby triplus » Wed May 06, 2020 7:33 pm

realthunder wrote:
Mon May 04, 2020 11:07 pm
UUID is too long, expensive to manipulate comparing to simple integer, and most importantly, not unique at all, considering the user is free to duplicate the document and then copy object back and forth.
First thanks for responding. Some background, this discussion has a "long beard" and more or less i asked the question, due to reading FreeCAD now has a "getID method", for i guess uniquely identifying document objects, compered to dealing with the internal (human readable) name for such purposes. And AFAIK the document itself already uses UUID, as identifier. Anyway, i remembered some old discussions, and asked.

To me personally using UUID feels natural, mainly because this is what it was made for. The integer approach is i guess closer to on how Python keeps an ID of an object. Now i would say that the UUID is unique, and you can count on that, and that is basically on why i am a fan of the UUID. As for possibility of duplicating a document and getting a clash, for sure that can be a problem, for any unique identifier, being a simple integer or an UUID. Copy of a document object should get a new identifier? For that for sure there will always need to be some logic included, to deal with that. But as for the uniqueness of a short integer vs. UUID, here i feel that UUID does the job better.

P.S. Beyond stating this i am OK with whatever happen or doesn't happen next. I see this as a conclusion to that old discussions we had, about the possibility of introduction of an unique identifier for a document object, beyond using internal name.