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
2
votes
1answer
33 views

Efficient way to store “item” objects in a simple game

I am developing a simple text-based game. In this game, the user is able to collect items and store them in an inventory. My question is: how should I organize the internal structure of my game so ...
-3
votes
0answers
35 views

How does creating and initializing a map in Java using an anonymous class potentially cause memory leak issues?

I've seen code that creates and initializes a map by extending HashMap (via an anonymous class) and initialization block as follows: final Map<String, String> headers = new HashMap<String, ...
-4
votes
1answer
55 views

Which API building practice is better?

Im working on a ERP product, In which backend logics are to be APIs. Right now I have around 80 Tables. Proposal 1: Creating CRUD APIs for all tables and manipulation of data to be handled in front ...
1
vote
0answers
41 views

Rectangle packing / Bin packing with multiple frames

I have multiple rectangular frames, with different fixed heights. The width should be minimized and there is a maximum width. Then there are many different smaller rectangles. These should be packed ...
-1
votes
1answer
32 views

Should all third party methods that access outside resources (like other databases) be wrapped up?

From the perspective of unit testing, the code under test should obviously not be accessing outside resources so the third party methods need to be mocked. However, it seems like this is poor practice ...
-5
votes
1answer
106 views

What is the point of interfaces and abstract classes? [closed]

So I'm taking a course on java programming, and in the lesson about interfaces, they gave an example of an interface with a Bird class, along with Chicken and Sparrow subclasses that extend Bird. They ...
0
votes
1answer
51 views

RxJava and race conditions

I have seen some RxJava projects using multithreading with .subscribeOn(Schedulers.io()), and their .subscribe(() -> {...}) code is manipulating some data structures that are also processed by ...
1
vote
1answer
66 views

Using a domain model to persist metrics

I am currently developing a spring boot web application in which no entity is persistent, and hence will not be saved on a database. Although, I need to be able to query some business metrics from it. ...
0
votes
1answer
46 views

Authenticating requests from third party users to our APIs

We have a web app which has certain APIs. Users of our webapp will use these APIs when they login to our webapp (like how many records me as a user do I own, user specific, etc). We are creating ...
0
votes
1answer
105 views

How do Java's proposed Inline Classes compared to Value Types in C#

There is talk once again about Inline Classes being added to Java. As someone who understands C#, what is the best ways to think about them? As a C# program what am I likely to misunderstand about ...
-6
votes
1answer
66 views

State design pattern for vending machine

I have to write a java program for a vending machine which: Accepts coins of 1,5,10,25 Cents i.e. penny, nickel, dime, and quarter. Allow user to select products Coke(25), Pepsi(35), Soda(45) Allow ...
-5
votes
1answer
104 views

Use Case Diagram for Vending machine

I want to create a use case diagram for a vending machine which has the following states: Accepts coins of 1,5,10,25 Cents Allow user to select products Coke(25), Pepsi(35), Soda(45) Allow user to ...
-3
votes
0answers
18 views

What should be a standard module structure in Spring BOOT for CRUD applications?

Most of the spring boot CRUD applications are very similar to each other. I have used the following module structure so far. - config - DB Config - Application Property Config - Bean Config - ...
0
votes
0answers
19 views

How to change response when token expire using AuthExceptionEntryPoint?

I'm facing issue in spring security custom response. I have asked question in stackoverflow community also, Here is link for Question, Can anyone help me out for this issue.
-1
votes
1answer
47 views

How can we extend a packet in the case of an overflow?

I have asked this question in stackOverflow, but I guess that maybe softwareEngineering is more appropriate. (here is the question in stackOverflow) I have frames sized with a fixed size of 7 values (...
2
votes
1answer
83 views

How to handle db password change in a live service

Suppose I have a REST application running on a remote server which connects to a mysql database. Now let's say the password of the db has to be changed. What are the right methods and practices that ...
1
vote
5answers
154 views

Is this an anti pattern or misusing the interface default method?

Instead of checking the null and throwing exception each time we call findByOrderNumber method, I came up with this pattern by taking advantage of a default method, are there any patterns misused here ...
0
votes
1answer
40 views

Implementing a user ID system like Discords for a web app using Java Spring, JPA, Hibernate and MySQL

I’m trying to create a web application with a forum and user profile along with other functions. However I’m thinking about how I might implement an ID for each user. The best way I’ve seen other ...
0
votes
0answers
48 views

Java Design Practice

I have gone through similar questions on this site and stackoverflow.com, but because I am still curious and want to cover all possible spectrums of this design, I am asking this question. I am ...
0
votes
2answers
74 views

Design pattern to validate list of conditions

Background: I have a JSON object (named JSONConditionObject) which looks like the following, { "condition1":"value1", "condition2":"value2,value3 ..." ...
0
votes
0answers
31 views

How to achieve both: clean (hexagonal) architecture with JPA goodies?

How do I achieve two things at the same time writing Java Spring Application: Clean Architecture JPA goodies (@Transactional, Optimistic Locking, dirty checking, etc.) I like the idea of database/...
2
votes
4answers
264 views

How do I deal with the fact that I am forced to make helper functions public for testing purposes?

I've encountered several scenarios that require me to mock certain helper methods because they call outside resources. As a result, I'm forced to convert all my helper methods from private into public....
0
votes
1answer
75 views

Extension of classes - Where to put behaviour - How much direct-access is allowed

At this point i would exclude the inheritance.... So the question is about more like extend into a seperate class or into the class which should be extended, both play in the composition-league. So ...
-3
votes
0answers
26 views

Android app in python using java libraries

I would like to write a app in python that runs on an Android tablet. I did some research and found out that that's possible when using tools like e.g. BeeWare. Now my problem is that I have to use ...
0
votes
2answers
84 views

How do the SOLID principles apply in the context of Lambdas and Streams? [duplicate]

How are these principles applied in the context of streams and lambda expressions? In particular, the applicability with respect to the following three principles: - Single Responsibility Principle (...
-4
votes
1answer
34 views

Should I handle a null value passed into a method inside the method or from the caller?

Say I have a method like so: public boolean extract(String string) { // return true if string can be extracted, false otherwise } And a caller if (!StringUtils.isBlank(myString)) { boolean ...
0
votes
0answers
21 views

How to support alternative behaviour at the end of a pipeline when the new behaviour is decided at the beginning?

Let's assume we have a few loosely coupled components that form a pipeline. At the end is an file generating component. A new requirement comes in that requires an parallel alternative behaviour for ...
0
votes
0answers
44 views

Ways to refactor project to match SOLID principles [duplicate]

I'm learning Java and recently started to write my own project. The idea of this project is to pass one input argument - path to file/folder, which would be analyzed in order to find all files with ...
4
votes
3answers
180 views

Java interface design: where should I put a lot of duplicate code that will be used by all subclasses?

Java interface design: where should I put a lot of duplicate code that will be used by all subclasses? interface Tuple { void method1(); } class Tuple1 implements Tuple { @Override public ...
1
vote
4answers
115 views

Is a class with a high number of member variables bad and is there a design structure for data processing?

Context: Java, fairly new developer I have inherited code from a friend for a project that processes variables. The first thing i notice is the class has a ton of member variables. I have always been ...
1
vote
2answers
35 views

What does this statement about implementing forwarding methods of components mean?

I can't wrap my head around this statement here: One common drawback of using composition instead of inheritance is that methods being provided by individual components may have to be ...
0
votes
0answers
88 views

Eureka cluster for service registry with only one IP address

I want to use the Eureka cluster with service discovery. As it said in the documentation, Eureka's nodes can share their state with other nodes. If one Eureka node fails, others still have all ...
-2
votes
2answers
177 views

How to pass data between multiple project modules

I'm working on a Gradle project that has several modules. The project is implemented in Kotlin. One of these modules is the main entry point to the project, which is the main module. Another module ...
-4
votes
1answer
55 views

Springboot (Java) - Is mandatory for BDD the use of Cucumber?

I was wondering if its a requirement to consider BDD the use of Cucumber framework or other framework of test abstraction. Because I was playing around with @SpringbootTest and TestContainers(both ...
0
votes
0answers
26 views

Designing a public facing Java interface for future extensibility (API evolution)

I develop an in-house Java framework. I provide an interface so that my end users can provide their own custom implementation (i.e. plugin/SPI). public interface SomePlugin { SomeResponse ...
3
votes
0answers
72 views

Logging by 3rd party libraries

We've got 2 very large platforms for our services & jobs. Both platforms consists of 20+ servers hosting 1000+ services/jobs. Each job/service is essentially a java web application. Both ...
0
votes
1answer
70 views

Different fields for GET and POST methods in REST

I have a collection /users/{userId}/tools and I want to GET and POST to that collection. Can I have different representation of that object based on the method? For example, for POST I want to send ...
-4
votes
2answers
93 views

What is the benefit of Java collection streams over C# or Scala collections?

Java collection streams were introduced in Java 8, which came out in March of 2014. By that time, we already had well-established mechanisms for manipulating collections in several other languages, ...
0
votes
1answer
95 views

Is this a good design for my library?

I am writing a client facing library and wanted to check if the below approach sounds reasonable? This library is a service that consumes HTML and creates a greeting card. I feel writing Services and ...
1
vote
1answer
75 views

Backward compatibility testing

As a creator of a software library, how can I verify backward compatibility with earlier versions? When using a dependency management (here: Maven), multiple versions of my dependency could be (...
-1
votes
1answer
42 views

Ontology + Relational bases or only ontology to store data in a web app?

I am trying to conceive a wine cellar application for my father and for fun on my free time. I've decided to make a simple MVC with Pixi.js / JQuery and Bootstrap served by Express for the front and a ...
-3
votes
2answers
134 views

Generating unique numeric ids in multiple thread application without locking

Multi Threaded application with n threads implemented using ExecutorService. There are x (tens of millions) tasks submitted to the ExecutorService. Each task needs to generate millions (number of ...
1
vote
3answers
125 views

Best way to Model Classes associated with other Classes?

I'm trying to make a sports stats app in Java/Android + Realm. I have the following classes: Season Player Matches I would like the Season to contain a "list" of all the players that played that ...
-1
votes
1answer
62 views

How to implement different workflows for a single api call in microservice architecture

I am working on building a generic api that should ideally work with any data (Bring Your Own Data) but the overall functionality remains quite similar at the top level. For example lets say we are ...
-3
votes
1answer
48 views

How to know if the UML class diagram design is good (well-planned) or not in java

I've learned the UML recently and I am trying to build a MonsterDuel system. However, there are a lot of classes in this project, and I am confused about the abstract class and its usage. Now, I have ...
-2
votes
1answer
44 views

Design to method chain across packages

So bascially we have a library that contains a series of bifunctions passed in the metadata and datum looking like: Transform1: package transformation1; import com.fasterxml.jackson.databind....
0
votes
1answer
32 views

API Split for creating object with inheritance and behaviors

I have a web service which is exposed to UI owned by our team. This web service is responsible for creation of objects and saving it in the DB (NoSQL Database). The object being created has multiple ...
4
votes
4answers
188 views

De-coupling business logic from POJO de-serialization design pattern

I've a JSON file which I'm trying to de-serialize into POJOs. public abstract BaseClass { private String baseClassField; abstract String execute(); } ClassA extends BaseClass public ClassA ...
0
votes
1answer
60 views

Problems with software layers in complex query methods

I desingned a rest api software with 2 simple layers: Controller and Service. The controller handles the coming http request and redirect to a service method. In the beginning of development every was ...
1
vote
3answers
181 views

Approach for rewriting a large, mission-critical method

Context: I am a new hire out of university at a large software company tasked with either refactoring or re-writing a large legacy method (~500 lines, ~2000 lines expanded with private method calls) ...

1
2 3 4 5
92