Page 248 -
P. 248

modular programming


          The discounts get the customers flooding in


           Once word gets out that there are double-discounts available in
           the coffee bar, the health club gets packed with customers.






                                We‛ve never been so busy! The weight
                                room, the gym, the steam baths. The
                                whole place is full of customers! I like
                                the way you write code. I want you to
                                upgrade every system in the place!






           Thanks to writing modular code, you got the contract to
           replace all the health club systems. Modules help you write
           stable, maintainable code. The more code you write in modules,
           the greater the chance that you’ll be able to reuse it elsewhere.

           Breaking your code into modules turns good
 It's a muffin.  programs into great programs.








            Q:   I don’t get it; why do I need to use   Q:  So if I hadn’t used a FQN, the   Q:  So, all I need to do is keep an eye

            a FQN again?                    wrong discount is applied to the   on the order when I import modules and
                                            purchase?                       everything will be OK?
            A: You use a Fully Qualified Name
            (or FQN) when you need to distinguish   A: Yes, most probably.   A: No, that’s not what we recommend.
            between two functions from different                            Don't rely on what might happen. Use a
            modules that have the same name.   Q:  But if I hadn’t used a FQN, how   FQN so that you are always in control.
            With the health club systems, the   would I know which discount was used?
            discount() function existed within
            your module and within the one supplied by   A: Well... that's the problem. You
            Starbuzz. In order to keep things straight,   wouldn’t. It’s hard to predict what would
            you had to use a FQN.           happen, because it all depends on which
                                            order the code imports its modules.
 It's a latte.

                                                                                      you are here 4    213
   243   244   245   246   247   248   249   250   251   252   253