For classes that you create, you usually get them to do their job. A Circle will be drawn on a Canvas , so a Rectangle . Thus, if they are all subclasses of Shape , they can draw themselves through the Shape interface. This is the same for saving. It is extensible - you do not need to guess all possible forms when developing the Canvas class.
For the “it depends” cases, for me, utility methods are usually used for classes already defined by some library. For example, save / load commonly used STL data structures, such as map, set, vector, etc .; through the File utility class with static methods.
source share