mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-20 01:25:41 +00:00
docs: Content SEO updates (#2990)
* update yaml frontmatter format * update abstract document * update abstract factory * use the new pattern template * acyclic visitor seo * adapter seo * ambassador seo * acl seo * aaa seo * async method invocation seo * balking seo * bridge seo * builder seo * business delegate and bytecode seo * caching seo * callback seo * chain seo * update headings * circuit breaker seo * client session + collecting parameter seo * collection pipeline seo * combinator SEO * command seo * cqrs seo * commander seo * component seo * composite seo * composite entity seo * composite view seo * context object seo * converter seo * crtp seo * currying seo * dao seo * data bus seo * data locality seo * data mapper seo * dto seo * decorator seo * delegation seo * di seo * dirty flag seo * domain model seo * double buffer seo * double checked locking seo * double dispatch seo * dynamic proxy seo * event aggregator seo * event-based asynchronous seo * eda seo * event queue seo * event sourcing seo * execute around seo * extension objects seo * facade seo * factory seo * factory kit seo * factory method seo * fanout/fanin seo * feature toggle seo * filterer seo * fluent interface seo * flux seo * flyweight seo * front controller seo * function composition seo * game loop seo * gateway seo * guarded suspension seo * half-sync/half-async seo * health check seo * hexagonal seo * identity map seo * intercepting filter seo * interpreter seo * iterator seo * layers seo * lazy loading seo * leader election seo * leader/followers seo * lockable object seo * rename and add seo for marker interface * master-worker seo * mediator seo * memento seo * metadata mapping seo * microservice aggregator seo * api gw seo * microservices log aggregration seo * mvc seo * mvi seo * mvp seo * mvvm seo * monad seo * monitor seo * monostate seo * multiton seo * mute idiom seo * naked objects & notification seo * null object seo * object mother seo * object pool seo * observer seo * optimistic locking seo * page controller seo * page object seo * parameter object seo * partial response seo * pipeline seo * poison pill seo * presentation model seo * private class data seo * producer-consumer seo * promise seo * property seo * prototype seo * proxy seo * queue-based load leveling seo * reactor seo * registry seo * repository seo * RAII seo * retry seo * role object seo * saga seo * separated interface seo * serialized entity seo * serialized lob seo * servant seo * server session seo * service layer seo * service locator seo * service to worker seo * sharding seo * single table inheritance seo * singleton seo * spatial partition seo * special case seo * specification seo * state seo * step builder seo * strangler seo * strategy seo * subclass sandbox seo * table module seo * template method seo * throttling seo * tolerant reader seo * trampoline seo * transaction script seo * twin seo * type object seo * unit of work seo * update method seo * value object seo * version number seo * virtual proxy seo * visitor seo * seo enhancements * seo improvements * SEO enhancements * SEO improvements * SEO additions * SEO improvements * more SEO improvements * rename hexagonal + SEO improvements * SEO improvements * more SEO stuff * SEO improvements * SEO optimizations * SEO enhancements * enchance SEO * improve SEO * SEO improvements * update headers
This commit is contained in:
@@ -1,24 +1,26 @@
|
||||
---
|
||||
title: Transaction Script
|
||||
title: "Transaction Script Pattern in Java: Simplifying Business Logic with Consolidated Scripts"
|
||||
shortTitle: Transaction Script
|
||||
description: "Explore the Transaction Script design pattern for Java applications. Learn how to organize simple business logic into efficient scripts with real-world examples and improve your coding efficiency."
|
||||
category: Data access
|
||||
language: en
|
||||
tag:
|
||||
- Business
|
||||
- Data access
|
||||
- Domain
|
||||
- Persistence
|
||||
- Transactions
|
||||
- Business
|
||||
- Data access
|
||||
- Domain
|
||||
- Persistence
|
||||
- Transactions
|
||||
---
|
||||
|
||||
## Also known as
|
||||
|
||||
* Scripted Transactions
|
||||
|
||||
## Intent
|
||||
## Intent of Transaction Script Design Pattern
|
||||
|
||||
Organize business logic by procedures where each procedure handles a single request from the presentation.
|
||||
The Transaction Script pattern in Java organizes business logic by procedures where each procedure handles a single request from the presentation.
|
||||
|
||||
## Explanation
|
||||
## Detailed Explanation of Transaction Script Pattern with Real-World Examples
|
||||
|
||||
Real-world example
|
||||
|
||||
@@ -32,9 +34,9 @@ Wikipedia says
|
||||
|
||||
> The Transaction Script design pattern is a straightforward way to organize business logic in applications, particularly suitable for scenarios where each request from the presentation layer can be handled by a single procedure. This pattern is often used in simple applications or in systems where rapid development and ease of understanding are crucial. Each transaction script is responsible for a particular task, such as processing an order or calculating a result, and typically interacts directly with the database.
|
||||
|
||||
**Programmatic example**
|
||||
## Programmatic Example of Transaction Script Pattern in Java
|
||||
|
||||
Our programmatic example is about booking hotel rooms.
|
||||
Our Transaction Script pattern in Java example is about booking hotel rooms.
|
||||
|
||||
The `Hotel` class takes care of booking and cancelling room reservations.
|
||||
|
||||
@@ -230,26 +232,27 @@ Console output:
|
||||
|
||||
This pattern is suitable for simple business logic and can be easily understood and maintained.
|
||||
|
||||
## Applicability
|
||||
## When to Use the Transaction Script Pattern in Java
|
||||
|
||||
* Use when business logic is simple and can be easily organized into individual procedures.
|
||||
* Suitable for applications with simple transaction requirements or where the logic doesn't justify complex architectures like Domain Model.
|
||||
|
||||
## Tutorials
|
||||
## Transaction Script Pattern Java Tutorials
|
||||
|
||||
* [Transaction Script Pattern (DZone)](https://dzone.com/articles/transaction-script-pattern#:~:text=Transaction%20Script%20(TS)%20is%20the,need%20big%20architecture%20behind%20them.)
|
||||
* [Transaction Script (InformIT)](https://www.informit.com/articles/article.aspx?p=1398617)
|
||||
|
||||
### Known Uses
|
||||
## Real-World Applications of Transaction Script Pattern in Java
|
||||
|
||||
* Early-stage startups and small-scale applications where rapid development is crucial.
|
||||
* Enterprise applications with well-defined procedures like banking transactions or e-commerce order processing.
|
||||
* Legacy systems where business logic is already written as scripts.
|
||||
|
||||
## Consequences
|
||||
## Benefits and Trade-offs of Transaction Script Pattern
|
||||
|
||||
Benefits:
|
||||
|
||||
* Leveraging the Transaction Script pattern enhances code simplicity and accelerates development cycles, especially in startup environments.
|
||||
* Simple and straightforward to implement.
|
||||
* Easy to understand and maintain for straightforward business logic.
|
||||
* Fast development cycle for small applications.
|
||||
@@ -260,13 +263,13 @@ Trade-offs:
|
||||
* Not suitable for complex business logic; can become unmanageable as the application grows.
|
||||
* Harder to test in isolation compared to more structured approaches like Domain Model.
|
||||
|
||||
## Related patterns
|
||||
## Related Java Design Patterns
|
||||
|
||||
* [Domain Model](https://java-design-patterns.com/patterns/domain-model/): Unlike Transaction Script, Domain Model organizes business logic around the data model and is better suited for complex business rules.
|
||||
* [Service Layer](https://java-design-patterns.com/patterns/service-layer/): Often used together with Transaction Script to define an application's boundary and encapsulate the business logic.
|
||||
* [Table Module](https://java-design-patterns.com/patterns/table-module/): Similar to Transaction Script but organizes logic using a single class per table rather than a procedure per request.
|
||||
|
||||
## Credits
|
||||
## References and Credits
|
||||
|
||||
* [Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions](https://amzn.to/3WcFVui)
|
||||
* [Patterns of Enterprise Application Architecture](https://amzn.to/3WfKBPR)
|
||||
|
||||
Reference in New Issue
Block a user