DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Build a Philosophy Quote Generator With Vector Search and Astra DB (Part 2)
  • LLM: Trust, but Verify
  • 4 Email Validation and Verification Techniques for App Developers
  • Doubly Linked List in Data Structures and Algorithms

Trending

  • Docker Base Images Demystified: A Practical Guide
  • Secrets Sprawl and AI: Why Your Non-Human Identities Need Attention Before You Deploy That LLM
  • How Kubernetes Cluster Sizing Affects Performance and Cost Efficiency in Cloud Deployments
  • Scaling DevOps With NGINX Caching: Reducing Latency and Backend Load
  1. DZone
  2. Data Engineering
  3. Data
  4. API Module Decoupling

API Module Decoupling

The cost of changing or maintaining software is mainly high because of cascading, which is a significant change in a coupled software system.

By 
Saurav Bhattacharya user avatar
Saurav Bhattacharya
·
Nov. 23, 23 · Analysis
Likes (4)
Comment
Save
Tweet
Share
1.9K Views

Join the DZone community and get the full member experience.

Join For Free

The cost of software primarily consists of the cost of maintaining software. The cost of changing or maintaining software is mainly high because of cascading, which is a significant change in a coupled software system. Therefore, decoupling a software system almost always results in a better-designed system with a low cost to change. Let’s see this with the help of an example.

Taking an Example

Suppose you were a vet clinic, and you needed a software system to manage the visits to the clinic: recording visits, assigning visit procedures, and creating visit invoices.

You would probably have three services, one for each of the functionality mentioned above:

three services

Now, to add the interactions between the modules:

  • Visit service takes in the customer, pet, date and time of visit as inputs and creates a visit.
  • Procedure service takes a visit and adds one or more procedures to the visit.
  • Invoice service takes a visit and creates an invoice for the visit’s procedures.

Let’s say the visiting entity looks like the following:

visit {  visitId  customerName  petName  visitDate  procedures [] }


The procedure entity would probably look like this:

procedure {  procedureId  procedureType  price }


To create an invoice, the Invoice service would need both the visit details and the procedure done:

invoice {  visitDetails  proceduresDone []  amountDue }


There are a couple of options on what kind of data we could be passing into Invoice Service:

  • It could take in the visit object and the procedures object array. Then, it would create the printable details from the visit object and procedures array and calculate the sum of the prices of each procedure in the procedures array.

OR

  • It could take the visitId, and call the Visit Service to get the visit details printed and the Invoice Service to get the procedures’ name list and prices of the list of procedures done during the visit.

Accessing Coupling

Which of the two options above is the better design choice? Let’s look at how decoupled or coupled this simple software system is on both options.

Option 1: When Entire Objects Are Passed

Here, any changes to the visit schema, say when we add a customer phone number, will mean we need to change Visit Service, but also the Invoice Service. Invoice Service takes a visit object and creates the printable visit details to put on the invoice.

Also, any changes to the procedure, like adding a new procedure type, would not only require a change to Procedure Service but also the Invoice Service since Invoice Service takes in a procedure object. It would need to create the printable version of the new Procedure type.

Option 2: When Only Non-Changing Data is Sent

In this case, the Invoice Service only takes in visitId and calls into Visit Service, for it should print onto the Invoice about the visit. This way, the visit schema can change as needed, and it would only require a change to the Visit Service. The contract between Invoice Service and Visit Service, as shown below, would remain unchanged:

GetVisitDetails(visitId) → string

Similarly, InvoiceService would call into ProcedureSerice to get an array of procedure names & price numbers for a visitId, as shown below. Then, if new procedures are added, they only affect the Procedure Service; Invoice Service need not change.

GetVisitProceduresWithPrices(visitId) → Dict<string, decimal>

Conclusion

While designing software, if we reduce coupling between modules, we make the design more modular, and we ensure that changes to one module do not affect other modules, or at least, the change cascade is limited, making changes low cost.

Thank you for reading! Please let me know your thoughts.

API Data structure Software system Decoupling (electronics)

Published at DZone with permission of Saurav Bhattacharya. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Build a Philosophy Quote Generator With Vector Search and Astra DB (Part 2)
  • LLM: Trust, but Verify
  • 4 Email Validation and Verification Techniques for App Developers
  • Doubly Linked List in Data Structures and Algorithms

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!