What are the pros and cons of creating a new class?

This is probably a very simple question, but this is one that I really come across as I learn more about ActionScript 3 in particular. However, my first question is very general: when is it advisable to add functionality to a new class, rather than a new function in the same class? According to this Java tutorial , which focuses on basic object-oriented principles, the class should be an “object plan”. I have always understood that this means that any functionality or behavior that an object should use must be contained within the class. However, according to the principlesingle responsibility, each class should have only one reason for the change. For example, you should have one class for compiling a report and one class for printing it, and not for one Report class.

Can you guys help me understand the pros and cons of creating a new class? What are the costs of dividing an object into several classes? Are there compilation times or performance overheads for storing related functions in one class or for splitting it into two? You may need time to share it, while you could save them together at another time?

+3
source share
2 answers

As far as I remember, there is not much difference between having 1 class that can do all or several classes that can do the same.

. .

"", "WaterCoolerSound()". , , , . , , .

, , , , .

, . , , . (. :)

0

, . . , , u .

0

All Articles