New answers tagged

0 votes

Rate-limited thread scheduler in Java

This code will work, but few suggestions : Here we are using timer as well as executors, side by side, the problem here is that you are un-necessarily creating 2 threads, timer is just going to hand ...
vishva's user avatar
  • 126
1 vote

Implemented Sorting of Map by Value and then by Key in java

I think since you just need the winner, we can use the reduce operation post collecting the data in map, that will reduce the overall time complexity as well. Adding the modified version of the code ...
vishva's user avatar
  • 126
1 vote

Search/Query API cross parameter check

You could wrap the request parameters in a class and then implement a custom validator that checks the dates. That way, your controller's code would be reduced to: ...
Miguel Alorda's user avatar
3 votes
Accepted

A vanilla Hibernate app (no Spring)

I suspect catching all Exceptions is bad practice (as opposed to catching specific exceptions). It depends... As long as you have the same reaction to all kinds of possible exceptions (just logging ...
Timothy Truckle's user avatar
0 votes

Send sorted, signed requests

The use of raw collection types is to me a bit of a code smell. protected HashMap<String, Object> body(String[] keys, Object[] values) { The declaration <...
TorbenPutkonen's user avatar
1 vote

Send sorted, signed requests

Performance At least by selecting the tag you ask for performance improvements. As a rule of thump you should not optimize for performance unless you have measured the performance and verified, that ...
Timothy Truckle's user avatar
2 votes

Spring REST Endpoint for Saving a User Inquiry

Regarding the mapper public final class QuestionMapper { public static Question toEntity(QuestionRequestDto dto) { ... } } The way the mapper is ...
TorbenPutkonen's user avatar
2 votes

The Matrix Winds In

We see multiple code stanzas that resemble: currentX--; currentY++; which seems tedious. Define a vector of four (delta_x, delta_y) pairs: <...
J_H's user avatar
  • 10.6k
0 votes

Quick Sort Done Lucidly

Sort Generic Lists It’s even more in the spirit of the algorithm, as I see it, to sort a List of a generic type by a comparator. This is an interface that ArrayList implements. In particular, that ...
Davislor's user avatar
  • 4,489
2 votes

Quick Sort Done Lucidly

To cover a few points that are not mentioned in the other two answers: Choice of loops Let's take a look at this while-loop: ...
MJ713's user avatar
  • 781
4 votes

String Permutation Implemention

The sources of inspiration aren't really up for review, but they have a couple of things in common: They print the permutations, instead of storing them in a list. They could be adapted though. They ...
harold's user avatar
  • 7,819
1 vote

Identifying indices of non-delimited characters in a string, supporting greater than 1 length of delimiters

Looking at the code, I can't easily tell its purpose. Java code exists in files and classes, blocks, functions, methods, and lambdas. With the exception of blocks, ...
greybeard's user avatar
  • 5,499
6 votes

Quick Sort Done Lucidly

Considering that the very name of the algorithm references speed, I think any approach that ignores important performance factors is very much against the "spirit" of the algorithm. As such, ...
Douglas's user avatar
  • 171
7 votes

Quick Sort Done Lucidly

The "spirit" of the algorithm is a subjective view, therefore it cannot be used as solid criteria for review. I will thus ignore that aspect completely. First and foremost, the algorithm ...
TorbenPutkonen's user avatar
2 votes
Accepted

Interest/Discount rate and loan calculator java

First of all, I'm coming from a C / C++ / C# and Haskell background and am not too familiar with Java. However, the main focus of this review are general programming techniques that will help you ...
Martin Baulig's user avatar
2 votes
Accepted

Optimize Island Counter program

import java.util.*; ... Scanner sc = new Scanner(inputfile); It turns out the * wildcard refers to this class. ...
J_H's user avatar
  • 10.6k

Top 50 recent answers are included