Law of Demeter in Java
问题 I have been building a RTS to improve my Java skills. I have been reading a lot about the Law of Demeter because I want to keep my code clean but I'm still quite confused! At the moment I have some code like this in the view to show how many of a certain ship there are in a fleet on the selected planet: int numberOfFrigates = model.getSelectedPlanet().getFleet().getNumberOfFrigates(); Which from what I understand goes against the Law of Demeter. If I'm only supposed to have 'one dot' do I