53 votes
Accepted

Counting rows in a CSV file that correspond to a database row, each with a million records

Your inner loop appears to be unnecessary. Why not create a lookup: ...
user avatar
  • 16.6k
20 votes

Singleton Database class

You shouldn't be sharing Connection instances, because ADO is already doing the job for you, it uses object pooling behind the ...
user avatar
17 votes

Marijuana information program

...
user avatar
  • 25.2k
17 votes

Console Library System in C++

Make variables and functions const where appropriate You used const references in a few places, but you missed a lot of ...
user avatar
  • 33.4k
14 votes
Accepted

My database class extends MySQLi

Note: I don't think this is what you want to hear. But I have to write "the truth". This is my personal opinions about your code. Give me parameterized SQL or give me death! tell me if ...
user avatar
14 votes

Counting rows in a CSV file that correspond to a database row, each with a million records

The code appears to be broken, you're not break;ing after finding a match so all records will likely have row[12] == "N". You ...
user avatar
  • 2,864
13 votes

Marijuana information program

...
user avatar
  • 25.2k
13 votes
Accepted

Generalization of any() function with switchable default parameter for empty iterables

I really think this is a bad idea. A function called any returning True if there not only isn't anything true but even not ...
user avatar
  • 3,981
12 votes
Accepted

Simple customer program in C (using binary files)

I see a number of things that may help you improve your code. Eliminate function prototypes by ordering Since you put the acadd and ...
user avatar
  • 64.4k
11 votes

Database Handler Class

Security This code is not secure. SQL Injection You are trusting the user input completely (except in the login function where you do use ...
user avatar
  • 24.9k
11 votes
Accepted

Simple text DataBase

Reduce duplicated logic by using helper methods Instead of repeating this condition: if (file.getName().endsWith(mime)) { Use a helper method: ...
user avatar
  • 107k
11 votes

Singleton Database class

Just commenting on ... the comments in the source (sorry): I think they add a lot of noise, and don't provide any improved clarity (in this case). They're mostly restating what the following line of ...
user avatar
  • 530
11 votes

Inserting a DBNull value into a database

The most terse and declarative way to write this is to use C#'s ?? operator. Your line becomes: ...
user avatar
10 votes
Accepted

Key value flat file system - single header INI replacement

Let's start with your priorities: optimization. You should be primarily optimizing for the most expensive and limited resource, which is almost always developer brain cycles. You optimize for that ...
user avatar
10 votes

Creating Original Database Algorithm--Login System

It looks like passwords are stored in plain text form in the pswd.txt file. Never ever store passwords in plain text form. Store passwords salted and cryptographically hashed. That way, if an attacker ...
user avatar
  • 107k
10 votes
Accepted

Generic asynchronous SQLite search builder

Reflection is slow. That line probably doesn't help your performance : var model = (T)Activator.CreateInstance(typeof(T)); I notice that you always create your ...
user avatar
  • 12.3k
10 votes
Accepted

Inserting a DBNull value into a database

All you have to do is to use the ?: (ternary operator): ...
user avatar
  • 43.8k
10 votes
Accepted

Reducing the amount of duplicated code (python) - cricket matches

Disclaimer: I know nothing whatsoever about the rules of cricket. Useless check Because either info['toss_decision'] equals ...
user avatar
  • 28.7k
9 votes
Accepted

Example script for teaching DDL and CRUD/DML operations

Also said before, but I think it worth mentioning again: there is not need for prefix_ for all columns. As far as I know, Hungarian and Leszynski notations are not exactly recommended. Since column ...
user avatar
  • 1,786
9 votes

Event scheduler in C

Self-documenting code char h1 = { (e.hour / 10) + '0' }; // Extract the first digit and convert to char (if any, else 0) As you considered the division by ten ...
user avatar
  • 27.2k
9 votes
Accepted

LinDB: A dictionary type database

Both impressive and ambitious! Passwords the absolute requirement of a 32 character long password ensures it will take a considerable amount of time to break the encryption It will also ensure that ...
user avatar
  • 49.7k
9 votes

Generalization of any() function with switchable default parameter for empty iterables

Any and All If you are going to override any(...) to return a custom result when given an empty iterable, you should also override ...
user avatar
  • 30.8k
9 votes
Accepted

Embedded IoT: local data storage when no network coverage

We're missing an include of <stdint.h> in the header, and <stdbool.h> in the implementation. Some parts of the code ...
user avatar
  • 57.9k
8 votes

Having a class return a single database instance or list of all database instances

First, I don't like the concept of mixing "Models" with "Repository". One principle that, from my point of view, should be followed, is the Single Responsibility (the S in SOLID). It means that one ...
user avatar
  • 81
8 votes
Accepted

Summing the prices from Transaction files

Nitpicks There is a slight amount of inconsistency in your capitalization of keywords. SUM() / sum() and ...
user avatar
  • 20.3k
8 votes
Accepted

Manage connection without 'using' statement

I can understand why you want to remove the clutter from your code - but sharing the instance of MySqlConnection isn't a good idea. As soon as multiple threads are ...
user avatar
  • 16.6k
8 votes
Accepted

Creating Original Database Algorithm--Login System

In your function pick_password, you should close the file at the end of the file because this frees up any system resources that were being devoted to working with ...
user avatar
  • 13.2k
8 votes

Marijuana information program

Everything is a String Welcome to Java and object-oriented programming! You are doing something really strange in Java in your ...
user avatar
  • 19.1k
8 votes

Use PreparedStatement to insert into H2 database

There are some things to improve in this code. Especially when it's underlined that "if it can be maintained later on". SQL query The columns where the data will be inserted should always be defined,...
user avatar
  • 3,627

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