I have a Java assessment that gets marked by a robot. Whenever I upload my assignment it shows a screen like this.
A good object-oriented design places each method into the most appropriate class. The most appropriate class for a method should be the same class as the data fields that that method needs to access. If you don't place a method into the right class, then this will most likely increase the amount of communication that is required between your classes. The score below measures the amount of communication between your classes. A lower score is better. 19 method invocations between classes 7 arguments passed between classes 15 results returned between classes Amount of communication = invocations + 2*inputs + 2*outputs = 63
Now what exactly does “method invocations between classes”, “arguments passed between classes” and “results returned between classes” mean?
Method invocations between classes
As your class contains their own methods if you want to call the method from another class you have to use an instance of this class.
For example :
If I want to call
methodA()from the classBI must use this:Argument passed between classes
This time
methodA()will need an argument, andBas a field which could be used as argument.To call
methodA()fromByou will pass an argument from a class to another.Results returned between classes
And now
methodA()returns a result this is the code.To use/handle the returned value of the
methodA()from the classByou’ll have to do this: