Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>One criteria you can have to decide whether the classes for Engine, Chasis etc.<br> needs to be present as an inner class (embedded class) is whether instance of<br> these classes can be used elsewhere in your application. In such cases the<br> decision is simple and it is to make these classes exist separately<br> (not as inner classes). </p> <p>Even if these classes are not used elsewhere in your application then other<br> criteria can be testability. With these classes embedded inside and with your<br> design is it possible to have unit tests that can appropriately test your<br> code providing a good coverage. </p> <p>For example say, if you have made an instance variable which references an<br> Engine object and this variable is being initialized in the Constructor of Car.And<br> your Engine class has some methods which needs to be tested. Then how can<br> you add unit tests to check the code in Engine class ? Probably you would<br> have some methods in Car class which expose the behavior or Engine class allowing<br> you to write unit tests. Then the question is if there is a need to expose<br> the behavior of Engine class wouldn't it be better that the Engine class<br> stands on it own? </p> <p>Alternatively there might not be a need to explicitly test the methods in<br> Engine class and unit testing the methods in Car covers the Engine class code<br> as well. Then it reflects tight integration of Engine class with the Car class<br> and would mean it can remain as an inner class.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload