Skip to main content
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 ...
MrBrushy's user avatar
  • 1,218
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 ...
greybeard's user avatar
  • 6,456
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 ...
chux - Reinstate Monica's user avatar
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 ...
pacmaninbw's user avatar
  • 23.9k
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 ...
mtj's user avatar
  • 4,822
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 ...
tobias_k's user avatar
  • 1,669
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. ...
Reinderien's user avatar
  • 62.4k
4 votes
Accepted

Sales tax calculator with branching based on postal address

I think you can refactor the sources as ITaxRateSource like this: ...
t3chb0t's user avatar
  • 44.3k
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 ...
alecxe's user avatar
  • 17.3k
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 ...
alecxe's user avatar
  • 17.3k
4 votes

Selenium-based link checker for a shopping site

Your LinkCheck.py can be greatly simplified: ...
Graipher's user avatar
  • 41k
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 ...
Rob Audenaerde's user avatar
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 ...
TwiN's user avatar
  • 453
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 ...
Linny's user avatar
  • 10.2k
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 ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
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). ...
Steve Carroll's user avatar
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 ...
h.j.k.'s user avatar
  • 19.2k
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 ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
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 ...
James's user avatar
  • 567
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 ...
ThisIsNoZaku's user avatar
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 ...
Roland Illig's user avatar
  • 21.3k
3 votes

Card payment strategies

Your friend is suggesting you have a class that does the common work, and then subclasses to handle specialized work. This is really core OOP. For example, your base class (say, ...
mdd-sbo's user avatar
  • 457
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 ...
Manuel's user avatar
  • 311
3 votes

Stripe payment form

instead of manually selecting each card every time like ...
Taki's user avatar
  • 608
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 ...
KIKO Software's user avatar
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 ...
Toby Speight's user avatar
  • 76.9k
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: ...
Flambino's user avatar
  • 33k
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 ...
alecxe's user avatar
  • 17.3k
2 votes

Plugin for showing cross-sells on the single product page in WooCommerce

The code looks ok to me from a security point of view. You're not accessing the database directly and it looks like you are escaping the output ( assuming that the template part does the same ). A ...
Welcher's user avatar
  • 121

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