When should we create a new method?

I think there are no specific design guidelines for this. But some of the design principles do talk about method creation.

DRY ( don’t repeat yourself) is a guiding principle when comes to method creation. You group similar logic in a single method so that you don’t duplicate them all over your code and thus make maintenance a nightmare.

Single Responsibility Principle is another. It says that your class, or method should do only one thing. This is to make the method size small.

Leave a Comment