Zwe Naing
Zwe Naing

Reputation: 61

One method for one operation in OOP?

In Functional Programming, the good rule of thumb for composition is to create a function for each operation and compose them together to achieve the desired functionality. In contrast, in Object-oriented Programming, should each method be self-contained with the use of less helper methods or same as Functional Programming? What is a good practice?

Upvotes: 1

Views: 75

Answers (1)

Mik378
Mik378

Reputation: 22191

Whether OOP or FP, a function should do one thing.

The good rule of thumb, no matter the paradigm is OOP or FP, is that a function should do one thing.

It does not mean that a function should not internally compose with others.

If helpers method contribute to participate to achieve the sole function/method responsibility, that's pretty fine to use them.

Upvotes: 1

Related Questions