ArticleslgStudy

computer science

Service refactoring

Service refactoring is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Service refactoring rather than just read about it. In short: Within the service-orientation design paradigm, Service Refactoring is a design pattern, which is applied to an existing service so that either the service logic or its implementation can be changed without affecting the service consumers. Rationale It is natural for a service to undergo changes for various reasons.

Key takeaways

  • Service refactoring belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Service refactoring to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Service refactoring from memory before moving on to harder problems.

Reference excerpt

Within the service-orientation design paradigm, Service Refactoring is a design pattern, which is applied to an existing service so that either the service logic or its implementation can be changed without affecting the service consumers.

Rationale It is natural for a service to undergo changes for various reasons. The change could be required because the underlying implementation e.g. databases, legacy systems, etc. needs to be upgraded or simply because the original service logic was not making efficient use of memory. In other cases, the change could be initiated by the service consumers themselves. For example, with limited concurrent usage, the service performs as stated in its SLA, however, with an increase in its concurrent usage, the service is unable to fulfill its SLA, consequently the service needs to respond to the increasing performance demands from its service consumers. This situation needs to be addressed in a way that upgrades the service without disrupting consumers who have already become dependent on it. Although one could argue that responding to any of the aforementioned requirements should not be problematic as long as the service honors its contract. However, we are concerned with both the outcome from the execution of service capabilities and also with the behavior and reliability of the service. The Service Refactoring design pattern provides a strategy aimed at ensuring that a service can evolve without negatively affecting its consumers.

Usage The application of this design pattern advocates the use of traditional software refactoring techniques. The focus is on refactoring the service in smaller steps so that the impact of each step is minimal and can be easily reversed if it negatively affects the service consumers. Secondly, to ensure the service contract remains unaffected by changes in logic or implementation, the service contract must be decoupled as much as possible. This can be done by introducing a façade component between the service contract and the service logic. However, this is only possible if the service contract is physically decoupled from its implementation in the first place, which could be accomplished by the application of the Decoupled Contract design pattern. This could further be strengthened by the application of the Contract Centralization design pattern that advocates establishing the service's contract as the only official entry point into the service. On the other hand, to insulate service logic from negative effects from changes in the service implementation, the Service Façade design pattern could be reapplied to introduce another façade component between the service implementation and the service logic. The application of the Service Abstraction principle can further help to reduce the possibilities of any detrimental effects caused by the application of this design pattern.

Considerations The application of the Service Refactoring design pattern requires extensive testing to ensure a reliable and proven service, although inefficient, carries on the same level of behavioral stability and reliability. This might increase the project costs and would require additional quality assurance procedures and strict governance. On the other hand, with its application, there might be a change to the current abstraction levels of the service, which would in turn require reapplication of the Service Abstraction design principle to ensure the service maintains the right level of abstraction. In some situations it might be impossible to constrain the effect of changes in the service logic or its implementation, and inadvertently the service contract must be updated. In this case, the Concurrent Contracts design pattern could be applied, allowing the service to continue supporting consumers dependent on the old contract while simultaneously offering an updated contract that aligns with the new service logic or implementation.

References

Further reading Erl et al.,(2009).SOA Design Patterns. Prentice Hall. ISBN 0-13-613516-1. Mauro. et al. Service Oriented Device Integration - An Analysis of SOA Design Patterns. [Online], pp. 1–10, 2010 43rd Hawaii International Conference on System Sciences, 2010. Date accessed: 5 April 2010.

External links SOA Concepts SOA Terms Glossary SOA patterns

Worked examples

Example 1 — a first encounter with Service refactoring

Start with the simplest possible case. Write down what Service refactoring claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Service refactoring before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Service refactoring ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Service refactoring

In research
Service refactoring appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Service refactoring in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Service refactoring is common in secondary-school and first-year university syllabi. It links to neighbouring topics Service-oriented (business computing), so understanding it makes those chapters shorter.
In everyday life
Look for Service refactoring outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Service refactoring” →

How to study Service refactoring in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Service refactoring means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Service refactoring out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Service refactoring in simple terms?

Within the service-orientation design paradigm, Service Refactoring is a design pattern, which is applied to an existing service so that either the service logic or its implementation can be changed without affecting the service consumers. Rationale It is natural for a service to undergo changes fo…

Why does Service refactoring matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Service refactoring?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Service refactoring.

Tags

  • Service-oriented (business computing)

Keep exploring