mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 08:58:26 +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:
+18
-17
@@ -1,24 +1,26 @@
|
||||
---
|
||||
title: Parameter Object
|
||||
title: "Parameter Object Pattern in Java: Simplifying Method Signatures with Structured Data"
|
||||
shortTitle: Parameter Object
|
||||
description: "Explore the Parameter Object pattern at Java Design Patterns. Learn how it simplifies method signatures, enhances maintainability, and promotes encapsulation with real-world examples and detailed code snippets."
|
||||
category: Structural
|
||||
language: en
|
||||
tag:
|
||||
- Abstraction
|
||||
- Code simplification
|
||||
- Decoupling
|
||||
- Encapsulation
|
||||
- Object composition
|
||||
- Abstraction
|
||||
- Code simplification
|
||||
- Decoupling
|
||||
- Encapsulation
|
||||
- Object composition
|
||||
---
|
||||
|
||||
## Also known as
|
||||
|
||||
* Argument Object
|
||||
|
||||
## Intent
|
||||
## Intent of Parameter Object Design Pattern
|
||||
|
||||
Simplify method signatures by encapsulating parameters into a single object, promoting cleaner code and better maintainability.
|
||||
The Parameter Object pattern is a key Java design pattern aimed at improving code maintainability by reducing method complexity through encapsulation of parameters into a single object.
|
||||
|
||||
## Explanation
|
||||
## Detailed Explanation of Parameter Object Pattern with Real-World Examples
|
||||
|
||||
Real-world example
|
||||
|
||||
@@ -38,9 +40,9 @@ wiki.c2.com says
|
||||
|
||||
> Replace the LongParameterList with a ParameterObject; an object or structure with data members representing the arguments to be passed in.
|
||||
|
||||
**Programmatic example**
|
||||
## Programmatic Example of Parameter Object Pattern in Java
|
||||
|
||||
The Parameter Object design pattern is a way to group multiple parameters into a single object. This simplifies method signatures and enhances code maintainability.
|
||||
The Parameter Object design pattern is a way to group multiple parameters into a single object. This simplifies method signatures and enhances code maintainability enabling Java developers to streamline complex method calls, focusing on cleaner and more maintainable Java code.
|
||||
|
||||
First, let's look at the `ParameterObject` class. This class encapsulates the parameters needed for the search operation. It uses [Builder pattern](https://java-design-patterns.com/patterns/builder/) to allow for easy creation of objects, even when there are many parameters.
|
||||
|
||||
@@ -127,24 +129,23 @@ public class App {
|
||||
|
||||
This example demonstrates how the Parameter Object pattern can simplify method signatures and make the code more maintainable. It also shows how the pattern can be combined with the Builder pattern to make object creation more flexible and readable.
|
||||
|
||||
## Applicability
|
||||
## When to Use the Parameter Object Pattern in Java
|
||||
|
||||
* Methods require multiple parameters that logically belong together.
|
||||
* There is a need to reduce the complexity of method signatures.
|
||||
* The parameters may need to evolve over time, adding more properties without breaking existing method signatures.
|
||||
* It’s beneficial to pass data through a method chain.
|
||||
|
||||
## Tutorials
|
||||
## Parameter Object Pattern Java Tutorials
|
||||
|
||||
* [Does Java have default parameters? (Daniel Olszewski)](http://dolszewski.com/java/java-default-parameters)
|
||||
|
||||
|
||||
## Known Uses
|
||||
## Real-World Applications of Parameter Object Pattern in Java
|
||||
|
||||
* Java Libraries: Many Java frameworks and libraries use this pattern. For example, Java’s java.util.Calendar class has various methods where parameter objects are used to represent date and time components.
|
||||
* Enterprise Applications: In large enterprise systems, parameter objects are used to encapsulate configuration data passed to services or API endpoints.
|
||||
|
||||
## Consequences
|
||||
## Benefits and Trade-offs of Parameter Object Pattern
|
||||
|
||||
Benefits:
|
||||
|
||||
@@ -164,7 +165,7 @@ Trade-offs:
|
||||
* [Composite](https://java-design-patterns.com/patterns/composite/): Sometimes used with parameter objects to handle hierarchical parameter data.
|
||||
* [Factory Method](https://java-design-patterns.com/patterns/factory-method/): Can be used to create instances of parameter objects, particularly when different parameter combinations are needed.
|
||||
|
||||
## Credits
|
||||
## References and Credits
|
||||
|
||||
* [Design Patterns: Elements of Reusable Object-Oriented Software](https://amzn.to/3w0pvKI)
|
||||
* [Effective Java](https://amzn.to/4cGk2Jz)
|
||||
|
||||
Reference in New Issue
Block a user