Home » Software Development » Chasing The Dragon

About Ashley Frieze

Ashley Frieze
Software developer, stand-up comedian, musician, writer, jolly big cheer-monkey, skeptical thinker, Doctor Who fan, lover of fine sounds

Chasing The Dragon

Functions should, ideally return something. It makes them easier to test.

Same for services in a service architecture.

Bosh!

Chasing The Dragon

Consider a component in your software where you make a request, and it handles that request by doing some processing and then passing the data to the next component for onward processing.

This might be at code level, or it may be your microservices, linked together by REST calls or queues. The problem is still the same.

While there are very good reasons why the knowledge of the orchestration might want to be hidden from some caller, from a testing point of view, if you send a message into the front of a chain of components, and want to see if things are working correctly, the answer is running away from the place where you started the test.

Before you know it, you have to black-box test the world, or provide stubs galore for any test you do.

This is most likely an anti-pattern if it’s the ONLY pattern.

At the lower tiers of the test pyramid, we want to be able to test the request/responses of our services pretty easily. This is most easily done by returning things.

It’s a Design Problem

These choices are a question of how you choose to design the software. At the line of code level, it’s a question of whether you write functions that return things. At the service level, it’s a question of where you put the control – everywhere, or in some central controller which calls a service and with its answer calls the next.

The general rule to use is:

If you modifying the design to make it much easier to test, more often than not, you’re making it a better design overall.

That’s not always true. But when it is, it’s monumentally true!

Published on Java Code Geeks with permission by Ashley Frieze, partner at our JCG program. See the original article here: Chasing The Dragon

Opinions expressed by Java Code Geeks contributors are their own.

(+2 rating, 2 votes)
You need to be a registered member to rate this.
Start the discussion Views Tweet it!
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of