Skip to main content

New answers tagged

1 vote

One centralized class to wrap/manage OpenTelemetry

public class OpenTelemetryManager { If this class is only used as static Utility, it should be ...
Bobby's user avatar
  • 7,797
1 vote

Printing a Hollow Butterfly pattern

Two thoughts: It is more normal (in C and its descendants, including Java) to write (for your first loop): for (int i = 0; i < n; i++) { I think this is mostly ...
David G.'s user avatar
  • 1,436
2 votes

Printing a Hollow Butterfly pattern

I have another suggestion: Instead of System.out.printing, you could build a single string containing all the ASCII art and print it once to console. To begin with, ...
coderodde's user avatar
  • 28.9k
6 votes
Accepted

Java: Benchmark findFirst() and findAny() methods on non-parallel streams

whether the benchmark has been implemented correctly I'm afraid, no. JVM does quite a bit of optimizations at runtime, compiling certain frequently called methods into highly optimized native code. ...
Alexander Ivanchenko's user avatar
6 votes

A chess engine in Java: generating white pawn moves - take II

Coupling I essentially extracted the move generating logic to a dedicated class implementing an expansion interface. That way, my code will stay well modularized. Modularizing the logic is a ...
Alexander Ivanchenko's user avatar
6 votes

A chess engine in Java: generating white pawn moves - take II

No offense, but it got worse :) Everything is quite over engineered. It's not part of the posted code, but combining the enums with the bit masks is pointless. Do one or the other, not both. You have ...
RoToRa's user avatar
  • 11.3k
2 votes

First tic tac toe game. want to see if valid or needs improvement

Start Over Start from scratch. You need to build a sense of the big picture of coding Tic-Tac-Toe. That perspective serves for any coding project. The before and after will give you insight that ...
radarbob's user avatar
  • 7,684
2 votes

A chess engine in Java: generating white pawn moves

Very good first attempt. Code follows C-style patterns. For more Java/OOPS-style, try incorporating these into the code: Solid Patterns 1.1. Segregate Actors and Actions 1.2. Actors are Pieces on ...
Adi's user avatar
  • 21
0 votes

A thread-safe performant Money Transfer API in Java

The approach is flawed from the start. An Account does not perform money transfers. Accounts are just data objects. A money transfer is done by a service, that ...
TorbenPutkonen's user avatar
6 votes

A chess engine in Java: generating white pawn moves

Do you just want elegant code, or do you want efficiency? I'm inclined to think that the memory allocated to a State needs to be a lot less than an array of 64 integers. It's fairly easy to get it ...
Michael Kay's user avatar
10 votes

A chess engine in Java: generating white pawn moves

The methods related to InitialDoubleMove are misnamed. It took me a while to understand what their purpose is. Consider renaming them to ...
vnp's user avatar
  • 56.8k
11 votes

A chess engine in Java: generating white pawn moves

The code in general is fine. If it were a C program (or some other classic language) I would even say good. However this is Java and especially by using integers to represent the pieces you completely ...
RoToRa's user avatar
  • 11.3k
3 votes

A thread-safe performant Money Transfer API in Java

This is not code where you should be remotely worried about the performance. Maximize readability until you have a tested, proven bottleneck. What happens when an external thread acquires and does not ...
Eric Stein's user avatar
  • 6,562
2 votes

Auth0 Credentials Manager in Android app

Never ever use the "My" prefix. Teachers like it when they want a quick and dirty way to resolve a naming conflict between an interface and their example implementation. Everywhere else it ...
TorbenPutkonen's user avatar

Top 50 recent answers are included