Domanda

In a recent code refactor, I'm fulfilling an idea that isolates data handling from data itself. It's something like Chain-of-responsibility - processing units providing the ability to handle the data within a particular business scope while data object being passed on through the whole processing chain.

A further optimization is done by "singletonizing" the processing chain instance. Considering potential concurrence problem, eliminating any private data reference in these processing units is desired.

So, I wonder if there is some programming paradigm which can suggest other programmers conform this pattern while they are doing modification in the future.

Thanks in advance~

È stato utile?

Soluzione

That principle called "service statelessness". In service-oriented design paradigm services supposed to be stateless, thus they don't have private data. Statelessness needed in order to support scalability.

UPDATE: If you need some state data (context, session, business), there is elegant way to prevent class from holding private data called state management delegation and state deferral. State deferral example could be a dedicated database/tables that used by your components to write state and retrieve it later.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top