Questions tagged [java8]
Java 8 refers to the version of the Java platform released in March 2014.
73 questions
1vote
2answers
229views
Choosing a strategy for representing and handling errors (or more generally status codes) in java 8
I asked this questions on StackOverflow but it's definitely a bit too broad. Even for this website, although the question is about software design, it might not be enough "focused". I am ...
2votes
2answers
5kviews
Dependency Injection vs Static Dependencies
I am building a wrapper for a library that requires little complex logic. The whole project is 8 builder classes, 4 classes for doing some pre-processing, and a couple visitor classes. Essentially I ...
1vote
1answer
2kviews
How to remove unused code from a jar file? [closed]
I have a jar file, for example foo.jar. My code contains a lot of libraries (almost 75 jar dependencies). I am not using anything like maven or gradle, I'm just using pure java with pure jar files as ...
-1votes
1answer
186views
Optimizing methods with multiple if checks on getter values
I have a method where I fetch user input, check if certain values exist, and based on that build my own custom input object that I would use to search in a database. The code for the search method is ...
0votes
1answer
1kviews
Best practice to create model objects in Java
I have an existing microservice that talks to a Natural Language Processing (NLP) product and fetches around 50 fields. I need to create domain objects in Java now from these fields. I read about ...
-2votes
1answer
63views
Initialize some values from an array, write more elegant or efficient
I have tried this piece of code: String[] latitudesArray = latitudes.split(","); String[] longitudesArray = longitudes.split(","); Double startLat = ...
-1votes
1answer
552views
How to handle pagination in a stateless application having multiple components involved for the data?
This problem statement is around one UI component, 3 service components. The current design of the application is like: UI makes request to Service-A to get data Service-A first makes a call to ...
-2votes
1answer
796views
Refactoring nested if-else interface method in Java8
I have the below default method in an interface and it seems to be pretty complex because of the many if-else conditions. default void validate() { Application application = application().get(); ...
2votes
4answers
1kviews
Is the Java Stream API intended to replace loops?
I mean the question in the sense of: Should the occurrence of simple loops on collections in code in Java 8 and higher be regarded as code smell (except in justified exceptions)? When it came to Java ...
-5votes
1answer
130views
Java version: When to migrate? [closed]
About 4 years ago, where I was working, software was still being developed with Java 7 + Swing. It took me a couple years, but we could finally migrate to Java 8 + JavaFX, two years after that. Now ...
1vote
0answers
49views
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 (...
1vote
0answers
44views
subinterfaces redeclaring abstract methods
Why is it that some abstract methods in interface hierarchies are redeclared as abstract further down? iterator() for example, abstract in Collection is redeclared in Set and List, and again further ...
0votes
3answers
1kviews
Populate values in a map from a series of function calls
I have the following common pattern that I need to use in an application: Given a list of keys, call a function with a parameter to find values for the keys. The function may return null for a given ...
4votes
4answers
2kviews
Database agnostic DAO (NoSQL + SQL)
Background While writing a new component, I m in middle of making a decision of SQL/NOSQL database (Mongo vs Mysql) for my storage layer. As of today, mysql seems to be a perfect fit for my use-case (...
3votes
2answers
2kviews
Are there any problems with using class variables in Java that can be accessed by any method?
So I've been coding in Java for a decent amount of time, but recently, I've started a class that cares about my coding design. In the past, if I had two methods inside a class that needed to edit the ...