Jeroen Vannevel
  • Member for 9 years
  • Last seen more than a week ago
Android "Search" Activity and corresponding XML
Accepted answer
10 votes

Initializing should be done automatically from your constructor. Right now you're exposing it as a public method that may or may not get called: this will guaranteed cause problems when someone ...

View answer
Problem: Traffic Flow
Accepted answer
10 votes

Naming I strongly recommend you read through the official C# naming conventions. Here are a few rules to keep in mind: Properties are UpperCamelCase Private fields are lowerCamelCase, sometimes ...

View answer
Tracking sports statistics
9 votes

I made a small example to show you that all your worries are in the past. Before you implement this yourself though, keep Mat's remarks in mind: I made this as a quick sketch and separating the ...

View answer
Circular queue implementation
9 votes

Explicit visibility I don't like relying on standard visibility; explicit declaring takes away all doubts. Instead have this: private int[] queue; private int front; private int rear; private int ...

View answer
ASP.Net caching manager
9 votes

try { if (!Exists(key)) { value = default(T); return false; } value = (T) HttpContext.Current.Cache[key]; } catch { value = default(T); return false; } ...

View answer
Custom Exception.ToString() formatter
Accepted answer
8 votes

private const string Space = " "; There's little point in storing this in a variable: it's never going to change anyway and you're not clarifying any of the intent. I'm fully aware that is a space ...

View answer
Putting everything in its place
8 votes

While reading my code for the bazillionth time, I noticed a logical error which would make it possible for very specific exotic scenarios to pop this up expectedly. At the very start of the analyzer ...

View answer
Injecting JavaScript to website for ordering products
8 votes

Alright, let's go through the code top-to-bottom. using Brushes = System.Windows.Media.Brushes; using SystemFonts = System.Windows.SystemFonts; Any particular reason you're using this alias? Most ...

View answer
Pagination implementation for a blog system
Accepted answer
8 votes

int num What does num represent exactly? Number of pages? Number of posts per page? Current page number? Properly naming the variable would help a lot in clarity here. var postsPerPage = 3; Turn it ...

View answer
Checking if 3 numbers are an arithmetic progression
8 votes

InOrderEqual() Methods should express an action or a state, this doesn't do that. How about.. VerifyOrder? Or IsInOrder? InOrderEqual(2, 5 , 11, false) I would suggest using a named argument for ...

View answer
Getting a substring of a delimited string
Accepted answer
8 votes

Yes, you can definitely simplify this. public string GetSubstring(string input, int count, char delimiter) { return string.Join(delimiter.ToString(), input.Split(delimiter)...

View answer
Stack with getMin method
Accepted answer
8 votes

Yay, you use tests! Darn it, you don't use tests. Confusing? Allow me to explain. While I totally approve of you using tests, there is a lot more to it than simply putting the @Test annotation above ...

View answer
Complex search program
8 votes

Comparing strings case insensitively is done by using the proper overload: string.Compare(str1, str2, StringComparison.OrdinalIgnoreCase) By calling .ToLower() for each string to compare (4 times ...

View answer
Refactoring String manipulating method with TDD
8 votes

Your tests are named horribly; make sure they convey what is being tested. Your code makes it look as if you're testing some helper method inside your tests. What exactly is going on? Make sure that ...

View answer
When a constructor calls a helper function, should the helper mutate the object or return part of the object?
8 votes

Consider it is just an initializer and will only be used this once, there is no need to make it explicitly return the data when you can just set it directly. Therefore the second approach would be my ...

View answer
What is the advantage/disadvantage of using default initializer for private fields?
Accepted answer
8 votes

There are no differences between your two options. There are a few remarks we can make about though: Consistency Keep everything consistent. There are a few reasons to change it up (for example: you ...

View answer
Educational website using ASP.NET webforms
Accepted answer
7 votes

private class Comp_CatName_D : IComparer { public int Compare(object x, object y) { BusinessLayer.Cat_Table Cat_Table1 = (BusinessLayer.Cat_Table)x; BusinessLayer.Cat_Table ...

View answer
Mathematical functions on fractions
7 votes

This is in addition to Simon's remarks. It's good practice to validate arguments as the first course of action in the body. Therefore I would suggest this instead: Fraction (int numerator, int ...

View answer
Simple image capture program
Accepted answer
7 votes

Considering there is almost no code to review, this will be purely stylistic. Remember that criticism is a sign of love. /// <summary> /// Interaction logic for MainWindow.xaml /// </summary&...

View answer
Wiring CollectionView and updating itself without the need for Refresh()
7 votes

One thing that jumped out at me is this: private bool PartsFilter(object item) { var editPartViewModel = item as EditPartViewModel; return PartsSearchFilter(item) && ...

View answer
Sieve of Eratosthenes implementation is running slowly
7 votes

You're using a List<T> and executing .Contains() on it. In a list, this will iterate over all the values which ends you up with O(n) time each time the inner loop runs: obviously very slow. ...

View answer
Implementing a queue in Java for a technical interview
Accepted answer
7 votes

You don't have a parameterless constructor which forces each queue to be instantiated with 2 elements. This isn't userfriendly since I might very wel want to construct it first and then add 5 ...

View answer
"Guess my number" game in Java Swing
Accepted answer
7 votes

Layoutmanagers You're using absolute positioning for all your elements which won't scale well when you enlarge or shrink the application. For this reason you should use a layoutmanager that will ...

View answer
Initial starting player
Accepted answer
7 votes

Your code is indeed confusing, primarily because of the naming: f should be firstPlayer, s should be secondPlayer and curSpeed should be speed or currentSpeed (it depends on whether there are other "...

View answer
"Guess a number" game in Java
Accepted answer
7 votes

First of all: I appreciate the clarity of your code. Variables have good names which causes the code to be read very fluently. Intendation, spacing and whitelines are also very well done so that's a ...

View answer
Cleaning up and commenting on my code for Pong game
Accepted answer
7 votes

As you noticed: it's hard to force comments when the code is written well. Once you get rid of magic values, create descriptive names for both variables and methods and make sure each method does one ...

View answer
Searching text files for string patterns that are each defined in their own classes
7 votes

It's very easy: you shouldn't. An interface is used to indicate that a subset of classes present common behaviour or should be considered similar in some way. In your situation there simply is no ...

View answer
Unit Testing the Duck
Accepted answer
6 votes

I don't believe a Semaphore is needed in the first place. Remove it, register an event handler and continue your "act" and "assert" phase inside it. Something like this: parser.State.StateChanged += ...

View answer
Get list of files in directory with exclude option
Accepted answer
6 votes

You're already returning an IEnumerable<T> so you might as well turn it into an iterator block. Discard the local resultFiles and simply use yield return filename. MSDN on yield I don't like ...

View answer
Displaying a video player to eligible users
Accepted answer
6 votes

What you call "underscore functions" are actually the result of a few principles including separation of concerns, single responsibility and sure, there is some encapsulation involved as well but that'...

View answer