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
27 views

How to properly model an MVC model in this case?

I aim to understand pull model MVC. I'm stuck at defining a model for a simple color-guessing game in Java Swing I chose to practice it. I borrowed the model's initial version from an example which ...
0
votes
1answer
70 views

How can we better maintain a large amount of DbUnit datasets?

The project I'm currently working on a Spring Boot project, and I have a question regarding testing against the database. Our testing tech is currently JUnit 4, Mockito and DbUnit, and we test ...
1
vote
1answer
30 views

Large method with nested switch case(s) refactoring (Java)

Essentially I've got a bunch of formulas in two giant methods in a class designed to do math transformations and evaluations to multiple inputs. Where the inputs are actually lists of inputs (as there ...
-2
votes
0answers
29 views

how multiple users can access the same web application at same point of time with different data?

In interview somebody asked me this question,didn't get proper idea still, so i am posting here to get clear idea. Suppose one web application is there, it's in internet,so many end users aoround ...
1
vote
1answer
100 views

Receiving errors without engaging in excessive communication when using sockets

I'm currently writing a program that communicates with a server over TCP sockets. I originally planned for the communication to include a message confirming successful communication at the end of ...
2
votes
1answer
50 views
+100

How to build a modular/extensible Spring Boot application?

I'm developing a Spring boot / Batch application. What I'd like to do is to have a separated module for every job. This is a reasonable decision because different tasks (Spring Batch Job) have ...
1
vote
1answer
29 views

Validation framework and immutability

I have designed a simple objects validation framework in Java in the context of a code refactoring. The framework has a ValidationRule interface with one method Errors validate(MyObject myObject, ...
30
votes
9answers
38k views

Line break before/after operator [closed]

While Sun's Java code convention suggests to put line break before the operator many other guidelines disagree with it. I do not see any obvious pros and cons, so are there advantages of using one of ...
18
votes
5answers
3k views

Polymorphism case study - design pattern for 'Morphing' between two classes?

Imagine two classes: class Person { MarriedPerson marry(Person other) {...} } class MarriedPerson extends Person { } The idea is that a Person is automatically "morphed" to type MarriedPerson ...
10
votes
1answer
10k views

The Observer pattern using the pulling mechanism

I was wondering about the following implementation of public void update(Observable obs, Object arg) while I want to send to all of my observer and update using notifyObserver() I and passing a ...
1
vote
2answers
69 views

When do you do a health check?

So, I have an application here that posts requests to another service via REST API calls. I have to implement a health check within my application that ensures that the other service is up. I'm a ...
3
votes
1answer
105 views

Externalized properties for an Java EJB application

I am not sure if this is the right place to post this question, but I think this might be better suited than Stack Overflow. I have got an online application, a Java EJB application. Requirement is ...
-2
votes
0answers
18 views

How can I update selenium chrome driver version on intelliJ? [closed]

New to automation - we have 3.141.59 currently set up and I tried to update to 4.0.0-alpha-4 but tests are not running :( I tried updating this on POM file but didn't work.. Can anyone advice what I ...
0
votes
1answer
48 views

Need for a domain model in a service in 3 tier architecture?

I am building an API Rest with Spring Boot and I would like to clarify a concept about my architecture, to see if the community can help me. Imagine that in my database I have a table called Person. ...
1
vote
0answers
21 views

How to Upgrade MQ with incremental approach with 50 micro services

I have around 50 microservices which communicate with each other using Apache MQ implementation. I want to know if I can avoid big bang approach when I need to upgrade the MQ version. Current option ...
0
votes
0answers
30 views

Spring Data MongoDB: Update document based on multiple identifiers with Composite ID vs. MongoTemplate upsert vs. MongoRepository find & save

I'm wondering for best practices to upsert a document based on two identifiers. @Document(collection = "cars") public class CarEntity { @Id private String id; private String color; ...
64
votes
1answer
21k views

Java: “Heap pollution” [closed]

A "Heap Pollution" as in Non-Reifiable Types (The Java™ Tutorials > Learning the Java Language > Generics (Updated)) Why is it called that way?
3
votes
2answers
101 views

Why Kotlin doesn't allow assignments as expressions?

Coming from Java, I was surprised to find out that Kotlin doesn't allow assignments as expressions. Is there a reason for that? Java (Works) @Test public void test_x() { List<...
0
votes
2answers
1k views

How to maintain and configure properties files for different environments in Java maven project?

A Java project with maven as build tool needs to be deployed to different environments, such as ci, dev, test, prod etc. Each environment has a properties file with the same set of properties such as: ...
-4
votes
2answers
163 views

An idea about cooperation between development engineers and test engineers

Suppose we want to develop a small module (time needed: two weeks of one developer). Then what about this new (maybe?) pipeline: The test engineer starts working: Think about all cases (including ...
1
vote
2answers
73 views

How to design a process and use the business rules for sending alerts/notifications

Currently working on designing a process which demands me to send alerts like email notifications to the users which meet a business criteria(we can also call business rules). I want to make this ...
1
vote
1answer
143 views

How is a nested Try/Catch (inside the try) not an anti-pattern

I seen a debate on this. Nested trys in the catch I can see that being okay. The outer try has already triggered a catch by that time, hence no scope issues. The other way....hides errors (it a scope ...
0
votes
2answers
94 views

Designing a Parser - Abstract vs Interface

I am building a mini SQL parser that reads and converts SELECT, INSERT, UPDATE and DELETE statements into an AST. My current design is as follows: Statement.java: public interface Statement { ...
0
votes
1answer
955 views

Parsing and validation of a csv file

I am trying to create a library where I need to validate and parse a file in a CSV-like format and then use this data to generate a Tree data structure. At the moment I split the process into two ...
-2
votes
0answers
34 views

Should ViewModel returns (or emit in Rx) UIElement or just let the View to handle it (and thus test it)?

I'm using MVVM in my project. And from my understanding ViewModels shouldn't really know about the UI since it's not their domain. But what if I want to test whether the UI element that is mapped to a ...
2
votes
4answers
4k views

If C++ is generally faster than java, why most data analysis / ETL tools are developed in java? [closed]

I've read in a lot of forums, a lot of users agree C++ is faster than Java (even if it leads for a microsecond, it is important), so why are the majority of data mining software or software tools ...
0
votes
1answer
163 views

Dealing with interrupt and sleep

I was thinking that I could calmly Thread.sleep() on an interrupted thread. Sonar doesn't think so, of course. In some circumstates we should waiting for conditions, even if an interrupt occured. Is ...
-3
votes
0answers
21 views

how do you document your http apis in grizzly http?

I have a jersey app running in jvm http server through jersey-container-grizzly2-http (no servlets) and I would like to generate the documentation for my endpoints. Which options do I have?
45
votes
6answers
17k views

Prefer class members or passing arguments between internal methods?

Suppose within the private portion of a class there is a value which is utilized by multiple private methods. Do people prefer having this defined as a member variable for the class or passing it as ...
-4
votes
1answer
46 views

Command-Query Separation non-compliance

Why does Java's V Map.put(K key, V value) not comply to the Command-Query Separation?
45
votes
4answers
7k views

Why are there multiple different implementations of JVM?

While going over a java book I came across this phrase: Different JVMs can run threads in profoundly different ways. While it's completely understandable to me that code can behave differently ...
-1
votes
1answer
68 views

Is it bad to break out of a labelled block in Java?

I sometimes write Java code that looks like: success: { fail: { if (...) break fail; // some code if (...) break fail; // some code if (...) break fail; ...
37
votes
3answers
54k views

What is message passing in OO?

I've been studying OO programming, primarily in C++, C# and Java. I thought I had a good grasp on it with my understanding of encapsulation, inheritance and polymorphism. One frequently referenced ...
1
vote
0answers
37 views

how to handle external shared libraries, which we do not want to expose

We have 800-900 services we expose via an ESB. Each service is a web app hosted on Tomcat servers. We have 4 tomcat servers per group of services. Our services are split into 4 groups. Each service (...
0
votes
1answer
34 views

Mapping bidirectional 'toMany' relation from DTO to entity

The application that I am working on has numerous ...toMany relations, e.i. class Model can have several parameters. In Unidirectional world, it is simple to manage a collection. I can clean the ...
-2
votes
0answers
30 views

Android project optimization, should I avoid creating too many files or classes?

When we do our test mocks for UnitTesting, if we really need to, we usually create the dummies in a DummyFactory which will generate the needed ones one for each method: class PaymentsDummyFactory { ...
0
votes
6answers
129 views

Adding client specific method to a listener interface is a good idea?

I'm using a listener pattern where a class A listens for events from various classes B, C, D with the help of a listener interface I Essentially the structure looks like: interface I { void ...
1
vote
4answers
146 views

Role of DTOs in Rich Domain Model

I work with Spring applications. Recently I have found this article about the Anemic Domain Model. They recommend putting logic in Entity classes. It solves a problem that Martin Fowler described in ...
-1
votes
1answer
924 views

Can we call final field as object's constant?

We call static final fields as constant, rather I should say Class constant. So can we call just final fields as Object's constant? Is it right to say this? Edited :: Consider the following code : ...
-4
votes
0answers
32 views

Transfer files to remote server using FTP or SFTP

Using java, I have my java application running on one server. This application is responsible for generating a zip file and uploading it to a specific directory on the same server. However, I want ...
-2
votes
1answer
38 views

Generate large Excel files and response from API

I need to generate a large Excel file (something around 50 megs) and send response to another API which will provide it to the front end for a download option. My question is if it will be better to ...
0
votes
1answer
151 views

Custom ACL Implementation

I have been trying to figure out an ACL solution for my application which should manage API endpoint's access rights dynamically. Some said that I have an option of Spring Security ACL. I checked it ...
1
vote
1answer
74 views

RMI vs APIs vs Akka Cluster

We have a Java Play Framework Application which we want to scale out into a cluster. The only issue is that there are services ran by the Akka Scheduler once per day, and we don't want these services ...
87
votes
3answers
66k views

What is the name of a function that takes no argument and returns nothing? [closed]

In Java 8's java.util.function package, we have: Function: Takes one argument, produces one result. Consumer: Takes one argument, produces nothing. Supplier: Takes no argument, produces one result. .....
1
vote
1answer
62 views

Handling OAuth 2.0 access token

I am creating a rest template to consume REST API secured by OAuth 2.0. The provider has implemented an expiry for the access token for 5 mins. So Using the rest template, I will be calling the ...
2
votes
1answer
106 views

Using Enum constructors, Overridable Getters, or both in combination?

Currently an enum in our project takes properties in the constructor. They are practically guaranteed to be entirely different across every different enum. Now I'd like to add an property which is a ...
-2
votes
1answer
48 views

Display different panel on button click (MVC pattern)

I have to code a gui like this: It's an homepage with a left menu and a changing right part, on button1 click form1 must be displayed, on button2 click form2 a so on. Each form has its own button "ok"...
-4
votes
2answers
96 views

In java string classes are final, than how did we enter value on string even its a final class?

In Java string classes are final, we know that we can't inherit a final class and not able to write on this, then how did we enter a value on a string even its a final class?
-4
votes
0answers
23 views

Java File diff with resource constraints

We have two unsorted ~100mb files containing file paths and their hashes in the following format: a/b/c/d.pdf;1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p One of these files is a source and the other is a target....
2
votes
4answers
2k views

Looking for a better Factory pattern (Java)

After doing a rough sketch of a high level object model, I am doing iterative TDD, and letting the other objects emerge as a refactoring of the code (as it increases in complexity). (That whole ...

1
2 3 4 5
91