Stubbing Out Taxes and Shipping

As mentioned at the beginning of the chapter, shipping and taxes are two more tricky business logic subsystems.

In a real application, you would have to calculate taxes and shipping costs on your orders. This usually involves interfacing to third-party APIs that do the (sometimes complex) calculations, and return a value to be placed into the order. This is the same thing you will have to do with credit card authorization.

You usually won't be ready to actually integrate with the vendor's code (you might not even have chosen a vendor) when you write the code that requires that functionality. So, you'll need to stub something out for testing.

A good technique for any piece of code that's going to initially function ...

Get MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.