我不明白setAttribute( )和addAttribute( )在GraphStream1.3中的区别。
在“GraphStream's Element API 1.3”中,有人解释说setAttribute是
就像addAttribute(),但是为了一致性。
这意味着什么?
发布于 2022-09-20 12:15:54
很可能他们用这种措辞来指api consistency;他们自己的API之间的总体一致性,或者开发人员可能期望在Java的API中发现的总体一致性。
例如,Java (Pojo)上的properties通常通过约定(而不是在C#中可以找到的语言特性)实现为getter和setter方法。
因此,也许graphstream开发人员希望getAttribute和setAttribute都能以类似的方式出现。
这可以通过检查javadoc中列出的一个Known Implementing Classes来确认;例如,org.graphstream.graph.implementations.AbstractElement,其中setAttribute方法只是直接调用addAttribute:
/**
* @complexity O(log(n)) with n being the number of attributes of this
* element.
*/
public void setAttribute(String attribute, Object... values) {
addAttribute(attribute, values);
}https://stackoverflow.com/questions/72753879
复制相似问题