Can separating static methods into several classes have a negative impact?

Asked

Viewed 117 times

4

In question of organization it is relevant to separate methods into different classes.

If we organize the methods in different classes in order to create a better organization, we can have a negative impact on the performance of the program?

For example, I have an application where several methods are in one class only, if I create new classes to house specific categories of methods, I can have a negative impact?

  • It is a little vague to evaluate these impacts without knowing what is the function of your code, The interesting is to know very well the Design Patterns (Patterns) to choose the one that best suits you. All choices are renunciations, too. Search a little about the subject: https://pt.wikipedia.org/wiki/Padr%C3%A3o_de_project_de_software#Padr.C3.B5es_gof_.28.27Gang_of_Four.27.29.3B

2 answers

9


No performance impact just because you did it. There may be if you do something else bad, but it would be indirect.

Even if it had some loss it would be insignificant. And the organization must come first. Concern about performance only if there is reason and the gain is interesting.

In general classes should have sole responsibility, so separating if it makes sense is what should do.

1

Just as a complement, there is a negative (but really slight) difference in the memory of the application process, which, at least for me, is worth the price of code organization.

The difference in performance does exist but is barely noticeable, at least not in today’s computers, I believe it may be noticeable in devices with less capacity, but only theoretically.

In conclusion, it’s worth organizing your code, but remember that organizing isn’t just splitting into multiple classes, do something compact and beautiful instead of splitting more than you should, even if it has a minor difference, if you can do something in the best way, why not?

  • 1

    What difference would that make?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.