Mari-Wie / ArchCNL

ArchCNL is an Architecture Conformance Checking Tool developed by the working group SWK (Software Engineering and Construction Methods) at the computer science department of the University of Hamburg
GNU General Public License v3.0
5 stars 8 forks source link

ArchCNL-51: Syntax checker for AndTriplets based on type tracker for Variables #278

Closed vraudszus closed 2 years ago

cmkehler commented 2 years ago

@VincentRaudszus The two methods: getRelatableSubjectTypes() and getRelatableObjectTypes() in TypeRelation that literally only throw exceptions when you call them, seem wrong to me. TypeRelation shouldn't inherit these methods if these methods are not allowed to be called. I assume that fixing the Relation hierarchy to remedy this would be alot of work? If that is the case and if those methods are never called anyway (since they would throw exceptions) then I probably would accept this pull request despite my misgivings.

vraudszus commented 2 years ago

The issue is that TypeRelation behaves fundamentally different from all other types of relations in this aspect. The allowable ActualObjectType of the subject can only be determined by looking at the object the TypeRelation relates to. And the TypeRelation has a dynamic set of allowable object types and retrieving this set would require access to the ConceptManager. So my idea of having fixed sets of allowable types does not hold up for the TypeRelation.

That is why triplets with the TypeRelation as their predicate are handled by a completely different method in the VariableManager. And unlike the standard method, this method does not rely on the getRelatableSubjectTypes and getRelatableObjectTypes methods.

And to make this difference clear, I decided to override those methods in TypeRelation so that it would not lead to undefined behavior when the methods are accidentally called. If not overwritten the methods would simply return the empty placeholder sets the TypeRelation has for its relatable types, which in my opinion would be worse than having the exception throwing methods around.