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.

-2
votes
0answers
58 views

Java 11 - Free for commercial usage? Restrictions? [on hold]

I'm very confused... With Java SE 11 Oracle published a LTS version of the Java SE and refactored the build cycle. Just to ensure we talk about the same things, if I'm informed right, until know the ...
-1
votes
0answers
31 views

How to model a metric

I need a class to represent some metrics in my application regarding payments. The metrics consist of max. payment amount, average payment amount, payment count, total amount, last date etc. Here's ...
-1
votes
1answer
56 views

Is there a great difference between older versions of the JDK and newer versions? [on hold]

I'll state my problem simply. I'm learning Java. I already know quite a lot of Python, so it's not my first language, and it's not an incredibly difficult migration to make because they're both object-...
0
votes
0answers
121 views

How to simplify design and remove duplication in java layered architecture?

I've the following project structure (simplified): domain dto view In domain model is kept. dto classes are used to pass data from domain to view. And in view I've a controller and a handful of *req,...
0
votes
0answers
15 views

Preferred method signature for API method involving DB interactions

I recently got into discussion about how the method signature should look like for an API method which doesn't expose internal objects used by application to caller. Here is how situation looks: Our ...
0
votes
1answer
50 views

Java Design Pattern to Use for switching between 2 different endpoints

I have a legacy service that is running on-prem and have built a new service that runs on cloud which provides the same functionality. I have another java (spring) service which consumes the on-prem ...
2
votes
0answers
93 views

Division by zero Java [on hold]

The behavior of Java is explained in this topic. But, is Infinity useful for something? Float: public class DivisionByZeroFloat{ public static void main(String[] args) { System.out....
0
votes
0answers
12 views

Best way to design federated contribution and consumption of java modules

The problem I am trying to solve is, I am trying to write a platform where people can write and contribute certain tasks (java code following a contract to identify it as task) to the platform. And ...
2
votes
2answers
359 views

Is it bad practice when an Object has to be aware of another Object

I was reading this page and came across this sentence in the accepted answer: I don't like A directly knowing about B. But that's a DIP thing not a POJO thing. What if you can't abstract out B ...
0
votes
0answers
35 views

Is a bad practice to instantiate an Activity class just to use a getter from onPostExecute within an AsyncTask?

GOAL: I need to get a value within an async task. The value is declared within a previous called Activity. QUESTION: is a bad practice to instantiate the Activity from which I need the value just to ...
0
votes
1answer
43 views

Add the database layer to your application with a service or include it directly?

I am planning to set up a new Web-application that contains the following things: I want to use JavaEE with JSF for the Frontend & Backend combined with git-hooks to deploy them onto my server. ...
1
vote
2answers
81 views

Is passing an ErrorMessage to be populated inside the receiving method an anti-pattern?

I come from a Java background, and my colleague is from .NET. We are working on a Java project and I saw him create a method like this: public Object myMethod(Object[] param1, ErrorMessage ...
0
votes
0answers
19 views

Storing data from a database vs continuous database retrievals [duplicate]

I've been searching for an answer across the web to my question but have not been very successful. I am creating an appointment scheduling program that uses a database to store a number of tables ...
2
votes
1answer
66 views

Working with maven and multiple git repositories

We recently migrated from SVN, with most code in a single repo, to git, with most projects in their own repos (about 70 of them). We build about a dozen different apps from this java source. The apps ...
3
votes
1answer
204 views

Java - What is the “schism” between interfaces and classes that James Gosling talked about? [closed]

Recently, I've stumbled upon an old interview with Dennis Ritchie, Bjarne Stroustrup and James Gosling, published back in 2000. Each of them talked about the language they were most involved with, ...
2
votes
3answers
162 views

Wrapping Object VS Copying Fields

Almost every software has a number of internal data structures that we don't want to expose externally (through APIs for example). Let's say we have a few classes representing 1:1 database tables - ...
-2
votes
0answers
9 views

J2EE CDI intercept private field and overwrite them using reflection

I have plenty of fields throughout the code annotated with a custom @TriggerLogic for example. This annotation is used by a CDI Extension to execute some logic on top of the field. I can't modify ...
0
votes
0answers
61 views

Is wrong to declare database public static?

GOAL: get access to a reference to the database (which is declared in the MainActivity ) from within a Fragment in another activity. The organization of the code is like this MainActivity public ...
-1
votes
0answers
46 views

How would I design a PyQt GUI for my desktop that communicates with remote Java program?

I'll be writing a piece of Java software that runs continuously on an Ubuntu remote server. In the future I may rewrite it in another language such as C++, however the process would be doing more or ...
1
vote
1answer
116 views

Why is using an internal attribute to filter objects considered OK, but when I use a map to filter based on attributes, it's considered a code smell?

A long time ago I asked about using an enum to essentially use as a poor version of instanceof to make decisions about an object. As stated in this answer: When your weapon types enum just mirrors ...
0
votes
0answers
60 views

Advice wanted on exceptions handling. Annotated, Pojo or Hierarchy

While building some recommendations I wonder what is the favorite way to handle exceptions. The finality is to return a meaningful message to the user (being human or machine). I see 3 different ...
-1
votes
1answer
103 views

Have an object communicate with another object

I asked similar question earlier this morning, and for whatever reason, I'm not getting a complete answer to my question. I'll ask it a different way. I was attempting to understand Eric Lippert's ...
-3
votes
0answers
27 views

Are there any dependency that implement JWT in spring boot in a neat way?

I'm trying to built a REST API with spring boot and secure it with JTW token , but here is the thing implementing JWT is really tedious and it's like re-inventing the wheel, are there any easier way ...
-1
votes
0answers
24 views

Replacing framework component

We are working on replacing a library code to another framework, but there are certain components, such as highly framework dependent methods and which count as the salient features of the framework ...
2
votes
2answers
86 views

Using a Collection with Attributes to Check and Make Decisions

I was reading on this SESE page about using a variable to indicate the object type, more specifically, an enum. The accepted answer states: When your weapon types enum just mirrors the class ...
-1
votes
0answers
42 views

how i read a code split into multiple classes and files? [duplicate]

I'm studying some Code languages OO and always see people saying its easy to put your code in multiple files and multiple classes instead to put everything in one single ROOT class/file. ok, I ...
1
vote
2answers
52 views

When should we use wrapper classes for data structures / what is the ideal number of packages

I recently wrote a program in which I wrapped a map data structure to increase the readability of code like so : package wrappers; import model.primary.customer.Customer; import java.util.HashMap;...
4
votes
2answers
174 views

How should I sub class a class that constructs it's objects primarily using Static methods

I have a class, that takes a lot of esoteric parameters to construct an object. I didn't write the code and frankly speaking, I don't understand completely, all of it's nuances. There is a valueOf(...
4
votes
1answer
324 views

Why do we imlpement the Command design pattern like this?

I trying to learn the Command design pattern, I already know how it works and where it is used, but I'm a little bit confused about the implementation. So I know we need to set the context by ...
0
votes
1answer
73 views

Can a user read static member values?

For my Android application, I wanted to store values such as username, userid and stuff in a sharedpreferences object. However, when I read more about it, rooted users can still have access to those ...
2
votes
0answers
99 views

Is this an example of cyclic dependency?

I'm an undergraduate student and I have this assignment on a Discrete Event simulator. Currently I have completed to the end of v1.2 here. Attached also, is an algorithmic overview. I have wrote my ...
2
votes
0answers
136 views

How to handle a large number of optional parameters

I am currently developing on a small library allowing to read and write Java .properties files while retaining all the formatting (comments, whitespace, etc.): https://github.com/hupfdule/apron This ...
-2
votes
0answers
25 views

Should subscriber contain application logic?

Should subscriber/listener contain application logic? For example my subscriber is listening Post object for send mail. Manage for sending (setting the recipient, sender, subject and content and ...
0
votes
2answers
168 views

Streaming file content efficiently without risking resource leaks

I have to rectifiy an application that basically serves content by using two REST endpoints. Both endpoints transfer files to the browser, one endpoint does so by providing the file in binary format, ...
-2
votes
1answer
110 views

What's the point of making variables private or protected in Java? [duplicate]

Is there really any actual use for private variables and specific moments where they would be your only possible option? Or can you just set all of your variables as public without any actual changes ...
-4
votes
0answers
53 views

How to design an Android app?

GOAL: I've started to write my first Android app and I made a lot of mistake, for example: putting every method and variable inside the main activity; not using single responsibility principle; ...
2
votes
1answer
103 views

Java and PHP compiled vs Interpreted and runtime environment?

I have primarily worked on java. Now Learning PHP. After reading couple of articles on google, i got the understanding but got some doubts too. Compiled vs Interpreted Java Compiled language :- ...
1
vote
0answers
34 views

separate table for one of the type or java enum?

I want to make budget tracking web-app, tracking all savings and expenses with corresponding dates. Later generating reports, summaries etc.. I came up this design Frequency Table - does it have to ...
2
votes
2answers
100 views

How to model JSON data so it can be easily de-serialized in to simple Java classes?

Context Currently I'm struggling with correctly modeling a small instruction set I want to send as JSON to an Android application to generate a list of UI parts. Right now it's layered as pretty much ...
1
vote
0answers
66 views

Hierarchy of models while designing a client for a RESTful service

I am trying to write a client for a restful service. I am confused in designing the models. Below are the details: I have a Model named UnicastMessageRequest, it's definition is like this: ...
3
votes
1answer
261 views

Avoid smurf naming while wrapping a library

I'm programming against a API Library which provides classes like Document, Folder, ContentElement, Action... These classes are basically just their respective representation from the database. I'd ...
3
votes
2answers
190 views

How is bad declare public static variable and use it in other classes?

GOAL: to have a main class which has some global variables which need to be modified by other classes. I have a class with a structure like below public class ClassName { public static ...
4
votes
3answers
365 views

Proper way to name a class which has just methods and not fields

GOAL: naming a class which has the responsibility to save data in Android database. The class structure is like this ClassName { public void saveSync(...){ /* implementation*/ } public ...
1
vote
1answer
37 views

Doing operations securily from an Android application into a Server

I have come up with a problem in my development and I have searched for correct solutions but have not found any. I am developing an application which lets users login with username and password. ...
0
votes
1answer
144 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 ...
0
votes
2answers
95 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
163 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 ...
0
votes
0answers
38 views

Questions about modeling a queue with DDD principles

Let's take the following exercise: A system can have hundredth of queues Each queue can have hundredth of entries There can be thousands of elements in the system Each element can be enqueued and ...
1
vote
2answers
55 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
27 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'...