You are previewing Exercises in Programming Style.
O'Reilly logo
Exercises in Programming Style

Book Description

Using a simple computational task (term frequency) to illustrate different programming styles, Exercises in Programming Style helps readers understand the various ways of writing programs and designing systems. It is designed to be used in conjunction with code provided on an online repository. The book complements and explains the raw code in a way that is accessible to anyone who regularly practices the art of programming. The book can also be used in advanced programming courses in computer science and software engineering programs.

The book contains 33 different styles for writing the term frequency task. The styles are grouped into nine categories: historical, basic, function composition, objects and object interactions, reflection and metaprogramming, adversity, data-centric, concurrency, and interactivity. The author verbalizes the constraints in each style and explains the example programs. Each chapter first presents the constraints of the style, next shows an example program, and then gives a detailed explanation of the code. Most chapters also have sections focusing on the use of the style in systems design as well as sections describing the historical context in which the programming style emerged.

Table of Contents

  1. Preliminaries
  2. Dedication
  3. Preface
    1. The Code
    2. Who this Book is for
    3. Motivation for these Exercises
    4. Acknowledgments
  4. Prologue
    1. Term Frequency
    2. Word Index
    3. Words in Context
    4. Pythonisms
  5. The Author
  6. I: Historical
    1. Chapter 1: Good Old Times
      1. 1.1 Constraints
      2. 1.2 A Program in this Style
      3. 1.3 Commentary
      4. 1.4 This Style in Systems Design
      5. 1.5 Historical Notes
      6. 1.6 Further Reading
      7. 1.7 Glossary
      8. 1.8 Exercises
    2. Chapter 2: Go Forth
      1. 2.1 Constraints
      2. 2.2 A Program in this Style
      3. 2.3 Commentary
      4. 2.4 Historical Notes
      5. 2.5 Further Reading
      6. 2.6 Glossary
      7. 2.7 Exercises
  7. II: Basic Styles
    1. Chapter 3: Monolithic
      1. 3.1 Constraints
      2. 3.2 A Program in this Style
      3. 3.3 Commentary
      4. 3.4 This Style in Systems Design
      5. 3.5 Further Reading
      6. 3.6 Glossary
      7. 3.7 Exercises
    2. Chapter 4: Cookbook
      1. 4.1 Constraints
      2. 4.2 A Program in this Style
      3. 4.3 Commentary
      4. 4.4 This Style in Systems Design
      5. 4.5 Historical Notes
      6. 4.6 Further Reading
      7. 4.7 Glossary
      8. 4.8 Exercises
    3. Chapter 5: Pipeline
      1. 5.1 Constraints
      2. 5.2 A Program in this Style
      3. 5.3 Commentary
      4. 5.4 This Style in Systems Design
      5. 5.5 Historical Notes
      6. 5.6 Further Reading
      7. 5.7 Glossary
      8. 5.8 Exercises
    4. Chapter 6: Code Golf
      1. 6.1 Constraints
      2. 6.2 A Program in this Style
      3. 6.3 Commentary
      4. 6.4 This Style in Systems Design
      5. 6.5 Historical Notes
      6. 6.6 Further Reading
      7. 6.7 Glossary
      8. 6.8 Exercises
  8. III: Function Composition
    1. Chapter 7: Infinite Mirror
      1. 7.1 Constraints
      2. 7.2 A Program in this Style
      3. 7.3 Commentary
      4. 7.4 Historical Notes
      5. 7.5 Further Reading
      6. 7.6 Glossary
      7. 7.7 Exercises
    2. Chapter 8: Kick Forward
      1. 8.1 Constraints
      2. 8.2 A Program in this Style
      3. 8.3 Commentary
      4. 8.4 This Style in Systems Design
      5. 8.5 Historical Notes
      6. 8.6 Further Reading
      7. 8.7 Glossary
      8. 8.8 Exercises
    3. Chapter 9: The One
      1. 9.1 Constraints
      2. 9.2 A Program in this Style
      3. 9.3 Commentary
      4. 9.4 Historical Notes
      5. 9.5 Further Reading
      6. 9.6 Glossary
      7. 9.7 Exercises
  9. IV: Objects and Object Interaction
    1. Chapter 10: Things
      1. 10.1 Constraints
      2. 10.2 A Program in this Style
      3. 10.3 Commentary
      4. 10.4 This Style in Systems Design
      5. 10.5 Historical Notes
      6. 10.6 Further Reading
      7. 10.7 Glossary
      8. 10.8 Exercises
    2. Chapter 11: Letterbox
      1. 11.1 Constraints
      2. 11.2 A Program in this Style
      3. 11.3 Commentary
      4. 11.4 This Style in Systems Design
      5. 11.5 Historical Notes
      6. 11.6 Further Reading
      7. 11.7 Glossary
      8. 11.8 Exercises
    3. Chapter 12: Closed Maps
      1. 12.1 Constraints
      2. 12.2 A Program in this Style
      3. 12.3 Commentary
      4. 12.4 Historical Notes
      5. 12.5 Further Reading
      6. 12.6 Glossary
      7. 12.7 Exercises
    4. Chapter 13: Abstract Things
      1. 13.1 Constraints
      2. 13.2 A Program in this Style
      3. 13.3 Commentary
      4. 13.4 This Style in Systems Design
      5. 13.5 Historical Notes
      6. 13.6 Further Reading
      7. 13.7 Glossary
      8. 13.8 Exercises
    5. Chapter 14: Hollywood
      1. 14.1 Constraints
      2. 14.2 A Program in this Style
      3. 14.3 Commentary
      4. 14.4 This Style in Systems Design
      5. 14.5 Historical Notes
      6. 14.6 Further Reading
      7. 14.7 Glossary
      8. 14.8 Exercises
    6. Chapter 15: Bulletin Board
      1. 15.1 Constraints
      2. 15.2 A Program in this Style
      3. 15.3 Commentary
      4. 15.4 This Style in Systems Design
      5. 15.5 Historical Notes
      6. 15.6 Further Reading
      7. 15.7 Glossary
      8. 15.8 Exercises
  10. V: Reflection and Metaprogramming
    1. Chapter 16: Introspective
      1. 16.1 Constraints
      2. 16.2 A Program in this Style
      3. 16.3 Commentary
      4. 16.4 This Style in Systems Design
      5. 16.5 Glossary
      6. 16.6 Exercises
    2. Chapter 17: Reflective
      1. 17.1 Constraints
      2. 17.2 A Program in this Style
      3. 17.3 Commentary
      4. 17.4 This Style in Systems Design
      5. 17.5 Historical Notes
      6. 17.6 Further Reading
      7. 17.7 Glossary
      8. 17.8 Exercises
    3. Chapter 18: Aspects
      1. 18.1 Constraints
      2. 18.2 A Program in this Style
      3. 18.3 Commentary
      4. 18.4 Historical Notes
      5. 18.5 Further Reading
      6. 18.6 Glossary
      7. 18.7 Exercises
    4. Chapter 19: Plugins
      1. 19.1 Constraints
      2. 19.2 A Program in this Style
      3. 19.3 Commentary
      4. 19.4 This Style in Systems Design
      5. 19.5 Historical Notes
      6. 19.6 Further Reading
      7. 19.7 Glossary
      8. 19.8 Exercises
  11. VI: Adversity
    1. Chapter 20: Constructivist
      1. 20.1 Constraints
      2. 20.2 A Program in this Style
      3. 20.3 Commentary
      4. 20.4 This Style in Systems Design
      5. 20.5 Exercises
    2. Chapter 21: Tantrum
      1. 21.1 Constraints
      2. 21.2 A Program in this Style
      3. 21.3 Commentary
      4. 21.4 This Style in Systems Design
      5. 21.5 Further Reading
      6. 21.6 Glossary
      7. 21.7 Exercises
    3. Chapter 22: Passive Aggressive
      1. 22.1 Constraints
      2. 22.2 A Program in this Style
      3. 22.3 Commentary
      4. 22.4 Historical Notes
      5. 22.5 Further Reading
      6. 22.6 Glossary
      7. 22.7 Exercises
      8. 22.8 Constructivist vs. Tantrum vs. Passive-Aggressive
    4. Chapter 23: Declared Intentions
      1. 23.1 Constraints
      2. 23.2 A Program in this Style
      3. 23.3 Commentary
      4. 23.4 Historical Notes
      5. 23.5 Further Reading
      6. 23.6 Glossary
      7. 23.7 Exercises
    5. Chapter 24: Quarantine
      1. 24.1 Constraints
      2. 24.2 A Program in this Style
      3. 24.3 Commentary
      4. 24.4 This Style in Systems Design
      5. 24.5 Historical Notes
      6. 24.6 Further Reading
      7. 24.7 Glossary
      8. 24.8 Exercises
  12. VII: Data-Centric
    1. Chapter 25: Persistent Tables
      1. 25.1 Constraints
      2. 25.2 A Program in this Style
      3. 25.3 Commentary
      4. 25.4 This Style in Systems Design
      5. 25.5 Historical Notes
      6. 25.6 Further Reading
      7. 25.7 Glossary
      8. 25.8 Exercises
    2. Chapter 26: Spreadsheet
      1. 26.1 Constraints
      2. 26.2 A Program in this Style
      3. 26.3 Commentary
      4. 26.4 This Style in Systems Design
      5. 26.5 Historical Notes
      6. 26.6 Further Reading
      7. 26.7 Glossary
      8. 26.8 Exercises
    3. Chapter 27: Lazy Rivers
      1. 27.1 Constraints
      2. 27.2 A Program in this Style
      3. 27.3 Commentary
      4. 27.4 This Style in Systems Design
      5. 27.5 Historical Notes
      6. 27.6 Further Reading
      7. 27.7 Glossary
      8. 27.8 Exercises
  13. VIII: Concurrency
    1. Chapter 28: Actors
      1. 28.1 Constraints
      2. 28.2 A Program in this Style
      3. 28.3 Commentary
      4. 28.4 This Style in Systems Design
      5. 28.5 Historical Notes
      6. 28.6 Further Reading
      7. 28.7 Glossary
      8. 28.8 Exercises
    2. Chapter 29: Dataspaces
      1. 29.1 Constraints
      2. 29.2 A Program in this Style
      3. 29.3 Commentary
      4. 29.4 This Style in Systems Design
      5. 29.5 Historical Notes
      6. 29.6 Further Reading
      7. 29.7 Glossary
      8. 29.8 Exercises
    3. Chapter 30: Map Reduce
      1. 30.1 Constraints
      2. 30.2 A Program in this Style
      3. 30.3 Commentary
      4. 30.4 This Style in Systems Design
      5. 30.5 Historical Notes
      6. 30.6 Further Reading
      7. 30.7 Glossary
      8. 30.8 Exercises
    4. Chapter 31: Double Map Reduce
      1. 31.1 Constraints
      2. 31.2 A Program in this Style
      3. 31.3 Commentary
      4. 31.4 This Style in Systems Design
      5. 31.5 Historical Notes
      6. 31.6 Further Reading
      7. 31.7 Exercises
  14. IX: Interactivity
    1. Chapter 32: Trinity
      1. 32.1 Constraints
      2. 32.2 A Program in this Style
      3. 32.3 Commentary
      4. 32.4 This Style in Systems Design
      5. 32.5 Historical Notes
      6. 32.6 Further Reading
      7. 32.7 Glossary
      8. 32.8 Exercises
    2. Chapter 33: Restful
      1. 33.1 Constraints
      2. 33.2 A Program in this Style
      3. 33.3 Commentary
      4. 33.4 This Style in Systems Design
      5. 33.5 Historical Notes
      6. 33.6 Further Reading
      7. 33.7 Glossary
      8. 33.8 Exercises