"Best?" That depends on what your criteria for "best" are, as well as your particular business requirements. If it gets the job done correctly, it's certainly not "worst." However, if you expect to have a series of different coupon codes that come and go in the future, it might be advisable to use some sort of data-driven design where all you would need to do is add new coupon codes to the database (or other data source) with relevant information (discount amount/percentage, expiration date, etc.). Then if a user enters a code, you would check it against the database to determine its validity and the discount amount to be applied.