Book Review: Modular Programming With Python
Check out Mike Driscoll's book review for "Modular Programming With Python" and see if you might be interested in picking up a copy.
Join the DZone community and get the full member experience.Join For Free
earlier this year or late 2015, packt publishing asked me to be a technical reviewer for a book called modular programming with python by erik westra. it sounded really interesting and it ended up being one of the best books i’ve read from packt. note that i am the sole technical reviewer of the book. i’m not sure why packt went that route for this book as they normally have two-three reviewers, but perhaps they are trying to accelerate their writing process.
- why i picked it up: primarily because packt asked me to. however, it really is an interesting book.
- why i finished it: because the book is short and very well written.
- i’d give it to: an intermediate developer who needs to brush up on their code organizational skills.
you can get an ebook (pdf, epub or mobi) version or a softcover .
this book only has 9 chapters and is 228 pages long.
modular programming with python is actually quite fun to read. it is designed to help you learn how to make your code more modular and gives some really good examples. the first chapter begins by going over the way python itself organizes its modules and packages. it goes on to explain why modular programming can be important and it has a neat example of creating your very own module, which happens to be a caching module.
the second chapter is all about creating your first modular program. it takes you through the steps you might go through to design a program in a modular fashion and then actually implements it. during the design phase, the author just stubs out the interface. then in the implementation phase, we get to actually add the code.
for chapter three, we learn how modules and packages are initialized. the author also goes over python’s importing system. we learn how imports work, what relative imports are, controlling what gets imported, circular imports, and more.
chapter four is about creating a modular charting package. we learn how to chart using the pillow package, which is a fork of the python imaging library (pil). then the author talks about how requirements for projects change and how we must respond to them. in this example, we need a way to do vector images which pillow doesn’t support. so the author shows how to add the ability to create charts using reportlab or pillow. this is also a really great chapter.
chapter five looks at modular patterns, like encapsulation, wrappers, etc. i think the part i found most interesting was the portion of the chapter that covered dynamic imports, plugins, and hooks.
in chapter six, we learn about reusable modules. the author first describes what a reusable module is and then gives some examples. the rest of the chapter is devoted to creating a reusable module which happens to be a unit conversion module.
chapter seven digs even more into python’s importing system. it covers such items as optional imports, local imports, adding packages to sys.path, various import “gotchas”, dealing with globals, and more. this was actually one of my favorite chapters.
for chapter eight, we get a change of pace. it’s all about testing our modules and deploying them. the chapter only gives the basics on unit tests, code coverage, and test driven development. the bulk of the chapter is about getting a module ready for publication to github or the python package index.
the final chapter is supposed to demonstrate how modular programming techniques can make the process of programming itself more effective. it gives a pretty short example and wraps up the book.
overall, i found this book conveyed its message very well. the code examples are straightforward and easy to understand. the writing is very good. much better than what i normally see in packt publications. i love reading neat or just interesting code and this book has several great examples. i did feel like the book ended a bit abruptly. while i don’t know what should have been added, i just felt like it could have had another chapter or two. regardless, i do recommend this book to anyone who is having trouble organizing their code.
modular programming with pythonby erik westra
Published at DZone with permission of Mike Driscoll, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.