Questions tagged [java]

Java is a high-level, platform-independent, object-oriented programming language originally developed by Sun Microsystems. Java is currently owned by Oracle, which purchased Sun in 2010.

Filter by
Sorted by
Tagged with
0
votes
0answers
19 views

Testing Proxy with its service

I have a program that contains client and api logic. In summary client works like this: 1) Client handles client code 2) Calling the API is surrounded in (lets call it ) ClientService 3) if client ...
-2
votes
1answer
68 views

Reducing duplicate API call between micro services in a latency sensitive flow

Let's suppose that I have 5 microservices, let's also name them ServiceA, ServiceB, ServiceC, ServiceD, ServiceE. To perform an operation X communication needs to happen between these services. And ...
-2
votes
2answers
58 views

Is a JVM based dbms like Neo4J implemented ideally?

Since Neo4J is implemented in Java and therefore uses the JVM, wouldn't an equivalent graph database that is written in C++ / Rust or GoLang be more performant? Why would one decide to build a DBMS ...
2
votes
1answer
107 views

Is it allowed to include the composition in the compositor in the Strategy Pattern

I have a range of different animals in my zoo such as turtles, birds etc. As they all share a common trait such as either swimming, flying etc., I thought a strategy pattern would be appropriate to ...
0
votes
1answer
416 views

Decouple business logic from DTO

I've to implement some Backend Webservices, which provide a given, final JSON structure, which is allready in use on the FrontEnd side. This structure doesn't match the database structure, so I have ...
0
votes
2answers
197 views

Designing a scalable microservice: how to prevent one instance from performing an action if another instance allready did?

As I am moving a part of the monolith app logic to a microservice, I am standing before a problem with scalability. Currently, the main monolith runs on different instances, and has some scheduled ...
1
vote
0answers
59 views

Architect Java Hashmap Hierarchy to its equivalent in Redis Cache?

I have the following Job class representing runs of a job. I have a list of start and end times in Job class because the same Job can be rerun. public class Job { private final List<...
1
vote
1answer
222 views

Design Chess - Object Oriented Design

I am trying to design online chess game(figuring out required classes). Need some suggestion on choosing better option to validate the move. So, lets say, I have below class Option 1 : My ...
9
votes
3answers
920 views

Implementation of quantities and units in a recipe manager

I am writing a recipe manager for a software engineering class I am taking, and I would like to implement classes (in Java, if it matters) to allow quantities and units. Now, taking recipes into ...
-5
votes
1answer
61 views

Java version: When to migrate? [closed]

About 4 years ago, where I was working, software was still being developed with Java 7 + Swing. It took me a couple years, but we could finally migrate to Java 8 + JavaFX, two years after that. Now ...
-2
votes
1answer
58 views

Optimal Data Structure for Searching though String

I am current developing a karaoke app in JavaFX, I need advise on the most optimal data structure storing a huge list of songs (library). I am inclined to use Binary Search Trees due to its Big O ...
-4
votes
2answers
135 views

Why is C++ not updated as frequently as Java? [closed]

Java was last revised in 2020, while C++ had it's update back in 2017
-1
votes
1answer
150 views

Exposing java service as static method or seam dependency

Our legacy application provide a static method public static boolean persist(Data data) for service/class callers for data persistence. I do see unit testing issue for callers. Is this also an ...
-2
votes
1answer
87 views

How to handle financial transactions across multiple pods of a service deployed on Kubernetes?

So, the question I have is how do companies handle transactions from a user with bad connectivity. The scenario in my head is. A user X (with $150 in their account) is trying to transfer $100 from ...
1
vote
1answer
155 views

Spring Boot/Batch: Should every Job be separate Maven module?

I'm building a backend service powered by Spring Batch which enables to define and Jobs. Currently, I have several jobs, that essentially, aren't related one to another. So, I have one application....
2
votes
2answers
154 views

Large method with nested switch case(s) refactoring (Java)

Essentially I've got a bunch of formulas in two giant methods in a class designed to do math transformations and evaluations to multiple inputs. Where the inputs are actually lists of inputs (as there ...
2
votes
1answer
83 views

How to properly model an MVC model in this case?

I aim to understand pull model MVC. I'm stuck at defining a model for a simple color-guessing game in Java Swing I chose to practice it. I borrowed the model's initial version from an example which ...
1
vote
1answer
66 views

Validation framework and immutability

I have designed a simple objects validation framework in Java in the context of a code refactoring. The framework has a ValidationRule interface with one method Errors validate(MyObject myObject, ...
2
votes
1answer
208 views

How to build a modular/extensible Spring Boot application?

I'm developing a Spring boot / Batch application. What I'd like to do is to have a separated module for every job. This is a reasonable decision because different tasks (Spring Batch Job) have ...
28
votes
7answers
9k views

Polymorphism case study - Design pattern for morphing?

Imagine two classes: class Person { MarriedPerson marry(Person other) {...} } class MarriedPerson extends Person { } The idea is that a Person is automatically "morphed" to type MarriedPerson ...
1
vote
3answers
241 views

When do you do a health check?

So, I have an application here that posts requests to another service via REST API calls. I have to implement a health check within my application that ensures that the other service is up. I'm a ...
1
vote
0answers
24 views

How to Upgrade MQ with incremental approach with 50 micro services

I have around 50 microservices which communicate with each other using Apache MQ implementation. I want to know if I can avoid big bang approach when I need to upgrade the MQ version. Current option ...
0
votes
1answer
143 views

Need for a domain model in a service in 3 tier architecture?

I am building an API Rest with Spring Boot and I would like to clarify a concept about my architecture, to see if the community can help me. Imagine that in my database I have a table called Person. ...
0
votes
0answers
3k views

Spring Data MongoDB: Update document based on multiple identifiers with Composite ID vs. MongoTemplate upsert vs. MongoRepository find & save

I'm wondering for best practices to upsert a document based on two identifiers. @Document(collection = "cars") public class CarEntity { @Id private ObjectId id; private String ...
3
votes
2answers
553 views

Why Kotlin doesn't allow assignments as expressions?

Coming from Java, I was surprised to find out that Kotlin doesn't allow assignments as expressions. Is there a reason for that? Java (Works) @Test public void test_x() { List<...
1
vote
4answers
1k views

How is a nested Try/Catch (inside the try) not an anti-pattern

I've seen a debate on this. Nested trys in the catch, I can see that being okay. The outer try has already triggered a catch by that time, hence no scope issues. The other way....hides errors (it is a ...
0
votes
2answers
237 views

Designing a Parser - Abstract vs Interface

I am building a mini SQL parser that reads and converts SELECT, INSERT, UPDATE and DELETE statements into an AST. My current design is as follows: Statement.java: public interface Statement { ...
-4
votes
1answer
53 views

Command-Query Separation non-compliance

Why does Java's V Map.put(K key, V value) not comply to the Command-Query Separation?
1
vote
0answers
41 views

how to handle external shared libraries, which we do not want to expose

We have 800-900 services we expose via an ESB. Each service is a web app hosted on Tomcat servers. We have 4 tomcat servers per group of services. Our services are split into 4 groups. Each service (...
47
votes
4answers
7k views

Why are there multiple different implementations of JVM?

While going over a java book I came across this phrase: Different JVMs can run threads in profoundly different ways. While it's completely understandable to me that code can behave differently ...
-1
votes
1answer
91 views

Is it bad to break out of a labelled block in Java?

I sometimes write Java code that looks like: success: { fail: { if (...) break fail; // some code if (...) break fail; // some code if (...) break fail; ...
-4
votes
2answers
172 views

An idea about cooperation between development engineers and test engineers

Suppose we want to develop a small module (time needed: two weeks of one developer). Then what about this new (maybe?) pipeline: The test engineer starts working: Think about all cases (including ...
0
votes
1answer
369 views

Mapping bidirectional 'toMany' relation from DTO to entity

The application that I am working on has numerous ...toMany relations, e.i. class Model can have several parameters. In Unidirectional world, it is simple to manage a collection. I can clean the ...
1
vote
4answers
298 views

Role of DTOs in Rich Domain Model

I work with Spring applications. Recently I have found this article about the Anemic Domain Model. They recommend putting logic in Entity classes. It solves a problem that Martin Fowler described in ...
-2
votes
1answer
299 views

Generate large Excel files and response from API

I need to generate a large Excel file (something around 50 megs) and send response to another API which will provide it to the front end for a download option. My question is if it will be better to ...
-1
votes
1answer
105 views

Display different panel on button click (MVC pattern)

I have to code a gui like this: It's an homepage with a left menu and a changing right part, on button1 click form1 must be displayed, on button2 click form2 a so on. Each form has its own button "ok"...
-3
votes
2answers
103 views

In java string classes are final, than how did we enter value on string even its a final class?

In Java string classes are final, we know that we can't inherit a final class and not able to write on this, then how did we enter a value on a string even its a final class?
2
votes
1answer
101 views

Handling OAuth 2.0 access token

I am creating a rest template to consume REST API secured by OAuth 2.0. The provider has implemented an expiry for the access token for 5 mins. So Using the rest template, I will be calling the ...
0
votes
6answers
132 views

Adding client specific method to a listener interface is a good idea?

I'm using a listener pattern where a class A listens for events from various classes B, C, D with the help of a listener interface I Essentially the structure looks like: interface I { void ...
0
votes
1answer
222 views

How to avoid “mock returning mock” when using factory pattern

I have recently encountered multiple articles with title Everytime a mock returns a mock a fairy dies And I ran into exact same situation while using factory class in my code. I am writing a sample ...
1
vote
0answers
33 views

subinterfaces redeclaring abstract methods

Why is it that some abstract methods in interface hierarchies are redeclared as abstract further down? iterator() for example, abstract in Collection is redeclared in Set and List, and again further ...
1
vote
1answer
82 views

Structuring application to comply with Single responsibility

I have the class AircraftManager that keeps track of a list of Aircraft objects and a list of AircraftListener objects. A DataSource (custom class, not sql related) object retrieves information from ...
2
votes
2answers
632 views

Maven: Versioning for multi module repository

Versioning is always a big question and I see many similar questions here, however none really answer my question so I try to highlight the things that are important to me specifically. We have a ...
2
votes
1answer
77 views

Which is the better architecture to follow for API Development in Java using any RDBMS database backend?

This question is regarding the better architecture to follow for API Development in Java using any RDBMS database backend. Currently, we are using the below approach to fetch data from database and ...
0
votes
2answers
307 views

Model View Controller pattern for a Java desktop application

I'm struggling to fully understand MVC pattern, I found a lot of information on the web but they are really confusing because it seems there are various ways to do it. What I understood is that the ...
-2
votes
1answer
474 views

Pass ID or Object which has irrelavant details as RequestBody in Rest Call?

Situation: I am designing a REST API that needs one or more, potentially large objects to do it's work I am facing a decision to either Pass the large object by reference and have the API retrieve ...
-2
votes
4answers
262 views

Is adding methods in a subclass poor design?

Let's say we have a abstract super class A with abstract method m1 and m2. B inherits from A, overrides m1 and m2 and defines a new public method m3. Since to access m3 we have to cast B and this ...
-1
votes
1answer
447 views

Difference between objects and data structures?

So I was reading https://hackernoon.com/objects-vs-data-structures-e380b962c1d2 and I stumbled upon this quote : "A Person data structure has a first name, last name, and phone number. A Person ...
0
votes
2answers
108 views

How to design a process and use the business rules for sending alerts/notifications

Currently working on designing a process which demands me to send alerts like email notifications to the users which meet a business criteria(we can also call business rules). I want to make this ...
1
vote
2answers
549 views

When to model an aggregate's entities as part of a value object?

I've read a lot about Domain Driven Design including books from Eric Evans and Vaughn Vernon. So I am familiar with the concepts Aggregate Root, Entity, and Value Object. But while I was modeling ...

1
3 4
5
6 7
95