Chapter 6. Classes and Objects

When physicists create a mathematical model of a physical process, they rely on the mathematical framework that can represent that process as closely as possible. When Newton developed a model of forces and motion, the appropriate mathematical framework was calculus. When Einstein developed a model of wave-particle motion, he relied on the mathematics of wave equations and eigenvalues. For many models in scientific computation, the computational framework that best aligns with our need is object orientation.

The universe presents itself as a collection of objects that humans (in particular, scientists) tend to classify based on their attributes and behaviors. Similarities, relationships, and hierarchies among these objects further help to structure our perception of the world. In alignment with that conceptual model, object orientation facilitates representation of the world as classes of objects that possess attributes, behaviors, and hierarchical relationships. Classes in object orientation organize data, methods, and functions. Those classes manifest themselves as specific objects. We will discuss these two concepts in great detail here.

This chapter will describe how object orientation allows the scientist to cleanly organize behaviors and data. It will also mention the many objects this book has used already and how they operate as particular instances of distinct classes. To demonstrate the use of classes for modeling physics, this chapter ...

Get Effective Computation in Physics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.