26
votes
Accepted
Validating Credit Card Numbers
First of all, you should encapsulate your functionality in a function, unless you really want to use your code only once. At the moment you would have to duplicate your code somewhat just to check a ...
20
votes
Accepted
Financial website scraper
Here a few suggestions (in no particular order) for improvements on your code:
Make variables have locality
The line:
items = 1
is at the top of the method, ...
16
votes
Accepted
Selecting an enum for a payment transaction
You're using the wrong tool for the job.
If there's ever going to be a loan that I will pay an amount to every week for 2 years, you're gonna have to write a script to generate the code for you, ...
16
votes
Accepted
Basic Python OO bank account
Python doesn't have private anything but we still have a need to separate inners of a class from the public interface.
By convention, attributes or methods whose name starts with a single underscore ...
16
votes
Financial website scraper
In addition to what @StephenRauch wrote in his excellent answer, let me add one more comment:
Your class is completely useless. Not its functionality, which is fine, but it being a ...
15
votes
Accepted
Stock control system
Start using New IO
The java.io packages have been replaced for a reason. They don't integrate well into what the language tries to become and are at best unwieldy. ...
14
votes
Accepted
Operations to a bank account
Account Structure
Since it looks like you are trying to model the bank account slightly more realistically than a typical getting started tutorial, I'd like to address the conceptual structure of ...
14
votes
Basic Python OO bank account
In this answer I'm not going to review your code, but instead discuss the design of a book-keeping system. (I know that you're just using a bank account as an exercise, but an important part of ...
13
votes
Money class with overloaded operators
This is way too complicated. You could have just the cents as a member and have some helper functions that converts it to the respective parts. This will simplify ...
12
votes
Accepted
SalesTax problem (C# version)
A couple of small suggestions.
Var:
You spend a lot of time redeclaring variable types when they are already well established by your code. For example:
...
12
votes
Safely convert dollars to cents
I don't like the 3 argument return you're doing. You're using status and msg to actually do the same thing. They both return a ...
12
votes
Validating Credit Card Numbers
You can do most of this with regex. Going through your requirements:
It must only consist of digits (0-9).
And so we can use [0-9] for each digit.
It must ...
11
votes
Stock control system
Firstly, I'm not familiar with the JavaFX nor PostgreSQL technologies, so my comments will be aimed more at Java-specific code practices. See also the answers by Vogel612 and Antot.
Use "try-with-...
11
votes
Accepted
Enumerate list with filter criteria
I will assume that the CreditCard class is set in stone, otherwise I probably would store a DateTime in it and calculate ...
11
votes
Accepted
Simple budget program
Here are the few things I've noticed after a first glance on the program:
import os is not used, you can remove it
() after the ...
10
votes
Stock control system
I totally agree with Vogel612's observations.
Since there is a lot of code for this review, I'd like to add a couple of items.
DatabaseAdapter Class
In ...
10
votes
Operations to a bank account
Don't catch NullReferenceException, this is a programming exception, it shouldn't happen when to code is running if you're doing ...
10
votes
Operations to a bank account
You have some noise in your code:
string iban = Console.ReadLine();
return iban;
and
...
9
votes
Accepted
How to use PHP Visibility method?
Yes, the original code is awful. It is 200 lines of spaghetti code; I have no idea what it does, it is impossible to reuse and extremely difficult to test, debug, or change.
That doesn't necessarily ...
9
votes
Basic Python OO bank account
In Python you can have multiple functions and classes in a single file (module) but is it considered bad practice to do so?
You can write as many functions and classes within a Python module as ...
8
votes
Basic mortgage calculator
"math.h" should be <cmath>. The brackets are for system libraries whereas the quotes are for user-defined headers. The ....
8
votes
Accepted
Convert an amount to Indian Notation
1. Style guides
leave two empty lines before each function (when you're not inside of a class)
Python is not C; don't use ;
put a space before and after operands. <...
8
votes
Financial website scraper
You should also split the code in functional parts, and not mix the IO (print(...)) with generating the result
base_url
First you generate the base_url
...
8
votes
Bank Management System
I see a number of things that may help you improve your program.
Use the required #includes
The code uses std::find which ...
7
votes
Accepted
Calculating the daily profit of a clinic
Break your code into methods if a code line in one method is more than 30 characters:
...
7
votes
Credit Calculator
Loop logic
There's definitely something strange going on with your looping. Why do you have so many checks on accnum equalling zero? Why do you ask for account ...
7
votes
Accepted
Bank account model implementation in Django
In general this seems fine, easy to read, you seem to be following PEP8, that's excellent.
At first look, this repeated logic in balance and ...
7
votes
Bitcoin trading system
In these screening situations, you only get a few seconds to make a good first impression. Unfortunately, this line already makes a bad impression:
...
7
votes
For a given balance and an annual interest rate, calculate the minimum fixed monthly payment to pay off debt in a year
This is a problem that can be solved exactly with a little math, so there should be no need to program a search.
Suppose that we borrow initial capital \$c\$ at a monthly interest rate \$r\$, paying ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
finance × 262python × 65
java × 55
beginner × 42
c# × 31
c++ × 28
object-oriented × 23
calculator × 20
performance × 19
javascript × 16
python-3.x × 16
php × 16
validation × 16
homework × 14
sql × 11
algorithm × 10
pandas × 9
python-2.x × 8
ruby × 7
interview-questions × 7
c × 6
programming-challenge × 6
multithreading × 6
unit-testing × 6
web-scraping × 6