Skip to main content
23 votes
Accepted

BinaryTree<T> written in C#

public class BinaryTree<T> where T : IComparable, new() I suspect that you are unaware of the possibility of writing ...
Peter Taylor's user avatar
  • 24.1k
13 votes
Accepted

Decided to update HttpWebRequest to HttpClient

var postResponse = _client.SendAsync(httpRequest2); var postResult = postResponse.Result.Content.ReadAsStringAsync().Result; Never use tasks like this, it leads to ...
Blindy's user avatar
  • 440
11 votes

Reducing contention in thread-safe LruCache

..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 ...
dfhwze's user avatar
  • 13.9k
10 votes

Bidirectional Dictionary

In general I find this implementation is OK. It uses internally two dictionaries as it should or rather must so there is not much to get wrong. What I do not like is the underscore naming convention ...
t3chb0t's user avatar
  • 44.3k
10 votes

C# Toy Robot Simulator

Your commenting style needs improvement Either you comment all methods or none This is generally not a good rule of thumb, but for coding tasks in a job interview setting can show consistency If ...
Markus Deibel's user avatar
10 votes
Accepted

Random temp folder implementation for unit testing

You could easily wind up with collisions on the folder name if the method is called multiple times in very quick succession because of the new Random() being ...
Jesse C. Slicer's user avatar
9 votes

Reducing contention in thread-safe LruCache

This is a neat little implementation. It's nice that LruCacheEntry is a private inner class. It does indeed look to be thread-safe in its current state. When ...
VisualMelon's user avatar
  • 7,431
8 votes
Accepted

Simple async task scheduler

No way to stop the cycle. The standard with TPL is to use the CancellationToken. Even if it is not need now, which I don't know why, it would be easier in the future if it supported it. For example ...
CharlesNRice's user avatar
  • 4,408
7 votes

Reducing contention in thread-safe LruCache

Cosmetics You can simplify your code by removing the generic arguments from LRUCacheEntry. Since it's a nested class it can use its parent class' types without ...
t3chb0t's user avatar
  • 44.3k
7 votes
Accepted

IEnumerable<T> async serialization

You have both IEnumerableStreamSerializer and EnumerableStreamSerializer, and in fact neither of them are used in the code you ...
canton7's user avatar
  • 216
7 votes

Bidirectional Dictionary

Much of what I wanted to say has already been said, but there's a few points I haven't seen being addressed yet: Why are the internal dictionaries lazily created? When someone creates a ...
Pieter Witvoet's user avatar
7 votes

C# Toy Robot Simulator

Collected thoughts: Your Helpers class is weird. It mixes e.g. command line input (GetArrayFromSplitInput) with a bad pattern ...
Colin Emonds's user avatar
7 votes

NewSequentialId - pure net core 2.2 implementation of sql server function

You want to reduce both computation time and memory allocation. Memory allocation itself takes time, so that's a good place to start -- try to find all the places where you're allocating memory and ...
Jeff's user avatar
  • 850
7 votes
Accepted

Example of why IReadOnlyList<T> is better than public List<T> { get; private set; }

The conclusion misses the point Your code technically does touch on what makes a list readonly, but the example you've used to display that behavior suggests a completely different problematic ...
Flater's user avatar
  • 5,542
7 votes
Accepted

Memory leak I can't identify using Bitmap and Graphics classes

Just few tips Prefer using over manual calling Dispose(). Consumed memory isn't always busy memory, GC can free the memory ...
aepot's user avatar
  • 2,019
7 votes
Accepted

HttpClient retry handler on response 429

Let me suggest here an alternative solution, namely the Polly's retry policy. This library is the Microsoft suggested way to decorate any HttpClients (normal, named,...
Peter Csala's user avatar
  • 9,279
6 votes
Accepted

Reading SQL query from a resource, with error logging

The most unforgivable aspect of this code is that it rethrows a degraded exception. The original type of the exception (likely an IOException) and the stack trace ...
200_success's user avatar
6 votes
Accepted

Usage of TPL vs Parallel.ForEach() on file processing

As seen with @t3chb0t and @dfhwze I have been misusing the TPL. I also don't see any point on .ConfigureAwait(false) a ...
Nameless's user avatar
  • 153
6 votes

C# Toy Robot Simulator

Styles and conventions The using should always be at the top of your file. Variable names like _f means...? Facing? Face? Force ...
IEatBagels's user avatar
  • 12.4k
5 votes

Reducing contention in thread-safe LruCache

Since I couldn't choose a single answer as the answer, I decided to compilte all the suggestions and comments made and show how the final class(es) looks. It still doesn't use ReaderWriterLockSlim, ...
Trauer's user avatar
  • 801
5 votes
Accepted

C# Toy Robot Simulator

I will try to focus on things that have not been said, but I apologise in advance if I have repeated something that has been mentioned in any previous answers. Separating your code into ...
Pharap's user avatar
  • 782
5 votes
Accepted

Dependency Injected StackExchange.Redis Client

I can share with you an example version of Redis service such as getting subscribers or accessing the other databases and also for catching connection issues. ...
Mustafa Salih ASLIM's user avatar
5 votes

Simple async task scheduler

Keep a single var now = DateTime.UtcNow; Initialize the check-tasks to Task.CompletedTask to get rid of all the null checks. ...
Johnbot's user avatar
  • 2,974
4 votes
Accepted

File path unified in Windows/MacOS/Linux

There are a couple of things that bother me: 1) I don't think you have properly implemented relative and absolute paths. At least in Windows: ...
Nikita B's user avatar
  • 13k
4 votes

Reading SQL query from a resource, with error logging

Would be incorrect to expect someone to pass an ILogger even if they do not intend to use it? If I wouldn't want to pass an ILogger I would just pass ...
Heslacher's user avatar
  • 50.4k
4 votes

Web-app for tracking containers

EF has zero compatibility with DDD. Any attempt to make your DDD code be suitable for direct EF mapping prevents you from implementing DDD solution – there is no way to do it directly. But any ...
Dmitry Nogin's user avatar
  • 6,131
4 votes

Web-app for tracking containers

I'll answer questions 3 & 4: Is it a good practice to throw an InvalidOperationEception or shall I use some other contract validation framework? I find that ...
t3chb0t's user avatar
  • 44.3k

Only top scored, non community-wiki answers of a minimum length are eligible