Stack Exchange Network

Stack Exchange network consists of 174 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
0answers
33 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
222 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
102 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 ...
0
votes
0answers
52 views

Java RPC - Notify client without client-side method call

The current project is a basic java web application written with the RPC pattern and java ObjectStream... Here a some base classes used by my basic framework: public abstract class AbstractServer ...
-3
votes
1answer
124 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
255 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
115 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 ...
2
votes
3answers
426 views

Try/catch or add exception to method signature for method used by a larger system?

public Path createPath(String name){ return Files.createFile( Paths.get( name ) ); } In createPath(String name), the java.nio.file.Files throws a java.io.IOException. This is however to be used ...
1
vote
0answers
108 views

MVC - How should components inside controller communicate?

I'm developing a level editor in Java. I'm designing its code in MVC. From what I've learned: controllers can have a direct reference (fields) to views and models. Views can have direct reference to ...
0
votes
2answers
130 views

How to build reports for an ecommerce webapp without slowing it down

We have a medium sized ecommerce website which is entirely custom built in using Java and MySQL database on AWS infrastructure. Over a period of past several years, our orders volume has grown ...
3
votes
5answers
218 views

Use POJO or Map when there is a finite number of known keys?

I have some set of data with key-value pairs, but there is only a finite and known set of keys, all of the key should always be present on that data, and they all have the same type for the value. ...
0
votes
2answers
196 views

If I modify a private field using another setter, is it a bad practice?

I have a java class where I have few booleans and one arraylist. If the boolean field is set to true, I need to add it to the arraylist. One of the ways I can do this is to use the setters of each ...
3
votes
2answers
402 views

Number of thread: Computation intensive vs IO intensive operations?

I came across below statement at this blog Computation intensive operations should use a number of threads lower than or equal to the number of cores, while IO intensive operations like copying ...
2
votes
2answers
287 views

Is importing wildcards a bad idea?

If I do this import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; Then why don't I do this, it's more convenient ...
0
votes
1answer
163 views

Post Increment of a variable in brackets [closed]

In my computer science exam there was a question as follows: i=10, j=51 & k=7. p = i+(--k +j) + (3*(i++))+i. I am getting the answer as 111. Here's my methodology : k is decreased by one in (--...
0
votes
0answers
56 views

Migrating from portlet to a different technology

I'm trying to migrate a JBoss Portal Platform 6 application to a monolithic/ deportalized application,with the challenge of doing this change without changing the service/business layer; One of the ...
1
vote
1answer
133 views

Where to store static contents

Recently I am developing a new feature for my web application that must be Release Independent. The feature requires to show some predefined data. Those data will rarely be changed or updated. Here ...
2
votes
0answers
59 views

Chronicle Queue: how to make a stack and how to limit disk usage

My server and several clients are different JVMs running on the same machine, they need to share persisted time series data: server reads a time series from somewhere, writes to a persisted embedded ...
1
vote
0answers
43 views

Seeking Tips on PAAS Architecture

I've developed a java web app using Vaadin, and using Jelastic/MassiveGrid as the PAAS. However, I need advice on proper architecture for my needs. Desired Outcome: Users land on my homepage where ...
0
votes
0answers
51 views

Pulling analytics metrics from java application without code modifications

We use spring 4.3 and spring boot version 1.5 in our java based web application. For (product) analytics purposes we want to read the metadata of our product which is persisted in an RDBMS store (...
8
votes
6answers
991 views

Should reused exceptions types be favored over single use ones?

Let's say I have Doors that are managed by a DoorService. The DoorService is in charge of opening, closing and locking the doors that are stored on the database. public interface DoorService { ...
0
votes
2answers
1k views

if and else or if an return?

I have a Java method with a void type of return that checks a condition. It do something in case of true and other thing in case of false, typical if / else structure, but is possible use only the if ...
0
votes
4answers
465 views

Rest API Design in case of partial success

So I have a ticket booking system. I have ticket booking request on api, from my application we call payment service. If failed on first attempt we proceed by adding message on queue for handling ...
2
votes
1answer
43 views

Gradle/Java separation public private API

I have a project that has a public API and an internal code. The public part is published on MavenCentral. I thought about making a package each, but everything from the 'internal' package that ...
-1
votes
1answer
34 views

Tools for generating a form from a schema, and applying process flow logic

We have a situation where the business has a range of datasets which end users contribute to. The business needs flexibility in adjusting or rather extending these datasets, and also publishing new ...
1
vote
0answers
253 views

How to make rest api end points in swagger UI pre authenticated in Spring BOOT

I have written a spring boot rest API application with OAuth.I have integrated swagger UI for API documentation. I want the API endpoints on swagger UI to be accessible without an access token. Please ...
2
votes
2answers
215 views

Is it an antipattern to introduce complexity into a builder?

I've looked at various definitions of the builder pattern and whilst there's varying definitions, they tend to be focused on the broad definition of incremental construction. However, it seems that ...
0
votes
1answer
397 views

In new project where you have ability to define DB and write app code, what is seen as best practice?

Good day When starting a new project and you have access to the db as well as writing the code. In this specific case it is PostgreSQL and Java EE with JPA and Hibernate. Should one: Aim to ...
1
vote
2answers
152 views

Returning JPA Entities in Rest Api's?

Recently Ive seen so many devs working with the stack Spring/JPA and returning all these JPA entities on their rest controllers. In my opinion it's a BAD PRACTICE for several reason such: ...
0
votes
0answers
28 views

How to architect priority ordered processing between two apps with multiple threads producing/consuming requests?

Apologies if the title of the question is bit misleading. I have two apps X and Y both implemented in java. App X runs in apache servicemix container and Y is web-app running in jee app server (often ...
0
votes
0answers
17 views

Persisting as XML using the model class or create a standalone class

Over the past two years I've written an image sorting and processing program for our lab, using JavaFX. The class Project contains all the information: collections of Images, Tags, Labels etc, as ...
1
vote
0answers
106 views

Why is java's Object toString method defined as it is?

In the Java API specification for the Object class for the toString method, there is the line "It is recommended that all subclasses override this method." While I don't have a better idea for what ...
-1
votes
1answer
130 views

How can I prevent my API from being accessed by anything but my website?

I've got an API (Java + Play Framework). I've got a website (React) who has to communicate with the API. I don't want my API being called by anything but my website. How can I do?
1
vote
0answers
27 views

Does this archicteture work for a Mobile App and Destkop App

This is a proposal of a Distribuited Cloud Architecture for DAWUF which is a Digital Audio Workstation under design and developmente in JAVA, XAMARIN, with REST services The white boxes are the ...
2
votes
1answer
109 views

Is an Adapter pattern a Proxy pattern? If not, why not?

A common use of the adapter pattern is to support functionality that isn't actually supported in an underlying class. For example, if I use an API to interact with a Samsung Smart TV, I might want to ...
5
votes
1answer
161 views

Achieving scalability and ACID with a RDBMS to NoSQL streaming solution

My understanding is that the main feature Cassandra has to offer is linear performance at any scale; meaning that if I know 1 C* node can handle 500 queries or commands per second from my app, then I ...
1
vote
0answers
582 views

Navigating through nested maps in Java

I am looking for an elegant way to get and put values in nested, untyped maps in Java. For instance assuming I have a map structure as follows: Map m = { "a": { "aa" : { ...
0
votes
1answer
184 views

Java takes 2 bytes to represent character?

In general a character is represented in 1 byte i.e. 8 bits . This is I believe true for all text editors even for databases like oracle. 1 byte can represent 2^8 = 256 Characters. My question is when ...
1
vote
0answers
113 views

Subclassing numeric types for safety

I'm writing something that handles length units, say, metres and feet. I don't want to accidentally convert between them (trying to avoid something like the Mars Climate Orbiter crash). I'd like to ...
0
votes
0answers
66 views

How to handle incomplete URL's in Rest Web Service

I have written new Rest Web Service, in which I have employeeInquiry method is present. During testing of web service(/employee/{employeeId}/details) using SOAP UI tool, QE is passing employeeId as ...
1
vote
2answers
291 views

Is it okay to put all your error handling on facade layer?

I am doing a Java Spring-Boot backend project and I am implementing a controller-facade-service pattern on my structure. So is it best to put all my error handling on the facade layer, while the ...
0
votes
0answers
22 views

Error details helpful for issue analysis?

I have webapplication. My requirement is I need to store exception details in DB in case any 500 error occurs. I am planning to store below details at backend automatically for any request under ...
2
votes
2answers
278 views

Is Java's @Override annotation still good practice in these modern times?

When the @Override annotation was introduced in Java 1.5, which feels like back in the days when the dinosaurs roamed the Earth, it was a good idea at the time because, amongst other advantages, it ...
-3
votes
1answer
785 views

UML Class Diagram HashMap Data Type

How can I show a Java HashMap data type in UML Class Diagram (or C# dictionary)? I.E. This class: public class Test { private Map<String, String> map; private Map<String, int> ...
2
votes
1answer
1k views

Implementing a REST API in a Clean Architecture

I have been implementing a proof of concept application using Uncle Bob's Clean Architecture and I have run into a bit of a problem. Uncle Bob's architecture calls for the explicit separation of ...
3
votes
5answers
315 views

Using a variable to indicate object type

The use of instanceof or getClass() is largely considered code smell. Is using a variable to indicate the type of object you're using also considered code smell? Suppose if I had an enum called ...
-1
votes
1answer
345 views

Adjacency List list of linked list or can be repesented in other ways?

I am new to graph data structure. Everywhere on google it is said to be list(or array ) of linked list. My question is can not it be represented as list of list(in java array list of array list) or ...
0
votes
0answers
43 views

GraphQL - should i enrich it with hypermedia

I know that GraphQL and REST are different approaches. But what if I need to provide hypermedia links and state transitions to my API design besides agile queries? Should I expose 2 different layers, ...
0
votes
2answers
270 views

WebSockets vs Ajax call for scheduled event?

Intro I have been weighing the pros and cons of using WebSockets vs. an Ajax call for an event which will happen every x number of seconds (in this case 5). I'll start by explaining the scenario. ...
3
votes
1answer
3k views

what is the use of DTO instead of Entity

I am working on RCP application, I am new to this application. Spring beans are used to write business logic to save/fetch entities. But, instead of sending entities directly to client we are ...