All Questions
Tagged with java api-design
86 questions
3
votes
4
answers
701
views
Why is ArrayList not a Stack
I've been wondering for a while why an ArrayList does not have a stack-like interface (think push() and pop())
I frequently find myself using these constructs in Java:
list.get(list.size() - 1);
list....
-1
votes
2
answers
161
views
Rest Endpoint Design
I have 6 endpoints that return 6 json response:
/cities/{id} return a json object: {
"city": "Orlando",
"altitude": 10
}
/cities return an array: [{
"city": &...
1
vote
1
answer
149
views
Background thread processing vs queue based processing for relatively short tasks (max 30-40 seconds)
I need suggestion / recommendation on the design approaches mentioned below.
UseCase: I have a usecase where a client uses my system to generate some recommendations. Now, these recommendations are ...
-1
votes
2
answers
393
views
Idempotency for a financial transaction API
Say you have a REST API endpoint like POST /move-money which transfers money from your main account to a savings pot. There are three path parameters
accountId for the user's account
potId for the ...
1
vote
5
answers
931
views
DTO vs POJO (Entity) on POST request
If I have for example a User POJO like the following
@AllArgsConstructor
public class User {
@Id
private final String id;
private String username;
private String password;
private Date createdDate;...
1
vote
1
answer
122
views
Exposing DB table to other Microservice via a Library
Consider I have 4 Services .
Account
Order
Items
Customer
Now a External Partner Service calls all these services , by passing an External customer id ( EXT_CUST_ID) in the request.
Our platform has ...
3
votes
2
answers
377
views
Best approach to microservice shared databse architecture
I have two microservices, one Flask (python) and one Spring (java), they currently share a database. The Flask microservice handles processing json files (~40mb) for each user (could be 100's or 1000'...
-1
votes
1
answer
641
views
How to design my API that interacts with a third party API and persists to a database
I'm building a web app that will integrate with the Etsy REST API and persist information in a database for things like order information, listings, etc. Essentially a panel to manage Etsy orders and ...
2
votes
1
answer
2k
views
Best method to differentiate between two REST methods with the same pathparam (in Quarkus)
I have an issue regarding the differentiation between two Rest methods that have the same amount of path parameters:
@GET
@Path("image/{ratio}/")
@Produces("image/png")
...
-1
votes
2
answers
160
views
Designing class for fixed-size data structure backed by ArrayList
Say we want to write a Java class that represents a fixed-size list. Let's call it Chunk.java (as in, it represents a chunk of data to be processed or sent somewhere). My implementation of this class ...
3
votes
2
answers
602
views
What is the alternative to checked exceptions in API/interface design?
Despite checked exceptions being generally bad practice and anti-pattern, I find one feature very useful: having list of checked exceptions part of function signature.
Checked exceptions are "...
0
votes
1
answer
404
views
Should i specify that my methods "throws ConstraintViolationException" if the exception is actually thrown by a CDI interceptor?
Here is a sample method:
@ApplicationScoped
public class MyClass{
public void getUser(@Min(1) int id){
//get User logic
}
}
I'm in a CDI environment with @ValidateOnExecution(type = ...
9
votes
6
answers
8k
views
How should an API handle unsupported fields?
Let's assume I have this API on /api/v2/persons that enables me to create new entries by POSTing this JSON:
{
"name": "me"
}
The API is implemented using Spring Boot and if ...
0
votes
2
answers
322
views
Is it bad to use checked exceptions as API response?
Consider the following code:
public class User {
private String password;
public void changePassword( String oldPassword,
String newPassword) throws ...
0
votes
3
answers
2k
views
How to design RESTful API for response object properties dependent on request parameter
I have a RESTful service where clients provide product codes, start date and end date. In response, the service returns a list of price metrics for the products over the date range. Start date is ...