Right now, the functions getDataForType and digDownData invoke the API recursively. To decide what pieces of info they need from the API, they look at the keys in the object placeholders, which correspond to all the placeholders found in the HTML.
The way this works now is cumbersome. There is manual checking of those placeholders: depending on the type of entity, and the placeholders found, digDownData is called with different parameters etc. For example:
if (placeholders.chairs) {
digDownData(TYPE_CHAIRS, json._links.chairs.href, callback);
}
The graph of information returned by the API is not a tree, and it is possible to reach one particular item of information starting from other items of different types. For example: the spec S may be found in the list of collaborations of user U; but also as one of the deliverables of group G (which, in turn, is one of the groups U belongs to). We could end up with infinite recursion.
I'd like to design some clever data structure and an algorithm that would model the graph of dependencies between all entities that the API understands. That way, we would avoid weak, specific branches in the code. The code would be more robust and succinct, and easier to maintain (for example, when there are changes to the API model).
Right now, the functions
getDataForType
anddigDownData
invoke the API recursively. To decide what pieces of info they need from the API, they look at the keys in the objectplaceholders
, which correspond to all the placeholders found in the HTML.The way this works now is cumbersome. There is manual checking of those placeholders: depending on the type of entity, and the placeholders found,
digDownData
is called with different parameters etc. For example:The graph of information returned by the API is not a tree, and it is possible to reach one particular item of information starting from other items of different types. For example: the spec S may be found in the list of collaborations of user U; but also as one of the deliverables of group G (which, in turn, is one of the groups U belongs to). We could end up with infinite recursion.
I'd like to design some clever data structure and an algorithm that would model the graph of dependencies between all entities that the API understands. That way, we would avoid weak, specific branches in the code. The code would be more robust and succinct, and easier to maintain (for example, when there are changes to the API model).