dfhwze
  • Member for 2 years, 8 months
  • Last seen more than 2 years ago
  • Belgium
"What is the maximum that Player 1 can win?"
22 votes

Usability I have a remark about defining recursive functions. You don't want consumers of your API to think about the intermediate variables and their initial value. The consumer does not care you ...

View answer
Create two random teams from a list of players
18 votes

Review Don't use the main entry point to implement an algorithm. Create a method instead. Think about how to allow this method to be usable for all kinds of types, not just integers. You have ...

View answer
ExactlyOne extension method
Accepted answer
15 votes

Q&A Is the code readable? ExactlyOne states very clearly what the method is supposed to do. source is null seems odd to me (does that even compile?). I'd prefer source == null. (Edit from ...

View answer
AsyncDictionary - Can you break thread safety?
13 votes

Threading Design Your implementation has a very intrusive lock for all read and write operations, using the SemaphoreSlim with max concurrency 1. try { await _semaphoreSlim.WaitAsync()// <- ...

View answer
Very basic singly linked list
Accepted answer
13 votes

size++ should be extracted from both branches and called only once there is no need to cache instance variables where local method variables should be used instead: newNode,oldNode,displayNode prefer ...

View answer
Get the encrypted payload from an unencrypted wrapper PDF document
12 votes

Positive Changes getReader() is only called once, while called multiple times before. There are more early exits as before, which results in less nested and lesser deepened nested statements. Method ...

View answer
Repetitive validation of Console inputs
11 votes

As you suggested, you have a lot of redundant code. And rightfully so you want to adhere to the DRY principle. All these input methods have the same pattern internally.. static void Main(string[] ...

View answer
Reducing contention in thread-safe LruCache
11 votes

..but I expect that most 4/5 cache accesses will result in a hit, and 1/5 in a miss followed by an add. You are not exposing your sync root _lock, meaning this class isn't thread-safe for consumers. ...

View answer
C# TCP server/client class
10 votes

Review This review handles readability metrics and C# conventions only and should provide insights to reach some of your goals. Goals: learn C#, improve coding style, create good to read code ...

View answer
Bouncing map back into its bounds, after user dragged it out
Accepted answer
10 votes

Readability Mainly looking for readability improvements/getting rid of those double ifs. Since you are considered about readability, I will focus on that part. Declare a flags enum on multiple ...

View answer
Recursive search on Node Tree with Linq and Queue
Accepted answer
10 votes

Reading Material .. any reading material about searching algorithms on trees These are the most common tree walkers: Breadth-First Search Depth-First Search Review There is a bug with IsRoot. ...

View answer
Asynchronous Circular Buffer in C#
10 votes

Quick Review An API like this, dealing with thread-sensitive operations, requires time and effort to test and review rigorously. When I will find this time, I will do a thorough review. But here are ...

View answer
Modeling and computing intersection between continuous intervals
9 votes

Review You are constrained to float which makes your class only usable for a limited number of scenarios. I would like to be able to work with int, double, DateTime, MyCustomEntity, .. You should not ...

View answer
General purpose replacement for enum with FlagsAttribute
9 votes

Is this as extendable as I think it is? Does it work for multi-bit flags? For instance [Flags] enum Modifiers : uint { None = 0, Private = 1, Protected = 2, Public = 4, NonPublic ...

View answer
Letter Combinations of a phone number using a Dictionary
8 votes

Review LetterCombinations returns an IList<string> but I see no reason to return a modifiable collection. Consider returning IEnumerable<string> instead. A method's name should be a verb. ...

View answer
Confirm the ending of a string
8 votes

Review You have a bit too many variables to my taste, but that's not much of a problem. let lengthOfString = str.length; // is a variable that useful here? I would use const instead of let because ...

View answer
Non-Entity framework database interaction model
Accepted answer
8 votes

Application Architecture The architecture of the application is divided into models and views to separate the data and business model from the user interface. Within the models there is an ...

View answer
String whitespaces
Accepted answer
7 votes

Usability I would have expected Optional to transform null and whitespace only content into String.Empty, not the around way around. Optional(string text) => Text = IsNullOrWhiteSpace(text) ? ...

View answer
Generic method to call API functions with simple retrial on errors
Accepted answer
7 votes

Inversion-of-control I wouldn't use reflection using error-prone member-by-string lookup, when a simple Func provides type-safe behavior. This signature could be used to have the error callback, ...

View answer
Science Fiction Wall of Fame (Shame?)
Accepted answer
7 votes

Problem Statement Tiered Architecture This database is the first part of the project, I couldn’t really create a friendly user interface until the database is working. Due to feature creep ...

View answer
HackerRank: Electronics Shop
7 votes

General Guidelines You have coded everything in a single class Program. Take advantage of the fact C# is an object oriented language. Create at least one custom class that defines this problem. Your ...

View answer
Find smallest index that is identical to the value in an array
7 votes

Review Your solution naively walks the array of ascending integers from starting position s = 0. In some situations, this means you are walking tons of negative numbers, knowing they can never match ...

View answer
Drone Delivery Scheduling Service
Accepted answer
7 votes

There are some basic considerations to make in your design. Guard arguments Perform at least NotNull checks on arguments on public entrypoints of your API. public OrderDeliverer(Warehouse warehouse,...

View answer
LeetCode: Symmetric Tree C#
Accepted answer
6 votes

Performance The recursive function is as fast as I can think of. The iterative function should enqueue root.left and root.right instead of root and root to gain a cycle (micro-optimisation). Review ...

View answer
Call center escalation excercise, using Chain of Responsibility pattern
Accepted answer
6 votes

Review Well done, there isn't much I would change in this implementation. I would grant you the humble badge for putting yourself as LowLevel employee :) The lazy and null pattern are well ...

View answer
Generate points for smooth movement between two given points
6 votes

Dividor dividor is ill-defined. It acts as a factor for quantization: xi = xi / divider; But also as threshold for yielding smoothed results: for (int i = 0; i < divider; i++) While this ...

View answer
Immediate Smaller Element Time Limit Exceeded
Accepted answer
6 votes

Things to improve You are looping over the input twice; (1) when splitting the raw input string Console.ReadLine().Trim().Split(' ') (2) when going over the splitted items for (int i = 0; i < ...

View answer
Reimplementation of min() in Python
6 votes

Review I should check for the list having no elements anyway, so I could check for its having only 1 element and return that element You have implemented a simple function, so it shouldn't have ...

View answer
LeetCode: Linked List Cycle
Accepted answer
6 votes

Performance You have implemented Floyd’s Cycle-Finding Algorithm which adheres to \$0(1)\$ storage space. An alternative exists Brent’s Cycle Detection Algorithm which uses the same storage space. ...

View answer
TreeView class in WPF class
Accepted answer
6 votes

Review I see no reason to have 3 constructors, each invoking the other, when two of them are private and only called by another constructor. Keep it simple. You check for if (Nodes == null) in the ...

View answer
1
2 3 4 5
13