book

See the first post in The Pragmatic Programmer 20th Anniversary Edition series for an introduction. Challenge 1 Although there are no guaranteed ways of ensuring that you always free resources, certain design techniques, when applied consistently, will help. In the text we discussed how establishing a semantic invariant for major data structures could direct memory deallocation decisions. Consider how Topic 23, Design by Contract, on page 104, could help refine this idea.

Read more…

See the first post in The Pragmatic Programmer 20th Anniversary Edition series for an introduction. Exercise 16 A quick reality check. Which of these “impossible” things can happen? A month with fewer than 28 days Error code from a system call: can’t access the current directory In C++: a = 2; b = 3; but (a + b) does not equal 5 A triangle with an interior angle sum ≠ 180° A minute that doesn’t have 60 seconds (a + 1) <= a All of them!

Read more…

See the first post in The Pragmatic Programmer 20th Anniversary Edition series for an introduction. Challenge 1 Points to ponder: If DBC is so powerful, why isn’t it used more widely? Is it hard to come up with the contract? Does it make you think about issues you’d rather ignore for now? Does it force you to THINK!? Clearly, this is a dangerous tool! Design by contract leads to similar arguments as the great dynamic vs static typing debate:

Read more…

See the first post in The Pragmatic Programmer 20th Anniversary Edition series for an introduction. Exercise 11 You’re rewriting an application that used to use YAML as a configuration language. Your company has now standardized on JSON, so you have a bunch of .yaml files that need to be turned into .json. Write a script that takes a directory and converts each .yaml file into a corresponding .json file (so database.

Read more…

See the first post in The Pragmatic Programmer 20th Anniversary Edition series for an introduction. Challenge 1 Design a small address book database (name, phone number, and so on) using a straightforward binary representation in your language of choice. Do this before reading the rest of this challenge. Translate that format into a plain-text format using XML or JSON. For each version, add a new, variable-length field called directions in which you might enter directions to each person’s house.

Read more…