Fast Win Data Science
If you are going to seriously program with Python, you will need to understand Object-oriented programming and the concept of a class and a data class. In this Fast Win Data Science In this article, you'll get a quick and painless introduction to all three, including what they are for, how you use them, and why you need them.
Object-oriented programming (OOP) is a language model that reduces code duplication and makes code easier to update, maintain, and reuse. As a result, most commercial software is now built using object-oriented programming.
While procedural The programming is based on behavior and logic, Object-oriented programming is based on data structures, known as objectsconsisting of data and functions (called methods) that act on the data. Objects are built from classeswhich are like plans of the objects.
A class is a type of dataand when you create an object of that data type, it is also known as instance of that class. The process of setting the initial values and behaviors of the instance is called instantiation.
Like instances of a class, objects allow you to create multiple copies with the same structure but potentially different data. For example, if you are creating a space combat game, you can conveniently combine the attributes of a given spacecraft, such as its size, speed, and weaponry, with the methods that control its flight and the operation of its weapons. Then, when you create a new spaceship of that type, you only need to worry about giving it a unique name.
Since Python is an object-oriented programming language, you have already been using objects and methods defined by other people. But unlike languages like Java, Python doesn't force you to use object-oriented programming for your programs. It provides ways to encapsulate and separate layers of abstraction using other approaches, such as functional or procedural programming.
Having this option is important. If you implement object-oriented programming in small programs, most of them will feel over-designed. To paraphrase computer scientist Joe Armstrong, “The problem with object-oriented languages…