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
0answers
18 views

Java spring DefaultMessageListenerContainer and dynamic queues

We have a number of message queues (ActiveMQ) feeding our system and for each one we have a Spring DefaultMessageListenerContainer receiving the messages from the queue (set up in code, not XML). We ...
0
votes
1answer
101 views

A desktop app which incorporates a REST API?

I am planning to build an adapter between a PC and devices which have the same function but which have different interfaces. The adapter will probably be based on a Raspberry Pi and will have a touch ...
-2
votes
0answers
28 views

How to break up a request into multiple requests

I have a question about following scenario I am trying to implement in Java JAX-RS REST: a client app sends request to my api, lets call it MY-API MY-API receives request, and sends it to vendor api (...
5
votes
6answers
709 views

Are Car objects and Dog objects used in real life programs?

While learning about OOP, I have noticed that a lot of the tutorials give examples of objects such as Car objects and Dog objects, but I don't know if these kind of objects are used in real life ...
-2
votes
0answers
27 views

Android Call Forwarding: How does Windows “Your Phone” app work with Android?

For a long time now, I have been unable to wrap my head around how Microsoft has been able to achieve forwarded android calls without special privileges. I know the more modern integrated Samsung ...
-1
votes
1answer
32 views

Opinions on using standardized J2EE APIs over specific over vendor APIs

I have always advocated the use of standardized api, and currently use it on my code. However i always get very strong resistance when it comes to code review, even on projects i have designed and ...
2
votes
0answers
69 views

Why does the Java CompletableFuture API uses long + TimeUnit instead of Duration?

Java 9 introduced many new methods in the CompletableFuture API that support execution timeouts. For example: public CompletableFuture<T> orTimeout​(long timeout, TimeUnit unit); public ...
3
votes
1answer
95 views

What are the advantages of checking for objects with Objects.nonNull()?

Our project changed the object existence checks from foo == null or foo != null to Objects.isNull(foo) or Objects.nonNull(foo). I never got an explanation why that should be better, that's why I ask. ...
-2
votes
0answers
25 views

Alternatives to the Maven Release Plugin: How does the “Dead and Buried” method check for snapshot dependencies?

I have been looking for alternatives to the Maven Release Plugin and as far as I can tell, this is a method liked by many people and often regarded as best practice: https://axelfontaine.com/blog/dead-...
3
votes
2answers
119 views

Composing and Inheriting from the Same Type

To start off with an example: I have a read-only Repository used for getting arbitrary values. This behavior can be implemented multiple ways. I also want to allow opt-in mutation of the repository's ...
-1
votes
3answers
85 views

Should methods with business logic be made private? [duplicate]

So I am writing a project using Spring Boot. All of my logic resides in @Service classes. I have separated each service class based on entity. For example - If I have two independent entities A and B, ...
0
votes
0answers
32 views

Multitenancy - Multischema DB and should we handle by individual microservice basis?

I am looking into the revamping my organization's application by moving from a monolithic into a microservice-architecture. My database is a multi-schema shared in one database. Each of these schemas ...
-1
votes
3answers
66 views

Logically grouped interfaces have circular dependencies in call graph, tight coupling. Leave as is, break up CRUD interfaces, something else?

The problem I have relates to an existing system in a specific business domain. I've simplified it into a very similar 'Library/Book' relationship to articulate the problem. Answers such as 'why would ...
2
votes
1answer
103 views

Is it a good idea to use a Lazy wrapper type to encapsulate lazy initialization in Java?

In our code base, we have several static or instance members that we would like to initialize lazily. If the initialization cannot yield null, It's easy to implement. Otherwise, one could use an ...
-1
votes
0answers
31 views

How to work with multiple packages at once during development?

I want to work with multiple packages for a project at once. I don't want to maintain any relationship between them except "A depends on B" and this relationship is mentioned only on the ...
81
votes
12answers
22k views

What is the utility and advantage of getters & setters especially when they are merely used to read and assign values to properties of an object? [closed]

I’m still really new to learning to program. Just learning the syntax for a few programming languages at the moment. The courses I viewed for C# and Java touched only very briefly on getters & ...
1
vote
0answers
76 views

Should I mock ObjectMapper in my unit tests?

I have different services in a spring application that have a dependency on Jackson ObjectMapper, the unit tests rely on @InjectMocks to inject all the various dependencies to the class that is under ...
1
vote
4answers
207 views

Pattern / solution for Boolean decision making chains

I need a solution for decision making chain. There are number of criteria that may return true, false or be inconclusive. A non-functional code (Java) would look like this: Boolean res = ...
-3
votes
0answers
92 views

How to iterate a huge data set?

I am trying to design a recommendation system. I have a list/set of unique UIDs and each UID corresponds to some user. Each user is stored in some relational Db, like PostgreSQL. I also have N worker ...
-3
votes
1answer
90 views

How Uber processes orders?

Lets say you created an order. Since Uber is a very dynamic system, one should constantly check if there are available drivers for you. If orders are saved as a some collection (e.g. in MySQL table ...
20
votes
8answers
5k views

Immutable String and Integer in Java: What is the point if assignment in effect changes the value?

If immutability is "good" and yet you can in effect change the value in an Integer or String variable (never mind that you get a new reference -- the value has changed) what good is it that ...
17
votes
10answers
5k views

Are immutable objects important only in multi-threaded applications and if so, how are shared immutable objects useful?

I think the answer to the first part of my question is, "yes" -- no point in making objects immutable in a single-threaded application (or I guess in a multi-threaded application if that ...
1
vote
1answer
62 views

Correct format to receive datatime data from consumer

I am working on a service in a sprint boot microservice application. The consumer for my service can be another service, as well as a UI component. The are 5 entities in my service, each entity having ...
-4
votes
3answers
135 views

Methods that receive buffer objects AND return another Object - is that bad design?

The Argument Some say that if you write a method that receives a buffer, iT MUST RETURN VOID -> the buffer is your exit point. Do not abuse the methods by receiving buffers AND returning a another ...
2
votes
2answers
157 views

Migrating legacy code with singletons to Dependency injection

I'm working on a larger, older project. Our code is littered with classical singletons, i.e. classes like public class ABCService { private static final instance = new ABCService(); public ...
0
votes
1answer
102 views

Application Horizontal and Vertical Scaling

I'm hoping the experienced Java developers here can share some insight about this problem we have been trying to solve for so many months. We're currently building a Java web application that uses ...
1
vote
1answer
38 views

Java, dealing with XML and JPA Annotated Classes

I use xjc to compile XSD files to Java Classes, and want to edit/extend them to make them persistable through JPA. I cant figure out what the best "Coupling?" would be and how to organize it,...
2
votes
1answer
83 views

Effective thread usage under blocking scenario

I have the following scenario: I am listening file requests and when one arrives, I am starting download task in a new thread. After download task ends, a process task starts but this is important, ...
0
votes
0answers
39 views

Licensing a spring boot application inside an AMI

Say we have a standalone spring boot application which we are going to distribute by creating an AMI and sharing on the AWS marketplace. Since the jar is available inside the AMI, I want to stop a ...
1
vote
1answer
63 views

Are the following project distributions valid SOAs?

Currently we are developing an application for service oriented development which is a college signature, the professor created two applications one for backend and other for front. We are using maven,...
-1
votes
2answers
64 views

Should we create review branch in github to story or subtask of jira?

I have an 8 pointer Story. Let’s call it for example XX1234 I have created 4 subtasks based on the list of actions to follow to complete the whole story implementation: 1. XX1235 2. XX1236 3. ...
-1
votes
5answers
142 views

How to manage exceptions in a long call stack

When throw a exception inside java method, IntelliJ suggest to add exception to method signature. When I have a long call-stack as below how I manage these exceptions. method 1() -> method 2() ->...
-3
votes
1answer
52 views

Is it good practice to call service layer through domain object getters?

Tell me anybody, is it good practice to call service layer methods through domain object getters? Let me show you with an example: public class User { private long id; private String name; ...
0
votes
2answers
194 views

Why are some languages called platform dependent if I can always share the source code?

I was reading about erlang when I read that it is platform-independent, using BEAM as the VM, now I understand that a VM compiles the byte code to machine code and this makes that language machine-...
-3
votes
1answer
95 views

How to implement time triggered batch processing in a K8s/Java Spring Boot environment?

Environment: Kubernetes Cluster with Spring Boot microservices. One microservice contains a database with a date in one column of a read-only table. Problem/Requirement: When the date is reached, an ...
1
vote
3answers
115 views

Design with subclasses being aggregates of classes implementing interfaces

I have modelled a class structure, where subclasses Rectangle and Circle inherit from an abstract superclass Figure. All subclasses share an interface IGeometry that provides for getArea() and ...
0
votes
0answers
67 views

Simple Message Handler in Java with generics

I can easily put together a message handling set of generic apis in C# with the following quick and dirty code: void Main() { var messageClient = new MessageClient(new TestMessageHandler(), new ...
4
votes
3answers
258 views

How to visualize a Stream object (and some other data types)?

I want to make a small programming tutorial which will have a number of images visualizing various data types, but I am not sure how to draw these images of the data types. Assume that I have a ...
0
votes
0answers
27 views

Is JTA appropriate for concurrent loads to a single database and transaction?

I have a Java process that loads data from a file in to an RDBMS - basically a CSV import with some logic around updating and deleting records in addition to the inserts. It's important that it ...
0
votes
4answers
338 views

Why have separate keywords for 'extends' and 'implements' in Java? [closed]

Short answer that I've come to accept: Firstly, it helps with readability, being able to see which is the superclass apart from interfaces. Secondly, though 'extends' and 'implements' do the same ...
1
vote
1answer
81 views

REST : Static API design

Lets say, I have a scenario where I have to expose an api to fetch supported shirt sizes(small , medium and large) My initial thought was /v1/shirts/sizes - But this clashes with the existing fetch ...
8
votes
4answers
3k views

OOP Design considering no modifications to existing design

The question is: interface Animal { void eat(); } class Lion implements Animal{ public void eat(){ //do somethng } } class Test { public static void main(String[] args) { ...
0
votes
2answers
115 views

Should it be considered a BC break to return clone instead of new self?

(This question applies to the equivalent code in both Java and PHP) I have a class like this: class Foo { private int $bar; public function __construct(int $bar) { $this->bar = $...
3
votes
1answer
150 views

Integrating TeX into a Java desktop application

Looking to integrate TeX equations in a TeX-agnostic fashion, suitable for either ConTeXt or LaTeX, into a Java-based desktop Markdown editor. The possibilities are numerous, but I'm not sure what ...
0
votes
2answers
38 views

Should my DenyQueryException extend a exception in a DAOException or Exception

need some advice...I am fully aware that Validation/Syntax Checking, etc. should happen above the Data Access Layer. However the powers that be would like the DAOs to do an extra check. Should when ...
1
vote
0answers
55 views

Correct usage of ETags?

Currently my code makes a series of updates to some resource via a REST API but I also have some "rollback" logic that basically updates the resource to its original state before my updates ...
1
vote
1answer
82 views

Pipeline design pattern and immutability

I'm developing a backend service that is supposed to process items in a pipeline-fashion. Each stage is essentially a Function<IN, OUT>. So the current stage's input is the previous stage's ...
-3
votes
1answer
80 views

In Java API documentation, what does it mean to inherit an abstract method? [closed]

Here's an example: In the documentation for java.util.HashSet, there's a list of "Methods inherited from interface java.util.Set", including equals, which is an abstract method in java.util....
0
votes
2answers
157 views

How to visualise Inheritance and Polymorphism?

I want to make diagrams that explain how Inheritance and Polymorphism work conceptually. Assume that we have a Cat class that inherits from the Animal class. The way that I can think of a Cat object ...
0
votes
1answer
69 views

How do I plan my refactor of my android app for better architecture?

The current structure of my app is as follows: One activity and multiple fragments (about 25 fragments) One huge monolithic repository One huge monolithic viewmodel Databinding is being used but with ...

1
2 3 4 5
93