Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-317

Create optimized versions of Location

    XMLWordPrintable

Details

    • Task
    • Resolution: Done
    • Major
    • 0.4
    • 0.3
    • API, Graph (2.x)
    • None
    • Medium

    Description

      The Graph API uses the Location class to represent the location (path and/or identification properties) of a node. So far, we haven't needed different implementations, but given that the current class has a number of optional member attributes and we'd like to add more, it is probably prudent to have different implementations that more optimally represent the combination of attributes that's possible.

      Currently, there are quite a few constructors and they are called in numerous places. However, every place that one is created, an ExecutionContext is available. Therefore, it seems like there are (at least) two valid approaches:

      1) Change Location to an interface, create multiple implementation classes, define and implement a LocationFactory that instantiates the most appropriate implementation class, and add getLocationFactory() to the ExecutionContext. This approach mirrors the way that the properties and value types are created, but Location objects are not used as property values. It would even be possible to add a "with(LocationFactory)" method to ExecutionContext so that one can clone a context but specify the implementation of the LocationFactory that the clone should use.

      2) Keep Location as an abstract class, but remove the constructors and replace with static factory methods. This would likely mean that there is a single set of implementations that never need to be customized. It also means that we could add methods that could return a new location with additional attributes set. For example:
      Location newLocation = location.with(uuid);

      Either way, we need to change the current implementation to be more flexible. I think the choice comes down to whether it's appropriate to be consistent with the factory-style approach used by property values, or whether Location is different enough and we know we'll only have a single family of implementations that don't need to be extended or customized.

      Attachments

        Activity

          People

            rhauch Randall Hauch (Inactive)
            rhauch Randall Hauch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: