The source code for this game is open source, so I decided to check it out. In it, I found something like:
void ActionManager::HandleQueryMessage(csString xml, Client* client)
{
psItem* item = client->GetCharacterData()->Inventory().GetInventoryItem(PSCHARACTER_SLOT_RIGHTHAND);
if(!item || !item->GetItemCommand().Length())
item = client->GetCharacterData()->Inventory().GetInventoryItem(PSCHARACTER_SLOT_LEFTHAND);
}
The first line to get the element clearly violates the demeter law. However, even if it was changed to client->GetCharacterData()->GetInventoryItem(PSCHARACTER_SLOT_RIGHTHAND);, it will still violate the demeter law (as far as I know).
What can be done about this? or is this one of the places where LOD is not applied [as in my second example]?
Moving a class GetInventoryItemto a class clientdoes not make sense in my point of view, since the client has nothing to do with character.
Creating wrappers in the class clientfor all xx methods the class characterseems redundant.
Any thoughts?