Book a Demo

Author Topic: Two elements with the same name and type in the model  (Read 15262 times)

EA_enthusiast

  • EA User
  • **
  • Posts: 172
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Two elements with the same name and type in the model
« on: December 07, 2020, 11:32:09 am »
Hello Sparx EA experts,

I have a package that includes an element (class) named "ABC". I created a new package and created a new element (class) and named it "ABC".

I was expecting that Sparx EA would warn me that the model has an element with the same name and that I sould not create an element with the same name of an existing one.

I used to get such notification by default when I was using another modeling tool. Do I need to make any settings to receive such notification? Isn't this how the model should work, no 2 elements with the same type and same name are allowed?

Thank you.
Mo
Thank you to all the contributors who spread their knowledge and experience!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Two elements with the same name and type in the model
« Reply #1 on: December 07, 2020, 03:39:15 pm »
Hi Mo,

Formally what you are describing comes under the concept of Namespace Management.  EA (effectively) does NO namespace management (from the point of view of general element naming).  The namespace property (as in selecting Namespace Root etc.) is primarily to do with code generation.  But, to a small amount in their defence, namespace management for items in a repository that's not a trivial matter. When considering named elements, the name uniqueness can be constrained by metatype, by package, by branch etc.  Each model within a repository can have differing namespace requirements.

SO, for example, prima facie, I would have said that the example you gave, they were two different items that happen to have the same name.  In the enterprise space, that can happen a lot.  For example, the position name is often the name of the primary role of the usual occupant of the position which is often the primary activity that the role undertakes:  E.g. "Finance Manager".  Here, you see, we have to allow the same name, so long as it is a different metatype (Position, Role, Activity).

In our case, we use external SQL queries to ensure that our namespace rules aren't being broken.

HTH,
Paolo

[NOTE: There IS an intentional mistake here...]
« Last Edit: December 07, 2020, 03:41:02 pm by Paolo F Cantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Two elements with the same name and type in the model
« Reply #2 on: December 07, 2020, 04:01:36 pm »
I recently wrote an EA-Matic script to prevent the creation of duplicate elements.

You can configure it to check certain combinations of element type and stereotype

https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Projects/EA-Matic%20Scripts/PreventDelete.vbs

Geert

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Two elements with the same name and type in the model
« Reply #3 on: December 08, 2020, 07:55:30 am »
I have a package that includes an element (class) named "ABC". I created a new package and created a new element (class) and named it "ABC".

That's perfectly valid because the classes are in different namespaces. If they were in the same package, they wouldn't be distinguishable according to UML's rules, but EA takes the path of least friction by NOT popping up an annoying error message (for which I'm very grateful).
The Sparx Team
[email protected]

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Two elements with the same name and type in the model
« Reply #4 on: December 08, 2020, 04:39:05 pm »
...
I have a package that includes an element (class) named "ABC". I created a new package and created a new element (class) and named it "ABC".

I was expecting that Sparx EA would warn me that the model has an element with the same name and that I sould not create an element with the same name of an existing one.

I used to get such notification by default when I was using another modeling tool. Do I need to make any settings to receive such notification? Isn't this how the model should work, no 2 elements with the same type and same name are allowed?
...
Yeah some tools do that and they are annoying to use. If the full name space is different then its valid i.e. different package. Sounds like if you want that behaviour Geert's EA-Matic is your best option so go for that.





Happy to help
:)