8
votes
Shopping Cart design interview task
I won't add to @mtj's comment (I totally agree that an array defined as a means to exchange information is a code smell).
I agree with @RobAu that you should stay far a away from those magic numbers ...
8
votes
CS50 pset1: credit card classification and checksum validation
Two more things about identifying the issuer
(pacmaninbw's report_card_issuer()/the last part that seems too long):
There is a lot of common parts
• in the ...
7
votes
CS50 pset1: credit card classification and checksum validation
Avoid wasting time with hostile input
Whenever there is a upper length bound to string validation, to efficiently guard against hostile input like ...
6
votes
Accepted
CS50 pset1: credit card classification and checksum validation
You should break the code up into functions, one of the functions should be to check if each character is a digit and that function should return a bool value that indicates success or failure. In the ...
5
votes
Accepted
Credit card validator code in Python
You are having a lot of code duplication in the second part, for all the different card vendors. Use the different if blocks just to determine the vendor and store ...
5
votes
Shopping Cart design interview task
Three points which immediately strike out to me:
Mutable double array in the interface. Yuck! This is unclear, hard to read and generally leaves a bad feeling. As you only use it to calculate a ...
5
votes
Accepted
Design Shopping Cart System Interview Problem [Python 3]
Broadly speaking this does a lot of things right: self-written exceptions, (the start of) type hinting, overridden __str__, etc.
...
4
votes
Accepted
Sales tax calculator with branching based on postal address
I think you can refactor the sources as ITaxRateSource like this:
...
4
votes
Accepted
pyvdp - Python library for Visa Developer Program
The code overall looks clean, there will always be debates on writing classes or not (both approaches have great reasoning behind them, of course):
Stop Writing Classes (PyCon 2012)
Start Writing ...
4
votes
Shopping Cart design interview task
To add to mjt's answer:
You never introduce the very sensible object Product (or SKU if you like). Instead, you use ...
4
votes
Selenium-based link checker for a shopping site
Adding to the Graipher's excellent answer, here are some selenium specific points:
you are not closing the browser instances started by the webdriver
using a CSS selector to get all the elements ...
4
votes
Selenium-based link checker for a shopping site
Your LinkCheck.py can be greatly simplified:
...
4
votes
Accepted
Apple receipt validator
Instead of returning false 10+ times, just return false at the end since the only case you'll return true is if the case is 0. Also, you could reduce some repetition by putting the message in a string ...
4
votes
eCommerce Mockup App in JS
I am by no means a javascript/html/css developer, just somethings I noticed, and some things I would recommend as a customer. I invite someone who is more ...
4
votes
Accepted
eCommerce Mockup App in JS
General feedback
Overall this code isn’t bad but could be simplified quite a bit. The biggest thing I noticed is that jQuery is used for a few things but could be used a lot more - e.g. selecting DOM ...
3
votes
Accepted
Open/Closed Principle with calculating the total cost of items in a shopping cart
Basics
String comparison shouldn't be done with ==, unless you can carefully ensure you're using ...
3
votes
Accepted
jQuery code to total the items in a shopping cart
this part of code var id = $('.quant').attr('data-id');
Presuming there are multiple inputs with class "quant" (perhaps 1 for each row in the table), then this ...
3
votes
Accepted
Using dependency injection for Node payment system
It looks good to me, very SOLID.
Here are a couple of suggestions:
I'm not really seeing the value in the PaymentRepository layer. If the ...
3
votes
Shopping cart in pure JavaScript
Go here: https://validator.w3.org/ to check your markup. You can input it directly and it will show all your errors, just go down the list until you deal with them all (luckily, you only have a few).
...
3
votes
Shopping basket with discounts and tax
Thank you for not using floating point numbers for money.
I don't think items in Basket needs to be a Map. The line items on a ...
3
votes
Shopping cart with discounts
You should have a class PriceComputer that computes prices and their discounts. This should be the central class of the whole design.
Then, make separate data ...
3
votes
Apple receipt validator
System.out.println vs logging framework
as TwiN pointed out, a logging library is preferred to system.out.println as it will allow the user to control the logging. Mind that SLF4J itself is only a ...
3
votes
3
votes
Accepted
Filling in the card expiry date from transaction data
Your first version of build_expiry_date_string() will be able to build an shorter notation date from any date array. I would therefore rename it to ...
3
votes
CS50 pset1: credit card classification and checksum validation
This builds on greybeard's answer, which in turn builds on pacmaninbw's.
I would recommend combining the test for non-numeric input and the checksum verification into a single function (as this is ...
2
votes
Accepted
Class for Stripe transactions
Since it seems you only need the transactions value once, you might as well just make an attribute reader that does the work:
...
2
votes
Accepted
TDD Django - Shopping Cart
It is, of course, important to see the code under test to get the idea of the quality and coverage of your test, but here are some generic things that I've spotted after glancing over the tests, from ...
2
votes
Accepted
Removal of jQuery from script to auto-apply coupons from a link
As it stands, in most ways the code is now much better than the original. Your senior dev is absolutely correct in wanting to use CSS for the modal size. Despite this, there are a few suggestions I ...
2
votes
Shopping cart in Rails for karaoke items
Generally looks great.
Since @cart is basically a list of Karaoke ids, you could update the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
e-commerce × 102javascript × 23
php × 23
java × 16
c# × 12
python × 11
object-oriented × 11
ruby × 11
jquery × 9
beginner × 8
python-3.x × 8
mysql × 8
security × 6
validation × 6
ruby-on-rails × 6
html × 5
wordpress × 5
json × 4
error-handling × 4
api × 4
laravel × 4
console × 3
react.js × 3
dom × 3
angular.js × 3