5.1. Introduction¶
As you will see in this chapter, interfaces allow programmers to write code that works on various types. For example, we could write a single program that can accept payments from different payment processing services (Visa, PayPal, Affirm, etc.). As long as we can guarantee that all of the payment processing services have a certain set of behaviors (methods), the program that uses these behaviors does not have to change in order to work correctly with all of the services. In other words, the code that takes in payment information from the user would not have to change but we would be able to seamlessly work with different payment processing services! In this chapter, we will show how this would work with the payment processor example and then we will provide you with a hands-on example that allows you to style output in various ways without changing the driver program.