Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I'm having a discussion with a fellow developer, and I'm trying to argument this in something like a short "term".

SoC (Separation of Concerns) is pretty straight forward design practice, but it dwells deeper. If we want to pick on it's deep corners, we can Google it and there are plenty of articles that pop up, and after taking a glimpse, we know a lot more, and might find some examples.

But, what about "Use procedures that execute a single task"? That's also a great design principle to use when writing applications and it becomes more and more rewarding, the larger the application gets.

Is there a term for Use procedures that execute a single task?

share|improve this question

closed as primarily opinion-based by gnat, MichaelT, GlenH7, Bart van Ingen Schenau, amon Sep 23 '14 at 20:14

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

Single Responsibility Principle? – Thijs van Dien Nov 25 '12 at 12:51
@tvdien - As far as I know SRP is about class design, not methods. – Oded Nov 25 '12 at 12:59
In the functional languages I think this is called purity - functions that have no side effects and return a single value. – Daniel Iankov Nov 25 '12 at 17:20
I don't think that it is limited to class design in anyway. SRP can be applied to any unit of code large or small. – chakrit Nov 25 '12 at 19:04
@DanielIankov, if is what you mean, I think it's a bit overkill. – joltmode Nov 25 '12 at 22:21

5 Answers 5

You could use "Single Responsibility", but that would only make most developers think you were talking about classes, even though the concept is most certainly applicable to methods as well.

While I personally don't know of any "industry standard" phrase, I sometimes use the phrase "Single Purpose Method" to describe a method which should do only one thing. It contracts down to a nice and simple TLA, however you would most often find developers describing how the method should be structured in full, rather than attempting to describe it as a "type" of method implementation. This is because methods which attempt to fulfill multiple purposes often end up looking like a lovely bowl of spaghetti, whereas refactoring your code so that methods do as little as possible results in code that is generally easier to read, easier to reuse, and less confusing as to purpose.

share|improve this answer

I only ever heard of it as "a method should only do one thing", but there is no particular term for this practice.

It goes deeper than Separation of Concerns, which is normally interpreted in OOP circles as "a class should only have one reason to change", whereas this is design in the small - what a single function/method/subroutine should or should not be doing.

To reiterate - it is part of good object and code design, but there is no particular term attached.

share|improve this answer

An alternate approach is to come up with a pejorative term for the converse.

At the shop I worked with, the word was "conflation".

If someone suggested "You've conflated setup and configuration in this function", you were immediately on the hook for defending your design (or acknowledging the problem).

share|improve this answer
Use procedures that do not conflate multiple responsibilities then? – Martijn Pieters Nov 26 '12 at 12:19

The High Cohesion GRASP pattern comes to mind - although it tends to be applied more to an object as a whole than a method.

share|improve this answer

Perhaps I'm just being naive here, but this simply seems like Separation of Concerns/Encapsulation as applied to a single method/function versus an entire class/module.

Maybe there is indeed a piece of jargon that describes the process of applying such schools of thought of methods/functions, but I've only ever heard of it referred to as Separation of Concerns/Encapsulation.

May I ask why this is an issue? I don't think many developers would be surprised if you applied Separation of Concerns to a method.

share|improve this answer
I'm just looking for a resource to share with fellow developers, where instead of arguing why their implementations are not application-growth-friendly, I could simply point them to such educational resource. That in case of wikipedia, are often considered more "valid" due to "big" names behind the principles / practices. – joltmode Nov 25 '12 at 22:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.