interface Base<T extends Base> {
T method();
}
Against this pattern design
interface Base {
Base method();
}
The only, I guess, with method()
in Base
I can get the specific type.
Are there more benefits?
Web application Design Patterns can help developers not only focus on the application design to build a powerful and functional User Interface for any web application but also to address many common issues even before they happen.
Explanation: Design patterns help one to write the process faster by providing a clearer picture of how one is implementing the design. The Design patterns encourage reuse and accommodate change by supplying well-tested mechanisms for delegation and composition.
The Value Object pattern provides the following general benefits: Better domain modeling and understanding. Recognizing a domain concept as a value type and implementing it as such reduces the gap between the domain model and its implementation. This eases code comprehension.
You just save one cast. Here is an example:
class A implements Base<A> {
...
}
A a = ...;
A b = a.method();
vs
class A implements Base {
...
}
A a = ...;
A b = (A)a.method();
You can also build on it using T parameter all over the place. Consider accepting T as a parameter or defining a local variable of type T, for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With