Imperfect C++ Practical Solutions for Real-Life Programming By Matthew Wilson | |
Table of Contents | |
Appendix B. "Watch That Hubris!" |
B.2. DRY Rued YesterdayAround the time I wrote the string class, I also wrote my first C++ linked-list. I just loved the idea of encapsulation. Alas, my enduring love for the Don't Repeat Yourself (DRY) principal [Hunt2000], which dictates that no item of information should be kept in more than one place, was naively misapplied in this class since I implemented the GetCount() method to do a count from the head to the tail every time it was called. Not exactly O(1). I dare not even talk to you about the self-balancing tree! |