Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
261 views

`set-then-get` vs `get-then-set` in context of race condition?

I have recently came across approaches to set-then-get and get-then-set in context of race condition in multithreading. My understanding :- set-then-get is the same approached in java concurrent ...
1
vote
2answers
214 views

New version of REST API - deploy two services?

Assume you need to define a completely new REST API for a given service. These rest APIs are distinguished by something like "v1" and "v2" in the path. If you develop these services in Java, would ...
2
votes
3answers
288 views

Java String substring() and StringBuilder delete() methods

I've noticed that some methods like the String's substring(int beginIndex, int endIndex) and StringBuilder's delete(int beginIndex, int endIndex), use the second parameter to signify that the ...
1
vote
2answers
62 views

How can I live-update my internationalization Resource Bundles?

I'd like to add translations without waiting for a full new release. In other words, I'd prefer that the Resource Bundles not be part of my Git repository; and that they be easily editable and ...
1
vote
0answers
29 views

Identify specific methods and their parameters in source code

I have two source code files (one in java and the other in python). Certain methods in the java file have references to the python file using the PythonInterpreter, e.g. execfile("hello.py"); or it'...
3
votes
2answers
320 views

Are there any problems with using class variables in Java that can be accessed by any method?

So I've been coding in Java for a decent amount of time, but recently, I've started a class that cares about my coding design. In the past, if I had two methods inside a class that needed to edit the ...
1
vote
1answer
53 views

Writing Event Process architecture for multiple event handler interfaces

I am working on Java program which will listen multiple kind of events from multiple sources and store information to multiple sinks. Each interface will have its own source to listen and own sink ...
1
vote
0answers
47 views

Java dashboard for machine data

I am currently working on a project for a production facility. The machines in the production are saving so called 'Telemetry Data', measurements like water pressure, plastic volume or temperature ...
1
vote
2answers
832 views

How to process huge amount of data with limited processing ressources? [closed]

I receive daily from an external source a very large amount of data (around 250GB with 260 million rows of fixed width text) distributed over 5 text files. I am writing a Java application that should ...
0
votes
1answer
90 views

Evaluation of (a)synchronous design of ledger interface

I'm currently designing a ledger API, that should work with different implementations (e.g. based on Blockchain, traditional databases, or files). Its purpose is to add/get messages to/from a ...
0
votes
1answer
115 views

Java's equivalent of C++'s double colon when writing a text about a code [closed]

What is the Java way to say in a text that a function belongs to a specific class? For example, when writing a C++ commit message, I say TimeInterval::toString() now uses a UTC timezone I.e., I ...
-1
votes
2answers
162 views

What design pattern(s) would provide a better solution to this problem?

I have a document object and a list of operations that can be applied to that document in sequence. The types of operations are known in advance, but not their parameters, the order of operations or ...
2
votes
1answer
85 views

How to test customer journey with mostly the same structure

I often hear that a test should contain only one assertion (Disregarding testing attributes of a class) and where the whole pre-conditions for the test should be setup before the assertion. In our ...
2
votes
1answer
84 views

Configurable sorting strategies

I need to be able to sort an object by multiple conditions, and these sorts need to be configurable from the application.properties file (as in it should be possible to specify in the file the sorts ...
6
votes
3answers
934 views

Algorithm to sort ten million 7-digit integers in ascending order with just 1.5Mb RAM?

Given a file containing at most ten million 7-digit integers with no duplicates. What is an efficient way to print these numbers in ascending order using just 1.5MB RAM and reading the data just ...
1
vote
3answers
166 views

Is it allowed to throw a runtime exception from a java.util.Predicate

The java.util.Predicate interface contains the test(...) method, whose JavaDoc description states that it [evaluates] this predicate on the given argument and that it [returns] true if the input ...
-1
votes
1answer
93 views

Removing a framework support from a big project

I need to remove a framework(vertx, to be specific) from a project(lib) which is the base for other projects as well. What would be the best approach to remove all dependencies on the framework from ...
1
vote
1answer
161 views

Is using the copy constructor in an object constructor bad? [duplicate]

I was reading this page about using the new keyword in the constructor, and I was wondering if it applies to copy constructors for collections. Suppose I have a Book class and a collection to store a ...
0
votes
1answer
144 views

Java application calling executable files

For some context: I am currently developing a Java application that needs to execute an executable in the command line. But that's not what this question is about. Now, usually you would pack all ...
2
votes
3answers
252 views

Can Java applications run on phones (at least android) AND Windows?

Hi all I love stackoverflow so helpful. Afaik IOS has some security measures that dont let other apps (such as jvm) execute code from your app. Not sure how much this is true. But anyway, I heard ...
1
vote
1answer
132 views

When is creating a supplier for an object less expensive than creating the object itself?

Objects contains 2 method overloads where one takes an object and the other takes a Supplier of that object: public static <T> T requireNonNull​(T obj, String message) public static <T> T ...
2
votes
1answer
84 views

What do you put in a “common” package? [duplicate]

I am trying to develop my package structure based on features rather than layers, but am struggling to find a package name for some of the classes. I have seen people use a package name of common for ...
-3
votes
3answers
677 views

Shouldn't cost be good reason to migrate to .Net from Java

I have a RESTful services developed using Java Spring framework. It's not a huge application, around 12K lines of Java code. Front end is in Angular and DB is No-SQL world. Recently I came to know ...
2
votes
1answer
97 views

How to reduce the chances of getting merge conflicts occurring in two projects of same cloned codebase

I have two applications A and B. Application A was written before application B, actually B was initially the same fork of A thus, each of the application had the same modules and same code in it. ...
5
votes
3answers
123 views

How to untangle a data class where annotations from different frameworks mix?

The framework mix problem I'm using two frameworks -- PingIdentity's SCIM 2 SDK and Spring LDAP -- to deserialise a SCIM resource (i.e. JSON) to a Java object then write it to an LDAP directory, and ...
2
votes
3answers
101 views

How to build rest calls dynamically to interface with different APIs?

Lets say I am building an application where clients can book bus tickets. The only thing they do is select, origin, destination and the type of service (express or standard). The system will then book ...
3
votes
1answer
110 views

Future/Promise objects in Controllers - Best practice - MVC

I was going through some articles related to Futures and Callables today and was thinking about the best practices when working in an MVC based environment. I was wondering, should one be creating ...
3
votes
2answers
172 views

Name of this pattern

I create an object that holds the status of a job. The job has many stages, some concurrent. Worker threads constantly monitor the status object to see if it's ready for the next stage to begin, if it ...
2
votes
0answers
46 views

Where to specify drag-and-drop related meta data?

The structure of our project strongly separates the three different parts: core - data classes, POJOs, sometimes aggregated with annotations (e.g. for XML/JSON serialization) plugin - plugin for a ...
2
votes
0answers
629 views

How to deal with large data in Websocket message?

I wrote a websocket server in Spring Boot and a client in Javascript. These work fine. I also wrote a second client in Java. When this one attempts to handle a frame after connecting to the host, I ...
2
votes
1answer
56 views

System design for multiple workers

I need to design a system where there are many micro-services which we can think of as crawlers that poll 3rd party resource and if they find some new information they pass it to some other service ...
0
votes
2answers
172 views

Is this Singleton-like design pattern a feasible framework to build on?

I am posting this question here after it having been determined to be "off-topic" for stackoverflow, and "too hypothetical" for codereview. I am experimenting with different singleton-style design ...
2
votes
1answer
67 views

Refactoring of a client calling a Rest Service

I have a class that is responsible for calling a service and returning a response. The contract is like this interface ServiceClient { ServiceResponse process(ServiceSubmissionParams params); } ...
4
votes
6answers
298 views

What pattern can be used instead of these if statements in starbuzz (head first design patterns-Decorator pattern)

Reading Head First Design Patterns. I came to the chapter 3, the Decorator Pattern, Decorator Pattern is very clear for me. but one of the "sharpen your pencil" Our friends at Starbuzz have ...
2
votes
1answer
131 views

Microservices loose coupling using distributed business logic or centralized?

How do we achieve loose coupling in the below scenario: N microservices (let's call them Callers) needs a logic or business( let's call it Worker) to be executed with different contracts. Although ...
1
vote
0answers
27 views

What are some design ideas for a data mapping and transformation application?

Here is a high level outline of the project: We frequently need to convert data from a new incoming system to our in house system (sort of a basic ETL process) We would prefer to do this dynamically, ...
1
vote
1answer
123 views

Private/Hiding dependencies between Maven modules

Given three project modules X, Y and Z on a Maven based project, and Y depends of Z and X of Y and X should not know that Y depends of Z, being this: X -> Y Y -> Z X -X> Z What is the best way to ...
1
vote
1answer
85 views

Should this part of my web-app implemented on server-side or client-side?

I want to write an application which monitors a few URLs (like a couple hundred) of all branches of school. By monitoring, we mean that it sends requests to those URLs at regular intervals (Interval ...
1
vote
0answers
52 views

Should I implement a JAX-RS ExceptionMapper for java.lang.Error?

I have a Jersey server that handles REST requests where I've implemented a RuntimeExceptionsMapper implements ExceptionMapper<RuntimeException>. If there's an unexpected exception, it handles it ...
1
vote
2answers
175 views

Calling a method with different parameters and iterate

I have a method that inserts into the Android Calendar an event. You can see a simplified snippet in two steps: 1)declare the variables 2) I put them into a kind of array that in the end will insert ...
2
votes
4answers
538 views

What do OOP languages gain from having constructors that always return an object?

In what seems like a deliberate design decision, C++ does not have a null value for objects and references. This makes using objects and references very elegant since we don't have to perform null ...
0
votes
1answer
104 views

Cache vs DB design decision?

Number of times this question comes to my and my team mind, should we persist or cache the data. I understand some time there is functional requirement that we need to persist in DB. But in my case ...
1
vote
2answers
409 views

Sequential or parallel access to hard disk in multithread program?

In multi threaded java program, I initiate four concurrent threads with below details 1. Thread 1 writing file F1 2. Thread 2 writing file F2 3. Thread 3 reading file F3 4. Thread 4 reading ...
4
votes
3answers
1k views

Resolving circular dependency between two classes

I am trying to resolve a circular dependency between two components in my system. The Messenger component is responsible for sending and receiving messages on a web socket. The Controller component ...
0
votes
0answers
39 views

Edit List attribute in JPA when null?

I am using EclipseLink as my JPA implementation and Postgresql as my DB. JPA: @Struct(name="label,.....") @Entity @Table(name="\"XYZ\"", schema="\"XYZ\"") @NamedQuery(name="...
4
votes
2answers
225 views

Is it violation of single responsibilty to add a method to an existing API

Say i have a Rest API that has a POST and GET method. If i want to overwrite a resource in the API i can call the GET method to get the original item and then call the POST method to replace that ...
0
votes
1answer
116 views

Best approach for web service that calls other web services

The scenario is: client makes request to server A Server A makes potentially multiple requests to server B. Edit to clarify, server A makes the requests concurrently using Futures. Server A blocks ...
-3
votes
1answer
133 views

Is it fluent interface or what is it?

So, I am a beginner level Java guy and I was following the java 2D game development tutorial on YouTube by CodeNMore. in the States video (https://www.youtube.com/watch?v=871zoXsYrbI&index=11&...
3
votes
1answer
272 views

Java web development

I started to develop web applications not so long ago, and therefore there are a lot of unknown things in this field for me. My question concerns web development using the Java language. Assume that ...
0
votes
1answer
118 views

Simple but frequently throwing vs reasonable but rarely throwing vs complex but never throwing [duplicate]

A lot of code that's designed to convert or parse some data of type Foo into a Bar is written with the assumption that one wouldn't intentionally pass it invalid inputs. As such, it assumes that ...