RubberDuck
  • Member for 7 years, 9 months
  • Last seen this week
Generic queries and handlers without reflection
2 votes

It's unrelated to your primary concern, but this pattern shows up in most of the code you've shared with us. public class HelloQuery : IQuery<HelloQuery, string> { public HelloQuery(string ...

View answer
Selecting from a database into a DataGridView
0 votes

I'll try not to rehash what others have said already. Indentation matters. The harder it is to read the code, the harder it is to maintain. Everything inside of Sub...End Sub should be indented one ...

View answer
Down with FizzBuzz... LOL
50 votes

I really can't believe I'm reviewing lolcode right now... The specification does allow for variables to be any case, but all existing documentation uses lower case for variables. So, lowercase ...

View answer
Lexer written in Rust
Accepted answer
2 votes

A couple of general notes: I’m not sure why you used a macro for peek_char!. I’m relatively certain this could have been a standard function. Take some time to learn about slices. You have a single,...

View answer
Shoe shine shop model in Rust
7 votes

You’ll often hear Haskel programmers talk about making invalid states impossible to express. The Rust community has taken this to heart and developed a state machine pattern that uses structs and ...

View answer
Most idiomatic way of declaring a deck in Rust
2 votes

You’ve made a fairly classic mistake when it comes to modeling cards in software. Cards have different values depending on the game. In some games, an Ace == 1, others 11, sometimes it could be either ...

View answer
Find the first missing positive integer in an array of integers
2 votes

Performance and readability are often a trade off. This \$O( n \log n)\$ solution just misses the \$O(n)\$ target, because we must sort the pre-filtered array, but it’s much easier to reason about a ...

View answer
Number to vector of its digits
2 votes

First thing's first, you probably don't want to leave the #[allow(dead_code)] option on. If the method is meant to be part of the public API, make it pub. It's also best to split your tests up into ...

View answer
Pulling images from Windows 10 Lock Screen to a different folder
Accepted answer
2 votes

A couple of general notes. The app directory should be consistent. It’s a UWP app and this is part of the app package family name. Your implementation is fine though. I would take advantage of some ...

View answer
Traceroute implementation in Rust
1 votes

I love your program’s entry point. Nearly all of my F# CLIs have an entrypoint that look nearly identical. However, Rust will automatically convert a Result into an exit code for you. You can get rid ...

View answer
Temperature calculator in Rust
2 votes

use std::io; fn main() { println!("Enter Temperature as 56f or 98c"); let mut usr_inpt = String::new(); io::stdin() .read_line(&mut usr_inpt) .expect("can not read ...

View answer
Encoding and decoding log entries in a Lossy Binary Format
1 votes

At a quick glance, I could nitpick about how I think K&R (Java) style braces are cleaner for type definitions or that hex literals are better than binary literals, but that’s really my own ...

View answer
Apply discount changes with Strategy pattern
5 votes

x and y are really bad parameter names. I had to look at the client code to figure out that these were actually cost and quantity.

View answer
CLI helper in Rust
2 votes

A couple of things pop out at me. Prefer `Iterators‘ over “raw” indexing for loops. Instead of this for i in 1..input_arguments.len() You can just loop over the arguments. for argument in ...

View answer
Crontab datetime field pattern parser in Rust
Accepted answer
1 votes

I’d go out on a limb and call this Good Code™️. I’m easily able to follow all the logic. It’s fairly idiomatic, using map/reduce instead of loops and pattern matching. The tests are all super tight ...

View answer
Laptop battery level monitor for Linux
Accepted answer
4 votes

Unwrapping options is probably fine for this simple little app that only you’re using, but it dumps out a panic if the result is None. I like your use of expect better. That can give a nicer error ...

View answer
Get The Base Name of an Elixir Template File
Accepted answer
5 votes

Since you seem to know what the file extension is, you can use Path.basename/2. "foo.html.eex" |> Path.basename(".eex") |> IO.puts If you don’t know the file extension, you can use Path....

View answer
MVP Passive-View
Accepted answer
6 votes

Your view is calling methods on your presenter. The view shouldn’t know the presenter exists. Instead of calling the presenter directly, the view should raise events that the presenter reacts to. The ...

View answer
QuickSort in Java with Lomuto Partition or Hoare Partition
1 votes

public static void main(String... args) { int array[] = {2, 3, 4, 1, 11, 5, 7, 0, 10, -1, 99, 23}; quickSort(array); System.out.println(Arrays.toString(array)); } I like that you're ...

View answer
Generate and validate EAN-13 barcodes
Accepted answer
0 votes

I’m just going to go line by line through part of your calculator class. namespace Ean13Calc { public static class InternationalArticleNumber13Calculator { Good name for the class. Very ...

View answer
Function for approximating a sine signal
7 votes

I'm interested in how to optimize this code regarding memory consumption and performance. Well, which is it? Are you optimizing for speed, ram, or executable size? You say this is for an embedded ...

View answer
Sum of multiples of 3 or 5 using functional programming
Accepted answer
6 votes

This is fairly good for someone fairly new to FP. You seem to have quickly grasped the idea of function composition and lazy evaluation. I would take a slightly different approach though. You're ...

View answer
Determine hour in other countries with generated random time
3 votes

This is a very naive solution. There's more to consider than just the hours offset. What happens when it's daylight savings time in London, but not in New York? You'll be off by an hour. You can ...

View answer
LINQ-inspired recursive file search
5 votes

As someone who's been writing cross-platform tools on .Net Core, this doesn't do what I expect it to do. finder.TargetDirectories.Add("/src"); I expect that to target a directory named src at the ...

View answer
Web API for reading file system
2 votes

_currentId++; Are you sure your id system works as expected? If I recall correctly, a new controller instance is created for each request. That means the id will get incremented, the class will go ...

View answer
C# API Wrapper with Static Function Calls
2 votes

public static void Initialize(string key,string url) { APIClient.url = url; APIClient.apiKey = key; } This is a dead give away that this class shouldn't be a bunch of static ...

View answer
Diff comparison for List<string>
7 votes

I wouldn't want to maintain this code. Unless you have proven that this code is a performance problem, do the simple thing. Yes, the following solution will iterate over the lists 3 times. No, I don't ...

View answer
Walking Git History
3 votes

public abstract class Visitor { public delegate void VisitedHandler(CommitVisitor visitor, Commit commit); Well, having your abstract class rely on its inheritors like that makes it pretty much ...

View answer
ServiceLocator for easy and central access to replaceable parts
Accepted answer
1 votes

You have some clean looking code there, but there's a huge problem with Service Locators. They're hidden dependencies. If I reference your class from elsewhere, I'm going to be really confused about ...

View answer
REST API for user access using ASP.NET Core
2 votes

It's best to have your controllers run async by declaring them like this. [HttpGet] public Task<IActionResult> Get() The server still has to wait for the entire request to be ready ...

View answer
1
2 3 4 5
19