Implementation of Methods Explained

The logical structures of nearly all objected-oriented programming languages are very much based on the same concept. However, in order to better understand what methods do, we first have to understand and define what a method is. To put it simply, a method is basically a recipe or, in this case, a blanket definition. We can picture this as cooking a meal in accordance with a recipe. Each recipe is going to have its own distinctive styles or methods of cooking, types of seasonings, and ingredients. In this analogy, the different cooking instructions are the “methods,” and the different types of seasonings and ingredients are the attributes or more commonly known as variables. Now, different recipes are also going to have their own unique cultural characteristics. In programming, this is considered and known as “classes.” Similarly, each recipe will need to follow a particular, systematic, and logical order. For example, in a typical recipe, you typically would not pour water into a boiling pan of oil. Each “method” or instruction set in programming will also need to follow its own distinctive logic. For example, some calculations ought to be calculated first before another, and there might be interdependencies between the two calculations. With that said, it is vital for us to know the priorities of each programming language’s syntaxes, functions, and their respective scope of visibilities. Nevertheless, for the most part, loops can be nested inside of a function, a function can be nested in a class, and variables may be nested in all of them depending on the person’s specific needs and use cases.

Responses to the professor or other students

Yes, Python was originally designed to be a highly flexible language while also maintaining its execution efficiency. Based on the three examples that you have provided, it is pretty self-evident that was the original intention. The C++ language may require a lot more lines of code, however, it will have also unlock more functionalities in that process with the freedom to declare the scope of visibility of different classes, whereas Python classes are all defaulted to public. Although there is usually no harm in doing so, adding the visibility scope, however, would give the programmer much more control over its data structure, hence, further enhancing readability and developmental maneuverability.

Leave a comment