All Questions
Tagged with java design-patterns
300
questions
5
votes
3
answers
634
views
Password checker using Decorator Pattern
I'm currently trying a Password checker for password in Decorator Pattern, which will point out what the current password missing to be a strong password (my example will check for 8 characters, at ...
3
votes
1
answer
209
views
A library management system
Following is my code for a library management system. I am pretty new to OOD and trying to learn it. I am specially looking for ways where any design patterns can be useful here. I tried to make ...
2
votes
0
answers
58
views
Implement Iterable where hasNext depends on mutable object state, which is mutated through explicit call
I am trying to implement the Iterable interface on an object, where the hasNext method on iterator will depend on mutable object state. This state is mutated by ...
0
votes
1
answer
40
views
Object build while sequential read user input [closed]
The implementation reads sequentially the user's input changing the type to build according to user choices.
There are two main components a conditional structural sharing (...
3
votes
1
answer
93
views
Sequentially find the indexes of an element into a collection
Util class to find into a collection the indexes of a given element with multiple occurrences from the first index or relative to a given index.
...
1
vote
2
answers
87
views
Verification job with multiple type of batch verifiers
I have a use case where a verification batch job (non-generic) verifies domains based on its input e.g domain_type, batch_pointer etc. The verification handles it based on the domain type which uses ...
1
vote
1
answer
126
views
Business logic verification template
I have a use case of template design pattern with generics as mentioned below.
I have AbstractVerificationHandler that provides template for verification business ...
1
vote
0
answers
139
views
Chain of Responsibility in the game of Hangman
I tried to do the Hangman Refactoring Kata for the piece of code over here - https://www.youtube.com/watch?v=-0MeoFTj6DU
This is how the initial code looks like after first set of refactorings (i.e. ...
2
votes
1
answer
145
views
Implement saga pattern with Kafka
There are very few example on how to implement saga pattern with Kafka so I tried to come up with my own implementation choreography saga pattern using Kafka. I need to implement outbox pattern as ...
1
vote
1
answer
1k
views
How to transform the CompletableFuture response
Context: I have a client app which consumes an API. I want to call this API is async way (using java.net.http.HttpClient) and once I receive this data then I want ...
2
votes
1
answer
85
views
Build a message string depending on the type of signature of an invoice
The following method was meant to build a message depending on the type of signature of an invoice. It contains some if-else statements and code duplication.
The original method :
...
4
votes
1
answer
2k
views
Java 2 Player Object Oriented CLI Chess Game
I just finished implementing a Java 2 player CLI chess game, it involves player putting in commands (i.e "move e2 e4" to move or "attack d1 d5" to capture.).
I am trying to follow ...
2
votes
0
answers
246
views
Is MVC an overkill for a chess CLI game?
I am working on a CLI chess game that only involves 2 human players, I decided to make it follow the MVC architecture to ensure separation of concern and to make the possibility of a GUI/web ...
3
votes
0
answers
205
views
Simple Java IoC container for dependency injection
I have come up with a quick and simple IoC container to enable minimal dependency injection support in one of my Java projects.
The container supports services with:
A transient lifetime, meaning, a ...
4
votes
1
answer
231
views
Command design pattern for RPG prototype
I'm writing an assistant for the tabletop RPG Pathfinder in Java. I already have a few building blocks and decided to make a small side-project to play around the Command pattern. I know that there ...