24
            
            votes
        
            
                
                Accepted
            
        
            
            
        FIFO data structure in pure C
                    None of your QUEUE_* functions validate their input arguments before using them.  NULL pointers will be a problem, particularly ...
                
            
       
        
            
                24
            
            votes
        
        
            
            
        AsyncDictionary - Can you break thread safety?
                    The reason why there is no async API for a dictionary is, that all operations on a dictionary are so fast, that there is no need for asynchronicity.
For concurrent scenarios there is the thread safe ...
                
            
       
        
            
                18
            
            votes
        
            
                
                Accepted
            
        
            
            
        Unit testing Video Service class
                    Welcome to code review and thanks for sharing your code.
When writing UnitTests keep in mind that they are documentation. 
Test code has less restrictions for identifier names.
This means that method ...
                
            
       
        
            
                15
            
            votes
        
            
                
                Accepted
            
        
            
            
        Triangle area computation and linear transformations
                    Here are a few of the high- and low-level ideas:
too many comments. Remember, comments tend to age and outdate, they need to be maintained as the code changes. And, if they are over-used, they hurt ...
                
            
       
        
            
                15
            
            votes
        
            
                
                Accepted
            
        
            
            
        ExactlyOne extension method
                    Q&A
  Is the code readable?
ExactlyOne states very clearly what the method is supposed to do.
source is null seems odd to me ...
                
            
       
        
            
                14
            
            votes
        
            
                
                Accepted
            
        
            
            
        indexOf Boyer-Moore String Search algorithm
                    1. Bug
The code in the post does not work!
>>> index_of('abba', 'bba')
>>> # expected 1 but got None
Read on to see how you could have ...
                
            Community wiki
            
        
        
        
    
            
                14
            
            votes
        
        
            
        Secrets management, operational security, keeping API tokens hidden while streaming
                    Your main is a classic arrow anti-pattern. You can use guard clauses to make the code flat and easier to understand.
Bare excepts are normally not a good idea. Why ...
                
            
       
        
            
                14
            
            votes
        
        
            
        
            
                13
            
            votes
        
        
            
            
        FIFO data structure in pure C
                    This looks really nice! Here we go:
  Is the API well thought and idiomatic?
Mostly. For a library as simplistic as this, you probably want to avoid creating a special enum when returning ...
                
            
       
        
            
                13
            
            votes
        
        
            
            
        AsyncDictionary - Can you break thread safety?
                    Threading Design
Your implementation has a very intrusive lock for all read and write operations, using the SemaphoreSlim with max concurrency 1. 
...
                
            
       
        
            
                12
            
            votes
        
            
                
                Accepted
            
        
            
            
        Flatten an array of integers in Python
                    Python normally promotes duck typing, yours is more statically typed.
You may want to use yield, as your current code possibly uses more memory than needed.
You can ...
                
            
       
        
            
                12
            
            votes
        
            
                
                Accepted
            
        
            
            
        Program to see how many points lie strictly inside a convex polygon
                    Data types
Why not use a simple point struct instead of std::pair<int, int>? It doesn't have to do anything, just a simple ...
                
            
       
        
            
                12
            
            votes
        
        
            
        ExactlyOne extension method
                    mhmmm... I'm not so sure about this implementation. @dfhwze's points are valid but still, I find it's overengineered.
I prefer chaining these two alraedy available extensions that can do all ...
                
            
       
        
            
                12
            
            votes
        
        
            
            
        AsyncDictionary - Can you break thread safety?
                    It's pretty hard to break something that uses a global lock around everything. So this seems pretty thread-safe. But that doesn't answer the question of why you'd want to use this. 
Asynchronous ...
                
            
       
        
            
                12
            
            votes
        
            
                
                Accepted
            
        
            
            
        Binary Search given sorted array Unit test
                    BinarySearch
The BinarySearch class should be public since it contains utility methods that are generally useful. To do this, ...
                
            
       
        
            
                11
            
            votes
        
            
                
                Accepted
            
        
        Controlling the order of unittest.TestCases
                    A search for "python sort unit test order in method definition order" got me here, and the documentation isn't particularly useful either ("Function" it says, what is it passed, what is it expected to ...
                
            
       
        
            
                11
            
            votes
        
            
                
                Accepted
            
        
            
            
        Stopwatch dependency for unit-testing
                    I would not return IStopwatch from Start/Stop/etc. This IStopwatch is not an immutable Value Object, like String for example: it would be easier to set expectations by having just this:
...
                
            
       
        
            
                11
            
            votes
        
            
                
                Accepted
            
        
        Building Slack message
                    I've come back to this question about 4 or 5 times since it was originally posted, started writing up an answer, started doubting my alternative implementation, scrapped it, and then come back about a ...
                
            
       
        
            
                11
            
            votes
        
            
                
                Accepted
            
        
            
            
        Recursive search on Node Tree with Linq and Queue
                    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. Also,...
                
            
       
        
            
                11
            
            votes
        
        
            
            
        
            
                11
            
            votes
        
            
                
                Accepted
            
        
            
            
        Unit test for a maximum-finding function
                    I'm not a C++ developer, and can't comment on the details of the code. But I can comment on the test cases and the general style of the code.
A good test should be enough to recreate the code from ...
                
            
       
        
            
                10
            
            votes
        
        
            
        FIFO data structure in pure C
                    When you have queued a pointer you can never get that pointer again. It is also very difficult to know when that pointer has been dequeued. This is a recipe for leaks. 
Instead returning the pointer ...
                
            
       
        
            
                10
            
            votes
        
        
        
            
                9
            
            votes
        
            
                
                Accepted
            
        
            
            
        Simple Unit Test in C
                    Statement-like macros should normally be wrapped in do...while(0).  They should also avoid multiple expansion of arguments.  So ...
                
            
       
        
            
                9
            
            votes
        
            
                
                Accepted
            
        
            
        AsyncDictionary - Can you break thread safety?
                    If you modify the AsyncDictionary while enumerating its keys/values it throws InvalidOperationException (if the backing ...
                
            
       
        
            
                9
            
            votes
        
        
            
            
        Mocking pathlib.Path I/O methods in a maintainable way which tests functionality not implementation
                    Mocking system calls, especially those with side effects (mkdir()), is difficult and error prone.
I would rather use a temporary directory for test purposes. This ...
                
            
       
        
            
                9
            
            votes
        
            
                
                Accepted
            
        
            
        Mocking pathlib.Path I/O methods in a maintainable way which tests functionality not implementation
                    I'm no professional when it comes to testing. But it looks like your code is a perfect example on non-test friendly code. And is why SRP, single responsibility principle is such a big thing.
From my ...
                
            
       
        Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
unit-testing × 1059c# × 255
python × 206
java × 197
javascript × 88
object-oriented × 60
beginner × 59
python-3.x × 58
c++ × 51
mocks × 47
php × 43
junit × 42
ruby × 41
programming-challenge × 40
algorithm × 36
c × 36
strings × 36
performance × 34
interview-questions × 33
design-patterns × 27
linked-list × 25
nunit × 24
.net × 21
node.js × 21
dependency-injection × 19
 
         
         
         
         
         
         
         
        