4 Object-oriented programming for data scientists
This chapter covers
- Introducing object-oriented programming (OOP) for data scientists
- Creating your own classes
- Defining class methods
In this chapter, we’re going to introduce object-oriented programming (OOP) for data scientists. Object-oriented programming (OOP) can be a confusing and abstract topic, especially if you’re reading about it for the first time. For software engineers, OOP is common practice. Data scientists, however, tend to have less exposure to OOP, which is one of the motivations for this chapter. Building on the material we’ve covered so far, OOP allows for better structure and adaptive flexibility in your code. In a nutshell, OOP also makes your code more easily portable, meaning that rather than having convoluted notebooks of code, you have a codebase that easily be integrated somewhere else. This saves time for you as a data scientist, as well time for others working with your code. It’s also useful when you’re putting your code into production.