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
1
vote
2answers
39 views

How to design a process and adopt to changing business rules and 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
2answers
66 views

When to model an aggregate's entities as part of a value object?

I've read a lot about Domain Driven Design including books from Eric Evans and Vaughn Vernon. So I am familiar with the concepts Aggregate Root, Entity, and Value Object. But while I was modeling ...
0
votes
1answer
199 views

Have the inventors of Java ever publicly expressed regret about hashCode and equals in class Object? [closed]

I was talking to a colleague recently about hashCode and equals being methods in class Object in Java (among other languages). I am from a more theoretical background while my colleague is more of a ...
1
vote
2answers
33 views

Multiple thread invocation in Rest Web Service

I have a scenario in our Web Application. GUI invokes a REST web wervice and further web service calls a procedure. However, the procedure returns data properly for most of the scenarios. In some ...
1
vote
0answers
58 views

How to architect time consuming server side process with multiple steps

I'm stuck on a problem and I don't know how to bite it. In the code I'm working on we do have functionality, which takes part on the server. And this functionality is maybe not complicateg perse, but ...
22
votes
6answers
5k views

Coupling: Theory vs Reality

Coupling is defined as the knowledge one object has about another one, which describes how dependent they are. The more dependent, the worse, since changes in one would impact in the second. High ...
1
vote
2answers
149 views

How to avoid type checking with Java/OOP in this situation?

I have a collection of animals (interface) which contains birds and cats (both also interfaces). I want to print out all the cats to the console and I am forbidden to use instanceof (I did not make up ...
-2
votes
1answer
57 views

Big scale projects

I had a question about big scale projects. what if the team decides to change a library and therefor the codes should be changed. for example what if the team wants to change the picasso library to ...
1
vote
1answer
89 views

Why does java use an @functionalInterface annotation, instead of a modifier?

What were the motivations for java to use the @FunctionalInterface annotation, instead of creating a new FunctionalInterface modifier? @FunctionalInterface public interface MyFunction { TypeB ...
2
votes
1answer
77 views

Convert modelId to model & validation of modelId — in Controller or Service layer?

Let's say a sample case where we want to create an article with some tags. Following are my pseudocode, and the questions are at the bottom. Sample Case Request: @Data public class ...
-3
votes
0answers
29 views

Is there a Fortify annotation for returning a wrapped stream/connection? [migrated]

We have a Java method that accesses a stream, wraps it, and returns it to the caller. (We have a similar situation with a database connection.) Fortify (the static code analyzer) reports this as an "...
0
votes
2answers
120 views

How to write the following snippet in more cleaner way?

When the caller gives me a call, I need to evaluate n number of criteria which currently I'm doing like if (a & b & c & d & e) Day by day the conditions are growing and it'...
0
votes
2answers
150 views

Alternative to mass Try Catch blocks for my logic

Currently I'm working on creating something with the following general structure. I want to call 4 different APIs in sequential order (the results of one are needed for the next one). If one throws an ...
2
votes
2answers
93 views

Alternating between Java streams and parallel streams at runtime

This is a question I constantly ask myself when designing a data intensive application: When is it appropriate to use stream() over parallelStream()? Would it make sense to use both? How do I quantify ...
2
votes
1answer
79 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 ...
1
vote
0answers
37 views

How to manage data in an Aggregate

This is an overly simplistic example of a domain model for a time keeping domain. I only started on it today as a way to practice the techniques I'm learning while reading Implementing Domain-Driven-...
2
votes
1answer
40 views

Evaluate and run Dynamic Rules

I have to build a dynamic rules engine in say, Java, where a user can define a certain list of filters and trigger a certain event based on them. The rules will be a long chain of conditions, such as: ...
-3
votes
1answer
316 views

C# is fantastic, if only List 'd respect Remove&Return [closed]

In the domain of system-modeling (e, systemVerilog, matlab, phyton), lists are obsoleting arrays, stacks and queues(*) altogether. Other domains that use python, perl and ruby have that same mindset, ...
1
vote
0answers
36 views

How does a framework manager, broker or coordinator class handle pluggable extensions and make them run?

I'm trying to understand if there is a manager/broker/coordinator class in frameworks and I hope so, but what possible ways are in a framework to make it run the pluggable extensions and what the term ...
0
votes
2answers
82 views

Boolean function for clean predicate?

Suppose I have a method which is something like void getCalled(Predicate<Integer> predicate, List<Integer> lst){ lst.stream().filter(predicate).forEach(...); } The thing is, for this ...
1
vote
0answers
34 views

Handle multiple similar structured XMLs in a Java project

We have a case scenario in our project where we are provided with a set of XSDs. These XSDs we converted to Java Pojos with the help of JAXB. After this we were suppose to update few values in the ...
3
votes
1answer
84 views

Is this a good design for wrapping asynchronous API calls into a RESTful interface?

I'm working with an API that has many asynchronous calls and handlers. I'd like to extend these with a RESTful interface and endpoints in spring. I'm imagining the usual Controller and Service layers, ...
-1
votes
0answers
32 views

Is it possible to use Seam so that it will cover only part of J2EE/Spring project?

I have got an old J2EE project that includes mixed technologies. Very mixed. For example, it uses iBatis and Hibernate or Spring/JSF/EJB simultaneously. I would like to organize it better, using Seam. ...
3
votes
1answer
128 views

Factory/Strategy Pattern for objects that require different pieces of data

I'm facing some difficulty with designing a factory and/or strategy pattern for building out EmailTemplates. IMO this seems like the design pattern to go with, but I feel like the path I'm going down ...
4
votes
2answers
317 views

Should dependency injection be used when there will only ever be one version of any class?

I'm writing a number of Selenium test classes that use Helper classes which contain processes that are often reused (ie. accessing a particular page, entering something into a specific field, etc.) ...
0
votes
3answers
117 views

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 ...
0
votes
1answer
74 views

Tomcat redirect HTTPS to HTTP

Made system update to temporarily disable HTTPS in our Tomcat server. Previous users are still using Https:// URL to access system and receive error message because it's disabled. Would like to ...
2
votes
2answers
135 views

Refactor approach for huge if else Clutter based on many independant conditions

Currently I am cleaning up hard to maintain and test if else clutter which is based on conditions which have to be checked in isolations: What is the basic semantic of the conditions? Big Entity ...
-3
votes
1answer
84 views

Should vanilla solutions be avoided in Spring web applications?

I am making a Java and Spring webapp that scrapes data from a web and then publishes it through an API. Some of the raw scrapped data is in the form of Set<SomeObject> which I then convert to a ...
1
vote
1answer
47 views

JEE Gps Tracking System Design

I have created a real-time GPS tracking web-based system using Java Servlets as a backend solution whereas the front end is using javascript with ajax requests and WebSockets. (Both the front and ...
2
votes
2answers
164 views

Bottom-up vs top-down object building in API

I am trying to identify the pros and cons of two approaches to create an object to return from my generic API. I am thinking the first approach I am sketching out has the advantage of being easier to ...
1
vote
1answer
104 views

Is designing a generic parameterized class with methods of it accepting higher order functions a functional technique that we can use in Java 8?

Recently I have asked this question: How do you rewrite the code which using generics and functionals in Java 8 and mixing oop and functional programming by using only object-oriented? on ...
2
votes
1answer
172 views

What are Java Interfaces used for? (multiple choice question)

I'm a beginner studying interfaces in Java through some quizzes and I came through this question: What are Java Interface used for? I can opt among one of the following three choices: A. They'...
1
vote
1answer
62 views

Best approach to handle user statuses and keep their history

I am developing a Spring application which has a few different modules. There will be a bunch of users added in the database. I want to add a feature, which will allow me to track users' availability,...
-1
votes
1answer
69 views

Services calling services

The application I'm developing has: controllers (they are responsible for processing RESTful API calls), services (their methods are being called by controllers, they are responsible for operations ...
-1
votes
1answer
47 views

Automated code navigation for finding all types of exceptions thrown?

There is a java code base based on the Spring Boot framework. As an activity I want to navigate the code path of every API method to check for the checked exceptions that are thrown at different ...
1
vote
1answer
127 views

Using ThreadLocal in Java

In one of my projects, I have this following use case - I have a variable, that I need to pass around in many methods. Business logic and object creation in those methods are dependent on that ...
1
vote
1answer
136 views

How does .Net's Mono Framework, Work on Android

Android uses the modified version of JVM known as Android Runtime to execute android apps. How do games (with Unity 3d) and Apps (Xamarin) written in C# (which require dot Net's Mono framework) run ...
0
votes
1answer
112 views

What's the difference between reactive programming and event driven architecture?

What's the difference between reactive programming and event driven architecture? Is reactive programming a way of implementing event driven programming?
-4
votes
4answers
137 views

C# Why should i limit myself to List or Stack ? ( instead of having both)

List is implemented in C# exactly as Stack, see: https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.stack-1.push?view=netframework-4.8#remarks https://docs.microsoft.com/en-us/...
-1
votes
2answers
85 views

How to implement a different behaviour for a method without changing the interface?

I am creating a small project that implements an interface in Java. I am not allowed to modify the interface, which means I can't change the functions in my class that implements the interface. ...
8
votes
1answer
194 views

To show the difference between system VMs and JVMs

I am trying to draw diagrams that show the difference between system virtual machines and Java virtual machines. The first two images looks correct to me. But I don't know how to draw the third. ...
1
vote
1answer
83 views

API design for data model with frequent field name updates

I have an external data model framework with frequent updates to the names of fields. Say for an iteration I implement on - EnterpriseModelObject -- EnterpriseDomainContentList --- ...
0
votes
1answer
99 views

What is the best practice to insert two similar records in sql server db table which will be sent to two different destinations?

I am working on parsing a file and inserting records into SQL Server DB.The database table structure will be something like this: A Users table which contains (id, name, address, destinationName,...
35
votes
10answers
11k views

Is it a good idea to have logic in the equals method that doesn't do exact matching?

While assisting a student with a university project, we worked on a Java exercise provided by the university which defined a class for an address with the fields: number street city zipcode And it ...
0
votes
0answers
25 views

Microservices: Changing DB Usernames at Runtime and Carrying Session Settings Across Other Services

Currently, our database is a shared database separate schema. Under the current architecture, all users start at the entry schema, which we called as APP, before the identity of the user (upon ...
-4
votes
1answer
73 views

Java Class Structure

I have a problem during a project of mine using Java, as usual my java classes have the structure: import ...; import ...; ... private Type0 myVariable0; private Type1 myVariable1; ... ... private ...
1
vote
2answers
88 views

Modeling Class hierarchy that may change during runtime

I've been building an application that processes documents through different filters. I have a class (or better as an interface for creating test-doubles?) called Document. The Document class ...
5
votes
3answers
408 views

Microservices - What does it mean to deploy & upgrade independently?

In this article, it is mentioned (emphasis mine): ...the microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own ...
1
vote
0answers
18 views

How to lay out a core java module with an Android GUI layer on top

How can I use Java modules in an Android app repository? In particular, what directory structure should I use? I have a project in mind for which I would like to have a GUI-independent core Java 9 ...

1 2 3 4 5 90