Menu

ChangeLogEntry Design Question

Ryon Day
2013-11-05
2013-11-05
  • Ryon Day

    Ryon Day - 2013-11-05

    This is less of a request and more of a question around the design of the ChangeLogEntry object.

    So I understand that there are three different List objects available for attribute changes: getAddAttributes(), getDeletedEntryAttributes() and getModifications() for Add/Delete/Modify changelog entries, respectively.

    My question is this: Why are there three methods? It seems to me that the getModifications() method could serve for all three; in the case of ChangeType.ADD, it could have all ModificationType.ADD entries, in the case of ChangeType.DELETE it could have all ModificationType.DELETE entries and API exploiters would have only one collection type to deal with when digesting ChangeLogEntry objects.

    My suspicion is that there is some subtlety about the RFC that I'm ignorant of that would make this a dumb idea. I just ran across this case where I am having a gnarly time because of needing to deal with two different types of collections (but Guava's filter and transform to the rescue...)

    Thanks!

    Ryon

     
  • Neil Wilson

    Neil Wilson - 2013-11-05

    There are a few reasons:

    • They aren't modifications, and it could be confusing for them to be treated as such. You should always know what type of operation a change represents (otherwise, how would you know whether a modification with ChangeType.ADD represents an attribute created by an add operation or a value added by a modify operation), so it shouldn't be significantly more difficult to handle the content in the most appropriate way for that type of operation.
    • I actually consider it to be much more convenient to deal with the content of add and delete operations as attributes rather than as modifications.
    • I think that it makes the API clearer to have methods that imply the type of operation with which they can be used.

    Ultimately, the API is what it is, and it won't change in a way that would break backward compatibility. Of course, that doesn't prevent you from creating your own helper method in your own code to get the content of a change record as a set of modifications.

    Neil

     

Log in to post a comment.