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.

2
votes
3answers
706 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
156 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
133 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
310 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
198 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
591 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
409 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
215 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 (--...
1
vote
1answer
137 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
80 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
46 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
996 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
3k 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
639 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
53 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
284 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
257 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
398 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
231 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
18 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
112 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
140 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
179 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
744 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
203 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
115 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
68 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
348 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
23 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
306 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
1k 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
330 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
416 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 ...
-1
votes
0answers
44 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
318 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. ...
6
votes
1answer
5k views

What is the use of DTO instead of Entity?

I am working on RCP application, I'm 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 ...
1
vote
1answer
182 views

Metrics that measure the readability of the function

Functions are the first line of organization in any program.I believe writing them well improves the readability of code to some extent.I am working on metrics that describe how readable the function ...
-2
votes
1answer
360 views

How to clean a refactor Java for-if-try-catch-else kind of messy code [duplicate]

Often I came across situations like this, how to write this code in a neat and clean way. One more issue I find here is performance as I am iteration a list and then it's properties. Edit : - while ...
0
votes
1answer
121 views

Correct way to receive bulk data from a server in Android?

Ok so to explain I have server in Java that receives data from a C++ program that I have no control over. So the data is transferred over TCP/IP and the Java server just receives it. The volume of ...
0
votes
0answers
48 views

Building a Generic SOAP Layer for an external Service

Status quo: For an existing software product (java) we have built another software (in java) that provides a SOAP service for many of those available calls so we can build our own product in our ...
30
votes
9answers
5k views

Designing a Class to take whole classes as parameters rather than individual properties

Let's say, for example, you have an application with a widely shared class called User. This class exposes all information about the user, their Id, name, levels of access to each module, timezone etc....
0
votes
2answers
134 views

Using the same name for setter and gettter methods for a boolean member variable

Say I have class with a boolean member variable fancy: public class MyClass { private boolean fancy; } Case 1. I could the define the setter and getter as follows: // getter public boolean ...
0
votes
0answers
239 views

Multi-threaded socket chat server design

I've a general question about the design of a multi-threaded chat server application written in Java. At the moment I've the following structure: ConnectionController class which handles the I/O ...
2
votes
2answers
154 views

Input based data fetch optimization

Is there a cleaner/ better readable way to maintain and iterate many-many mapping rather than multiple if conditions ? (One way would be to store the mapping of ReportType -> DataSet Req. in the ...
5
votes
0answers
133 views

Reason for sudden rise in popularity of compile-time annotation processing in Java [closed]

So compile-time annotation processing is as old as the annotations themselves in Java. Yet most of the useful libraries were developed with the runtime approach in mind – at least at first. Now, ...