Object-Oriented Programming is one of the most used programming paradigms to develop software. This article shows a series of posts I wrote about object-oriented programming in Python, and the right order you must follow to read them.
The study of Object-Oriented Programming (OOP), as the study of many other subjects, is divided into topics or stages.
I’ve been teaching programming for several years, so I want to recommend to you how to start learning OOP and in what order you should learn the topics.
You should focus on the paradigm, not on the programming language. A common mistake many students make is to focus on learning python, or java or C#. They look at the syntax and how to use certain blocks of code.
After that, they usually ask themselves, what can I do know with this? How do I apply it?
The answer to those questions lays in the paradigm. What is the paradigm for? What is programming for?
The programming language is just the way you communicate with the computer. It is the way you tell the computer what to do. But, before that, you need to know what to do, and you need to know what you can tell the computer to do.
So again, my recommendation is that you should focus on learning the paradigm, getting the problem-solving skills. After that, you can go deeper (and focus) in learning a specific programming language.
What is Object-Oriented Programming about?
As I mentioned before, OOP is a programming paradigm. A paradigm is governed by rules and principles. So a good way to start learning programming is by learning the principles that are the foundations of the paradigm.
A simple way to understand OOP is as follow.
We want to solve problems with OOP. That is our main goal. Therefore, we must be problem-solving oriented.
Using OOP we can model real-life situations to give a solution to a problem. So, when we try to solve a problem using OOP (and programming in general), we first have to understand the context, the real-life situation that we have to model.
For instance, let’s say we want to create a software for bookkeepers. The first thing we should do is to learn what bookkeepers do. There is no way you can “tell” (write the code for) the computer how to do bookkeeping if you cannot do it yourself.
The process you should follow to create the solution
Now, the software development process starts. You have to gather the software requirements. This will be the functionalities the end-user expect to have available while using the software you are creating.
So, now you know what the end-user expects from the software. Next step is to design your solution. While completing this stage, you should use principles, good practices, patterns that are used according to the paradigm and methodology you are using.
Next, you start implementing. Only at this stage, you start using a programming language.
So, here is my question, if the process is like that, why most students want to start writing lines of code from the beginning instead of following the process?
You probably found out the answer already. The students still don’t know or have the big picture, of where the programming language fits in the process of creating software. Yes, it is a process, it is not a task you just create and solve.
What is Object-Oriented Programming used for?
OOP is used to solve problems.
OOP paradigm is more than a programming language, it is a way to solve problems, to automate processes or tasks, to “teach” the computer how to do certain things.
So, the first step of the process, the client will tell you what he/she wants. From that description, you have to start your design. Notice it is the design, at this point, there is no programming language involved yet.
Usually, the design is made using UML.
After that, you can start thinking about what programming language and/or software framework to use.
Only now you can start writing the code.
I hope from the reading you get the idea of how important is to understand the paradigm, instead of just learning a specific programming language.
So, what to do now?
Object-Oriented Programming in Python Series
OOP involves the use of concepts like class, object, inheritance, polymorphism, etc. From my point of view, the best way to understand these (and other) concepts is by solving a problem and see the concepts in action.
You can read about the first two concepts: classes and objects in this post. In the post, you will see a problem description that a client is giving to you. From that description, you will identify classes and you will see the examples on python on how to implement classes. I recommend you to start modelling the class in UML instead of using python code.
The benefit of using UML to model a situation is that it is programming-language agnostic. It means that you can implement that design in any programming language you want, without having to change anything in the design. However, if you start writing the class in python, that “design” (it is actually an implementation) will be unusable in another programming language.
Several UML modelling tools have options to export the model to a programming language. Therefore the importance of doing the modelling in UML using this type of tools.
As a second topic to learn I always recommend arrays/lists. The majority of problems to be solved by computers involves a collection of objects. The data structures arrays/lists are the most used to handle, store, model collections ob objects. You can read more about lists in python in this post.
After that, more advanced topics are coming to help us in our efforts to solve problems using programming: Inheritance and Polymorphism. You can read this post explaining the topics and also this one.
Other topics you should learn
Other topics that are not specifically related to OOP, but there are of utmost importance for programmers.
I’ll list them in the order I suggest you read the topics.
- Strings.
- Exception handling. The examples are in python, but the reasoning is the same in any programming language.
- Working with files. Same as the previous one, the examples are in python.
- Recursion.
- It is always good (although not compulsory) to learn mathematics. See one example of why mathematics is important for programmers.
- Algorithms. See an example of two algorithms to extract digits from right to left without using strings in python.
Summary
In this article, I showed you the way that, according to my experience, is better to learn programming.
Key take-away:
- Focus on the paradigm, not on a specific programming language.
- Learn the fundamentals first, don’t try to start writing code right away.
- Be problem-solving centred, that is what programmers do. They solve problems.
- Learn the concepts of OOP by applying them in concrete projects.
- LEARN ALGORITHMS! I cannot say it in another way, it will be impossible for you to be a good programmer if you don’t learn algorithms.
Related posts
- OOP paradigm principles
- Learning python with examples
- How to solve problems using Inheritance and Polymorphism in Python
- OOP concepts: Illustrated guide
- Metaclasses in Python
H@appy coding!