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
1answer
59 views

Should you use your own implementation of inversion of control instead of a dependency injection container? [duplicate]

I have a small project that has 6 service classes and a main class. Since they are service classes and does not store any state in it, I declared one static method in each one: class Main calls A....
0
votes
1answer
81 views

java threading model for scale up

I need some advice on the scale-up issue. we have a java application currently it works as below the current system is using the Thread Per Request Model. each client connection (long-running and ...
1
vote
4answers
126 views

Architectural problem for class combination (cartesian product) for save format strategy

Hello to everyone and thank you for any suggestion. I have a family of subclasses of Track (Track is abstract). Every concrete Track has a different number and types of fields (attributes) that extend ...
0
votes
0answers
47 views

Best choice for a holding large number of objects in java

I have a set of array, containing a large number of objects (products), which has lately grown so large, searching in it takes about a minute, which is considered too long, since one search is ...
1
vote
2answers
83 views

Checking the user in almost all use cases

I have a web application that has Users that belong to Companies. A User can only belong to 1 Company at a time and they can manage their own company information. I'm using java spring and I'm ...
-2
votes
0answers
33 views

Formula Reader and parser java

I have a task im working on which should read formulas from db and interchange the fields in the formula with real values and evaluate them. i will give a descriptive explanation of what ive done and ...
0
votes
0answers
47 views

How to use single Spring-Boot instance to cater to multiple environments?

We have a Spring-Boot Web application currently deployed to 7 environments (DEV, SIT, UAT, Pre-Prod, Prod, etc.). This application connects to other REST services, which has different URLs for each of ...
-1
votes
0answers
87 views

Clean Architecture By Uncle Bob / Design Issue [duplicate]

As per to uncle Bob we should divide our App into layers and keep the business logic independent,to make loosely coupled App. I can understand that we need to make kind of plugable business logic that ...
-3
votes
0answers
50 views

At what point does a Java SE app transition into Java EE territory?

I know EE is based on SE, but where is the line drawn when an app transitions from being SE to EE? Let me be specific. Let's say you create a console-based application then decide to add web socket ...
-1
votes
0answers
24 views

What's the correct way to handle view creation and switching with JavaFX?

I'll put it simple: I've been using JavaFX for college and pet projects but the sensation that instantiating and switching views from another view it just seem wrong. Of course, it's available in the ...
-3
votes
0answers
53 views

Why in java package names follow the convention that has this form: org.^something^.^rest_of_package_name^? [duplicate]

Both in my Android Java project and in Junit's documentation I noticed that package names follow the following convention: For example in junit4 there's the org.hamcrest prefix on each package name ...
1
vote
2answers
79 views

Efficient and correct way to store image data in Java? [closed]

To clarify, I'm having to develop a GUI application that stores information about clients (for a course) where one of the fields is the logo of the client. I'm currently using serialization to persist ...
-1
votes
1answer
76 views

Design Pattern for accessing data over RestAPI calls

I am looking out for a general design strategy or pattern designing various components in my client application. Here are high level details: The data is accessed my making a RestAPI call. The data ...
0
votes
2answers
102 views

Is there any benefit testing only with mocks/fakes/doubles?

Say I want to test the behavior of the GUI while I follow a PassiveView approach. I also use the command pattern to handle the actions of the user. So given a PersonView and a PersonService with a ...
-1
votes
2answers
78 views

Payment Processor using polymorphism?

I am writing a payment Processor class, then will take different payment objects in input and talks to external services to process payment.My class is designed using polymorphism as follow: public ...
15
votes
4answers
3k views

Should entities contain information about their amount?

Can I get some thoughts on the entity design? Let's say I have an entity called Book. Let's say I create a specific instance of that book. It has a title A and an author B. Since there can be multiple ...
0
votes
0answers
47 views

Designing a unique id reliably based on a String date?

I am creating an Android application that sets alarms based on the String date of a list of Objects (PendingIntents, with each taking in an id, that is an integer). In order to cancel the ...
0
votes
2answers
96 views

Where should I put the initialization validation of a Value Object?

Hi I am making a Value Object. public class Age { public Age(int age) { Value = age } public int Value { get; private set; } } I want to check ...
-2
votes
2answers
60 views

Where to place exception handling while using Decorator design pattern

How to design a service layer structure that will be resistant to exceptions. Let's say I have a simple OrderService service, this service performs basic operations - saving an order. public interface ...
0
votes
3answers
127 views

Map same POJO values to different variables based on Key value without switch case

Based on the string "key", I want to get the latest and previous values assigned without using the Switch case. I need some mapper method that it get the key value as input and map the ...
0
votes
1answer
91 views

Does it make sense to create a WAR anymore?

This is more specific to spring boot projects and applications whose main USP is its APIs. Now that we can simply create a JAR file deploy it anywhere, what is the point of WARs? Is there a specific ...
2
votes
2answers
85 views

Foreign Keys and Eventual Consistency

We have a project that loads metric data from various etls and services into an AWS SQS queue, where that data is processed and inserted into a metrics database, also running on AWS RDS. When we ...
0
votes
0answers
62 views

Simple Rate Limiting Logic

I have a requirement where I need to add some rate-limiting functionality to an existing web application. The application reads transactions from a queue (TXN queue) and processes them in realtime. ...
0
votes
0answers
25 views

Third Party Data Push / Exchange Solution

Apologies in advance if this is the wrong StackExchange forum for this question. Looking for a recommended data exchange solution. Our application needs to push transaction data to a third party. Each ...
2
votes
3answers
168 views

Extending the class to test it: is this testing approach fine?

I am curious if the following example of testing a class with protected methods is fine. For example, say you have the following class Foo that has method a() of return type Bar: class Foo { ...
2
votes
2answers
128 views

How to structure classes for two distinct use cases that share key parameters

I have a Java application that needs to generate mathematically-defined 3D shapes for a voxel world (Minecraft specifically, but that's not important to the discussion). These include sphere, ovoid, ...
1
vote
2answers
62 views

Reuse helper objects or recreate them on usage?

I would like to get some experienced advice about the handling of helper objects. Consider the following situation where we want to build a connector to a third party system. The connector shall ...
3
votes
3answers
293 views

Best practices for retrieving data scattered over multiple tables

In the company I work with, we have a 3-layer architecture in our micro-services and the flow is like this: Repository/DAO (entity) => Service (entity) => Controller (dto) At the Controller ...
0
votes
0answers
13 views

scalable architecture for application with mailbox polling servers

I'm working on application that has relatively low volume but has four nodes on it. One node is currently handling server requests, and polling a mailbox and doing some processing. We think the volume ...
-2
votes
1answer
33 views

Entity objects with data external to the database

I'm looking for design patterns to model (java) objects that are partially stored in a database and partially stored some other external source. In my case the external data is a whole lot of files ...
2
votes
2answers
121 views

Should I create two synchronous or a single asynchronous rest APIs?

Here is the situation. System A sends the notification as it completes the work items to System B. System A does not know how many items the project consists of. It's just a pass-through system. ...
4
votes
3answers
209 views

Passing object or using the field

I would like to know what is a more appropriate way to code in Java. Is it generally better to pass entire objects in the method's parameters or just using the fields from the class? Using the field: ...
0
votes
2answers
136 views

Inversion of control

I have been reading about inversion of control and dependency injection and I was wondering the following. Is there a good way to tell when it is okay to initialise an object inside a method body of a ...
1
vote
4answers
90 views

Using Enum to represent VehicleType in cab Booking system

I am working on low level design of cab booking type of system and feeling stuck at modelling Vehicle in Booking class.I came up with following design. Class Vehicle { } ...
1
vote
1answer
49 views

What is the better way to save swagger code gen plugin generated model classes in spring boot maven application?

I am working on a spring boot maven project in Eclipse IDE. And here is my pom.xml. <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/...
-1
votes
1answer
48 views

Designing around potentially multiple RESTful API calls to a downstream service

To set up the problem, let's imagine we have a downstream service that we need to call for some information. We set up an API endpoint and call another method which will hold our business logic and ...
12
votes
5answers
2k views

How can I simulate a “negative” type system?

In my experience, all languages I know have a sort of "positive" type system. What I mean by "positive type system" is that when you are writing the source code, you always specify ...
0
votes
1answer
60 views

What Should An FTP to REST Process Look Like?

I am writing a new application where the clients want to communicate using files over (S)FTP. The first use case is that the client puts a file on the FTP server at end of day. I then process it and ...
1
vote
2answers
93 views

Is it wrong to extend an inner static class in java? (Builder pattern)

I'm working on a java project for the university. The project is a card game in which you travel around a 2D map and fight against some enemies. My part consists of creating the deck and the cards. I ...
-1
votes
2answers
43 views

Using classes in separate Tomcat Projects

I need your sage counsel on the following scenario that I would like to implement. I have a class that interfaces with a persistence layer (an ERP system) with a JAR dependency (in fact JAR and a DLL :...
2
votes
1answer
97 views

DRY principle vs decoupling (business from GUI)

Say I have a business model called Vehicle. Vehicle has many fields but to keep it simple say it looks like: public class Vehicle { String ownerName; String brand; FuelType fuelType; }...
1
vote
2answers
76 views

Can DTO have helper method that operates on DTO fields?

I wonder where to add method that reads my dto WindowDto.getPath().getPoints() and based on this collections returns some value (that value will be needed in some different srevices in my app): public ...
0
votes
3answers
121 views

Solutions for polyadic functions/methods

In the book Clean Code, Robert C. Martin says that we should avoid polyadic functions (functions that contain four or more arguments). One of the solutions presented by him is the use of objects as ...
0
votes
2answers
54 views

Best way to package Resources in the microservices

I want to know if there is a best practice around packaging the Resource classes of micro-services. By Resource classes I mean the contracts (like request, responses and error objects of the service) ...
5
votes
2answers
200 views

DRY polymorphic object creation (always valid)

Assuming we have polymorphic entities such as the following, with constructors enforcing invariants (assume there could be lots of sub-classes). What would be an effective/elegant approach to ...
0
votes
1answer
51 views

Spring Boot + MongoDB project structure and database creation

I'm planning to start a new Spring Boot project with MongoDB. I'm very familiar with Spring Boot, but all of my past projects used MySQL. Each of my projects has the following directory, that holds ...
-2
votes
2answers
72 views

Comparing and replacing values in an array [closed]

I am currently working on a program that replaces the value in an array if the value next to it is the same as the current value. So If the array is [0,0,0,1,0,1,0], when the program runs it'll turn ...
0
votes
0answers
50 views

Pushing entities through multiple levels of abstraction

Let's say I have an external library that I want to use in my application, which performs some long running operations: interface ExternalLibrary { void operation1(ExternalInput input); List&...
0
votes
2answers
78 views

Conditionless code when working with a time bound cached map

I have this piece of code, and I've been racking my brain trying to think of a way in which I could factor out the if statements, mostly as practice to write code that is less conditional and more ...
2
votes
1answer
105 views

why java List interface implements 10 methods of(..) instead of just one varargs version? [duplicate]

I find it strange that in the List interface are defined 10 methods of(...) static <E> List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) instead of just @...

1
2 3 4 5
95