MrBrushy
  • Member for 5 years, 3 months
  • Last seen more than a week ago
Shopping Cart design interview task
7 votes

I won't add to @mtj's comment (I totally agree that an array defined as a means to exchange information is a code smell). I agree with @RobAu that you should stay far a away from those magic numbers ...

View answer
Sending data to a database in size-limited chunks
Accepted answer
7 votes

I waited a few days to get other answers to your questions. now I feel I can add my 2 cents. First off, the obvious: This is one single method. It does: Polling a queue Serialising a message into a ...

View answer
Number of Islands in a 2d grid
Accepted answer
5 votes

Complexity Each cell will be accessed at most 5 times (once to check itself, once per each neighbour that are on land, as part of their BFS search). This means your overall complexity is O(n) (n ...

View answer
Validation on two different classes and passing one object including everything to another class
Accepted answer
5 votes

The question is rather vague, I'll assume you haven't taken the time to step back and look at your overall architecture. Still, a lot can be said already, so here's my understanding (you should ...

View answer
Calisthenics objects, and primitive wrapped in Objects
3 votes

That cannot work with this Object hierarchy. You have a contradiction in your katas, that requires some messy stuff. Here's an extract of the katas of your previous similar Question (emphasis mine): ...

View answer
Updating positions of enemies every frame
3 votes

You could try not updating all your entities, on all your frames. This is standard practice in games, and at high framerates, is unnoticable. You would split entities in 10 buckets, and only update ...

View answer
Running multiple producer and single consumer in a multithread environment
Accepted answer
3 votes

Let's tackle the Threading and synchronization. It's a big task. Just one word before hand: Immutability is the king synchronization. Just putting objects in Thread-safe Java Collections does not ...

View answer
Repeatedly eliminate a substring
3 votes

OK I'm no good at C#, I'll present an alternative solution is pseudo-code, using a Stack of matches. The key is : The characters in the substring are all different Which means if we encounter ...

View answer
Approximating Pi, Monte Carlo integration
3 votes

Naming The Dart class does not define darts. It holds a Collection of Points called darts. It is a Quiver. I would rename Point as Dart however, and it could extends Java's Point class. World ...

View answer
Splitting strings in Java
3 votes

Formatting Your overall code formatting leaves to be desired. Please use consistent blocks and whitespace. It helps hugely in readability. Most IDEs will do it automatically for you whenever the ...

View answer
NBA*: Very efficient bidirectional heuristic search algorithm in Java
Accepted answer
3 votes

(Personal note: Good work, this is an excellent resource. Can I bookmark/reuse?) What is this for? protected AbstractPathfinder() { this.graph = null; this.weightFunction = null; // Compiler ...

View answer
Send data on a socket from multiple threads
2 votes

I see several issues here belonging to style, structure, and functionality. Also, the code shown is partial. I'd like to see what that cache thing is doing (if anything at all). 1 - Style 1.1 - ...

View answer
Getting the distance between various classes of shapes
2 votes

Quick Comments Your Distance Interface is weird. It does not represent a distance, but an object having the ability to provide the distance between it, and some other object sharing the same ...

View answer
Java queue with dynamic priority flag
Accepted answer
2 votes

Constants naming CONSTANT_HUNDRED is a bad name. It tells us its value, but not its role. Its value could be changed, making the whole thing useless, and in addition it is used in completely ...

View answer
Finding shortest paths in a Wikipedia article graph using Java
Accepted answer
2 votes

Naming QUEUEA, QUEUEB, DISTANCEA, DISTANCEB, PARENTSA, PARENTSB Should be: queueA, queueB, distanceA, distanceB, parentsA, parentsB baseGetNeighbors is a strange name. I understand it's the 'base' ...

View answer
Send records and retry them if acknowledgement is not received
2 votes

This is missing in the code: Store all the incoming records in a CHM from multiple threads. Records will come at a very high speed. Who adds work to the buckets? To which buckets? I might be ...

View answer
Shortest path navigation across a grid using Best First Search
2 votes

High-level reusable or purpose-built? You wrote Strategy like a high-level, all purpose Dijkstra Pathfinder (works on nodes, which can be arbitrarily far, but your grid only allows 4-connected ...

View answer
Implementation of a graph in Java
2 votes

You have chosen this class hierarchy: AbstractGraph / \ UndirectedGraph DirectedGraph It is a valid one of course. But you coded it too strongly, and also an other, more ...

View answer
Activity Assigner - that randomly assigns each student to an activity
2 votes

Good feedback form @RobAu. I would add a few point on OOP: I do not understand the added value of subclassing the Activity. Fundamentally, all Activity subclasses do a similar thing, the difference ...

View answer
Generating RPG Characters (Objects)
2 votes

Your code is quite well structured. A few points: Useless cast before calling a method These cast bother me: // Creating a new knight, that is a clone of the first knight humans[2] = ((Knight) ...

View answer
ROW (Race of work) simulation
1 votes

Very quick review here, formatting is good, so I focused on good practices, reuse of standard Java libraries (Streams), naming etc. To have this code more organized I would embrace Objects and create ...

View answer
Password generator using Decorator Pattern
1 votes

The Abstract class Decorator is too light I find your DomainRangeDecorator abstract class a bit lacking in functionality. I understand you made it a backbone for all Domain Ranges, but what ...

View answer
Acey Ducey game
1 votes

Why isn't Deck an object? It seems the Dealer functionality replaces that object. I would rather have a Deck object with functionalities like restore(), shuffle(), draw(), hasCards() etc. The added ...

View answer
Concurrently reading a Map while a single background thread regularly modifies it
1 votes

Comments Just wanted to point out you made great, great comments. Those explain implicit relationships (why you use local variable, why synchronise methods etc.), they do no useless hand-holding, ...

View answer
Dynamic array challenge
Accepted answer
1 votes

When instancing generic collections, it' best to use the diamond operator to let the compiler figure out the generic arguments. This lets you define in a single place (type definition, not constructor)...

View answer
Rainfall challenge solution using Union-find
Accepted answer
1 votes

Fun problem! This is looking quite good. That said, there are always stuff to improve... ;) Format 1. Whitespace You seem to have a lot of whitespace going on, many times without a particular ...

View answer
Checking whether number is in given range
Accepted answer
1 votes

I fully concur with @TimothyTruckle on format, follow his advice. Using binaries is restrictive (only two states), and not user-friendly. I don't like byte arithmetics, its quite un-Java like. I ...

View answer
Improving this TileMap
1 votes

Good Style Good, consistent style accross the files. Excellent spacing, very easy to read. Top notch! Now I'll get meaner, sorry! Missing bits Please include the complete class declaration in your ...

View answer
Test and implementation of a reorderable data structure that stores number of users (classifiable as per gender, country, etc.) of an Application
1 votes

I liked the idea of dynamic, controlled classification of a bunch of objects. So I went through your code, so here we go. This is buggy First off, the Tree implementation wasn't one, I had to fix ...

View answer
Reading properties from file during standalone application startup
1 votes

Other answers are very good regarding your question. There isn't an issue yet in your code, but I found something I think you should do with the catch block: it is a very good idea to enforce going ...

View answer