I wonder whether there is a concept for attribute dependency in object oriented terminology?

It's an example showing what I mean with attribute dependency:

2DShapeclass may have an areaattribute. Then, Rectangle is a 2DShape and it has lengthand widthattributes. Now, area is dependent to lengthand width. It's a one-way dependency.

Another example: LineSegment has beginPoint, endPointand slopeattributes. One of these attributes is dependent to two others. There are two-way dependencies here.

The term dependency may not fit my examples. Nevertheless, I think there should be a concept which fits these cases in modelling languages or any OO language.

  • 1
    That's not dependency as we know it in OO parlance. Aug 29, 2016 at 7:41

2 Answers 2


As mentioned already, this is not referred to as a dependency. However, the case of attributes being derived from others is so common, that it has been explicitly addressed f.ex. in the UML standard.

Attributes in UML parlance are properties and there is a specific syntax for declaring derived properties by prefixing them with /. Here's a more detailled explanation.

The UML standard does not enforce a certain implementation of derived properties though. It doesn't matter whether you create immutable classes with pre-calculated or lazy-loaded values, implement the derived property as a method with or without memoization, etc. etc.

Finally, note that you may mark a class' property as derived and OCL generally allows you to provide a derivation based on another class' properties. Having a derivation cross class-boundaries though is probably a bad design choice due to the resulting high coupling of these classes.

  • That's not dependency as we know it in OO parlance.
  • In the case of 2DShape length and wide are inputs to the function that calculates area.
  • You could also talk about preconditions, like beginPoint and beginPoint not being null in order for slope to be calculated.
  • In LineSegment, slopeis calculated with beginPointand endPoint. Also, a point could be calculated with slope and the other point. An attribute may be both input and output. So, we need another concept here.
    – Q Q
    Aug 29, 2016 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.