Chapter 4. Writing an application and design patterns with IronPython

 

This chapter covers

  • Duck typing in Python
  • The Model-View-Controller pattern
  • The Command pattern
  • Integrating new commands into MultiDoc

Python as a language goes out of its way to encourage a good clear programming style. It certainly doesn’t enforce it, though; you’re just as free to write obscure and unmaintainable code with Python as you are with any other programming language. When talking to programmers who haven’t used Python, I’m sometimes surprised by their perception that it’s harder to write well-structured programs with Python because it’s a dynamically typed language. In fact, by making it easy to express your intentions and reducing the amount of code you need to write, Python makes large projects more maintainable.

In this chapter, as well as learning more about IronPython, you’ll also explore some Python programming best practices. This exploration includes getting deeper inside Python by using some of Python’s magic methods. You’ll also create a small application to tackle some common programming tasks, using several .NET namespaces that you haven’t yet seen.

We start with a look at data modeling in Python.

4.1. Data modeling and duck typing

4.2. Model-View-Controller in IronPython

4.3. The command pattern

4.4. Integrating commands with our running example

4.5. Summary

sitemap