DEV Community

lordronjuyal
lordronjuyal

Posted on

day 09

date:- 28 May, 2024.

Procedural programming:- This is just how we structure our code. This is an old way of coding. In this, we divide our program into the logical sequence of steps it needs to follow to do the task.

Object-oriented programming:- This is another and more modern way of structuring the code. In this, we divide programs into different groups called object, where each object is responsible for a specific job. By this, we try to model objects as real-world entities. They can have their own attributes(properties/variables) and methods(functions).

In OOP, we create a standard description(properties and methods) of a group. This is called class. This class is used to make other objects which have the same description and some additional properties and methods. For eg we make a teacher as a class, knowledge of a subject can be its properties and functions including teaching, homework, test etc. Now, object will be real life people like Ramesh sir, Asha madam who will have knowledge and functions like teaching, giving homework etc plus additional functions/properties like storytelling, name which can be unique.
To make an object from class: object_name = ClassName()
We use Pascal case(each letter capital) for class names and we have to use ().
Now object_name is the object we created and it will get attributes and methods of the "ClassName" class. To access attributes or functions, we use object_name.attribute_name or object_name.function_name()

Other things I learned today:-

  1. To use a global variable in local scope, we have to use code global variable_name. But in the case of dictionaries, we don't have to write this.

Project I made:-

  1. Coffe machine https://replit.com/@rohitrj332024/Coffee-machine-day-09#main.py

Somehow theory took much of my time. I am practicing oop with turtle module. Time for the rest. Thank you see you tomorrow.

Top comments (0)