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
2answers
52 views

What directories and files should I push to my Git repository from local?

I have been using Netbeans to practice JDBC coding. Netbeans projects create multiple sub-directories (/build, /lib, /src...). Should I add and commit all of these directories and files or should I ...
-1
votes
1answer
33 views

Parametricize type by Enum value in Java?

I was looking into parametrizing generic classes in Java with Enum values to increase type safety and for some compile-time checks (I know generic parameters are ereased at runtime). Premises With ...
0
votes
1answer
41 views

Service layer returns DTO to controller but need it to return model for other services

Following this post https://stackoverflow.com/questions/21554977/should-services-always-return-dtos-or-can-they-also-return-domain-models and best practices in Software Arch suggestions by Martin ...
-4
votes
0answers
30 views

Basic design and architecture of an application with a Form and a database back-end [on hold]

I have a requirement to create an application for a client. The requirements are - 1.Create forms for the user to fill in details. 2.Store the data from the form 3.Provide search ability to the ...
0
votes
1answer
50 views

How To Design Event Handlers With Different Parameters

I have an interface Event and a class Agent. I want to be able to write something like agent.handle(event). However, the classes that implement the event interface will all have different fields ...
2
votes
4answers
144 views

When is it appropriate to reuse a method for another method?

I am writing a program that describes different properties on a single Management Company's plot of land. For this program there are 3 overloaded addProperty method's. My question is I can reuse the ...
5
votes
2answers
121 views

Is the builder pattern appropriate to use to update Objects in a Service layer?

Currently, in our service layer, we pass an id as well as a new updated value, something akin to updatePersonName(Person person, Name name) which, in turn, calls the corresponding repository ...
3
votes
3answers
293 views

Java: Why not allow nulls in methods to represent optional parameters?

I wanted to follow up on this previous question I asked related to @Laive comment, but I couldn't think of an excellent way to do so without asking another question, so here we go. With the previous ...
-3
votes
0answers
16 views

authentication and authorization with Oauth2 and spring security

I have a quick questions In your opinion, it makes sense to implement OAuth2 if all clients will be accessing their information via a trusted application? My use case: I have a mobile application, ...
2
votes
6answers
215 views

Java (or other Java-like languages): Best practice for many optional parameters?

Code design question for Java or Java-like languages (excluding languages which support default values for method parameters such as Javascript flavors): You would like to implement a method with the ...
1
vote
2answers
91 views

Tree data structure where children can only be added based on their type

I have a tree data structure where each node has a name, an id, a type and a number of children. Additionally each node has properties based on its type. Thereby each node with type A should only ...
0
votes
1answer
28 views

How can we better maintain a large amount of DbUnit datasets?

The project I'm currently working on a Spring Boot project, and I have a question regarding testing against the database. Our testing tech is currently JUnit 4, Mockito and DbUnit, and we test ...
3
votes
3answers
195 views

Does each microservice need its own server running (Tomcat, docker container)

In development I have a Java backend API which I'm running with Tomcat. I'm wanting to wrap the backend in a docker container and deploy to an AWS EC2 instance, and be able to scale up/down. Does ...
0
votes
1answer
52 views

How do I negotiate messages to avoid errors resulting from duplicate messages?

My system looks the following: I have N message producers, N RabbitMQ instances, N message consumers and 1 service. Producers produce the same messages while consumers consume the same messages. Here ...
1
vote
2answers
77 views

Need good design: Anemic Model, Inheritance and Pattern Matching

I have Handler classes which accepts Queries and returns Results. Handlers is anemic. They accept input data bag and returns output data bag. Handlers can be many so I created common generic interface ...
-3
votes
1answer
63 views

Java swing debugging [closed]

I have programmed a Java Swing application. I have some bugs in my program and I want to discover where in the code these errors occurs. With normal code (Non-GUI related code) I apply debugging for ...
-3
votes
0answers
35 views

Including jdk in app bundle for mac

I have developed a Java application and have placed it within a .app bundle for distributing on mac. However, when I try and run it on a mac it says I need to have the jdk installed "to use the 'java' ...
1
vote
0answers
57 views

Practice for modeling class - multiple container relationship

I have a class that could: Have multiple types of containers Have multiple types of implementations and what I did to model so far is: public interface ChildClass { Container getContainer(); ...
0
votes
2answers
78 views

How to refactor function chains for Java 8 Streams

I have a stream of data recordStream that I am collecting into a Map. Using a chain like this. recordStream .filter(Objects::nonNull) .map(RoomSchedule::new) .map(...
-1
votes
1answer
59 views

Microservices: how far should coupling / decoupling of application parts relying on the same data backends go?

I am in the process of migrating a pretty much monolithic PHP application to microservices. With the development pipeline, docker containerisation, CI/CD and scalability in mind, what would be the ...
2
votes
1answer
118 views

Human and AI subclasses for Player class

I am looking to implement two branches of classes in my Java program to distinguish between Human and AI-controlled Players in my game. The game is asynchronous, so players have different methods and ...
2
votes
1answer
58 views

Form validation code shared in the frontend and backend API?

I have a legacy Java monolithic web application. My goal is to use React on the frontend, keep Java on the backend and add an API for the frontend to use. My question is how can I write the data ...
0
votes
0answers
48 views

Distributing a Java application on macOS

I have developed a Java application for both Windows and MacOS. The application requires 2 separate jar files, 1 for the main application and then another is used to download and apply updates. This ...
-3
votes
0answers
35 views

Oracle sybase bidirectional synch [on hold]

I need to keep oracle table in synch with sybase ASE table. Oracle table gets a few hundred rows added every few minutes, I need to insert those new rows into sybase table, then sybase starts ...
-1
votes
0answers
21 views

Using Eclipse JDT Plugins Outside Eclipse

I want to write a script or program that uses an Eclipse Plugin, precisely JTransformer, to analyse the code of a project without having to load the project in Eclipse itself so I can run it as a part ...
0
votes
1answer
35 views

How to handle the getting of information from Model

I'm doing a Java software engineering team project in school and my team has decided on a Finance Tracker application, which contains the main components of Expense, Budget, Statistics, Suggestions ...
2
votes
1answer
58 views

best way to create @PUT upon multiple entities and compatible with RFC

I am trying to build the best PUT possible that allows modifying multiple entities upon single requests using java jersey. The idea is to send a request with multiple entity ids as @PathParam values ...
39
votes
8answers
3k views

Do access modifiers matter? [closed]

The theory is that access modifiers improve code safety because they support encapsulation of internal state. When doing OOP, every language I've used implements some kind of access restriction. I ...
2
votes
2answers
121 views

Is it clean to place method for comparing 2 objects of same class into that class?

Let's say I have class Car (just for illustration) class Car { ... boolean isRed(); ... } where to place methods which acts with objects of same class, in my example Car, but not just on ...
2
votes
2answers
128 views

Design pattern for static fields of a subclass

I'm creating a library, and I want there to be an abstract class called Optimizer. The user should be able to choose from a set of predefined Optimizers and if desired, use fluent methods to change ...
-2
votes
0answers
22 views

Organize Maven multimodule project with multiple WAR

I have a project which consists in several modules. Three of these modules are WARs. The rest of the modules are JARs containing the model, repositories and services to be used for the WARS. The ...
-5
votes
0answers
38 views

What do you think about DTOs in Spring Data JPA project?

First of all, I am not a junior programmer. I'm just looking for best-practice. How do you use entities and DTOs into your Spring Data JPA projects? Assume there is our layers: Repositories (as ...
-3
votes
1answer
64 views

How to make code runnable on open source code editors like Ace Editor?

For my computer science uni project I'm required to build a web application with an integrated code editor. I believe I can just integrate open source editors like Ace Editor. However, I feel ...
1
vote
1answer
128 views

Java - private static vs. public static

A wrapper class for storing primitive parameters which are initialized with values. Is it better to use public static or private static with bunch of getters and setters, for these constants? public ...
-3
votes
0answers
28 views

Eclipse JavaFX issue

I am using Eclipse to program a game as part of a school project and I am going to need to use JavaFX. At my school, the computers have an older version of Eclipse already installed and JavaFX works ...
2
votes
1answer
92 views

Should I wrap a 3rd party library?

I'm developing an application that manages many different components, including various objects in a Kubernetes cluster. There's a nice Java library to manage K8S objects, I use it to examine objects ...
8
votes
3answers
439 views

Does it violate the Single Responsibility Principle if an object knows how to change itself?

I have worked with examples like a Player object which knows how to change its own state. Another example, is an Invoice object which knew how to calculate its invoice charges using an algorithm. ...
1
vote
5answers
275 views

When should i use an abstract class vs an interface? [duplicate]

I'm fairly new to programming. At school I am currently learning to program with Java. I want to build an application where i can store my collection of books, records, boardgames and such. Started ...
-4
votes
0answers
31 views

How to download and install jaspersoft studio in ubuntu

How to download and install jaspersoft studio 6 .3.1 in ubuntu.What is the different of jaspersoft report and jaspersoft studio
1
vote
3answers
227 views

Which option is best, when you have an attribute that is a list?

I have a class containing a list, for example: class User{ .... List<String> cards ... } What's the best way to provide access to this member? List<String> getCards() or ...
2
votes
1answer
153 views

Better practice of workaround for implementing a type field in Java

We have a class in our company's main library as follows: public class User { private long id; private UserType type; // Getters, setters, constructors, etc. } and have several options ...
-2
votes
0answers
39 views

Which pattern to use to do projection of POJO in API response?

Say that I have this POJO. public class Customer { public String id; public String name; public String lastname; public String birthdate; public String adress; } I have an API ...
1
vote
1answer
47 views

RMI vs APIs vs Akka Cluster

We have a Java Play Framework Application which we want to scale out into a cluster. The only issue is that there are services ran by the Akka Scheduler once per day, and we don't want these services ...
-3
votes
1answer
32 views

read text file with extended ascii from Google Cloud Storage (Java)

We have a text file with extended ascii (words like 'Systèmes' and 'Café'). It is in Google Cloud Storage. Its Content-Type is text/csv. If I download it via the browser UI (https://console.cloud....
3
votes
2answers
165 views

Is recommendable set as final as classes by default in a SDK?

I am working on the development of an SDK in Android with Java, In general the user doesn't need to inherit any class of the SDK, so the question is if it is a good practice put by default all classes ...
0
votes
0answers
50 views

Mapping properties to lambdas instead of using factory method/pattern

I'm receiving a JSON object which has many properties and the properties change (properties are added/removed) according to the type of the data in the JSON object. I'm expecting to receive many ...
4
votes
1answer
184 views

Delegate vs Forwarding in Java OOP

I'm reading some article about "prefer composition over inheritance", and heard about Forwarding and Delegation. After search for the different I found some source: https://en.wikipedia.org/wiki/...
2
votes
2answers
254 views

Why doesn't C++ support covariance in STL containers like C# or Java?

The Covariance and Contravariance feature is well supported in C# and Java collections. However C++ doesn't support them in their STL containers. Why is it so? For example the below code will ...
3
votes
2answers
164 views

When covariance becomes an issue, how can I restructure my code and still be clean?

Suppose I have the following interfaces, GameObject and Enhance. GameObject: public interface GameObject { void prepare(); void use(); void cleanup(); } Enhance: public interface ...
1
vote
4answers
235 views

Do we always need to override equals/hashcode when crreating a new class?

When creating a new class, should we always override the equals and hashCode even if we don’t intent at that point to use the class with any Collection classes? Or is it better to wait till such a ...