jpmc26
  • Member for 8 years, 8 months
  • Last seen more than a month ago
Python program to take in two strings and print the larger string
28 votes

Limit execution to main module It is customary for code that starts executing a series of commands to be surrounded in a special if-block: if __name__ == '__main__': ... This prevents the code ...

View answer
Git delete all merged in local branches
Accepted answer
16 votes

Improve your file handling: Don't use a hard coded file name for temporary files. Don't spew temporary files into the current directory. Make sure you clean up temporary files even on error. The ...

View answer
Compiling and throwing simple dynamic exceptions at runtime
11 votes

Surprising This is a gross violation of the Principle of Least Surprise. The only possible reaction I could have seeing this in the wild would be, "What the heck?" This is not a normal way of using ...

View answer
Own implementation of Lazy<T> object
10 votes

Meaning that I have to put half of my logic concerning the lazy property in the constructor, and having more boilerplate code. This is a little speculative, but I think you have an XY problem. You're ...

View answer
Simple Python Dice
8 votes

You spent 55 lines and a stateful class on something that can be accomplished in 3 lines (1 line if you don't count the imports) using only standard library functions: from functools import partial ...

View answer
Simple Oracle connection using JDBC
Accepted answer
8 votes

Minor detail: I prefer putting a closing parenthesis on its own line when the content between parentheses spans more than one line. (Basically, it looks like one-true-brace style with parentheses ...

View answer
Implementing a customized helpful hints function which includes docstring but much shorter than Python help()
Accepted answer
7 votes

I'm not sure whether you're reinventing the wheel, but you are using the wrong tools for the job. I've been through the phase where I think I'm doing something unique enough that I need to do ...

View answer
Skipping over failed imports until they are needed (if ever)
6 votes

Whenever you find yourself trying to replace a standard language feature, the first thing you should think is, There's probably something I'm missing. What's the standard approach to this kind of ...

View answer
Password maker in C#
4 votes

Most of your variables should be static readonly There is no reason to new up a brand new copy of the arrays of characters each time you run this function. Instead: public static readonly ...

View answer
Creating HTTP proxies for services
3 votes

Too much indirection Your public methods, e.g. CreateMasterClient, already tell you which type the caller needs. When you design the shared private method the way you have, you add a lot of ...

View answer
PHP gaming community website
2 votes

Too many things in one page You rely primarily on query string parameters to distinguish between the different actions the user is requesting. The modern trend is to instead set up different ...

View answer
Versatile string validation
1 votes

Stop it. Just stop it. Unless you have some kind of unusual performance requirements, keep it simple: /// <summary> /// Regular expression pattern that matches strings containing only Unicode //...

View answer
Adding 0 to a balance on an object
1 votes

Don't. There is no advantage to making this function single line. You have two distinct operations, and keeping them separate makes the function much clearer. You gain nothing by making it single ...

View answer