Python Forum
How to understand object-oriented programming?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to understand object-oriented programming?
#1
As a beginner just starting to learn Python, I'm quite confused by object-oriented programming. I don't know how to understand this concept, and it doesn't seem very beginner-friendly... Angry Big Grin
Reply
#2
Are you referring to how the object oriented programming is discussed in "How to think like a computer scientist"? You referenced that book in another post. That book covers classes and objects, but doesn't touch object-oriented programming at all. Classes and objects are central to Python since everything you use in your program, even strings and numbers, are objects and all objects are defined by classes. Knowing how to write you own classes is important for writing programs much larger than a few hundred lines.

Object oriented programming is completely different. OOP is a design philosophy that guides how you turn a programming problem into code. Instead of focusing on algorithms and functional decomposition (breaking large complex problems into smaller functions that work togeter), OOP focuses on the entities in your program and how they interact. For many types of problems this results in a design that is easier to understand, and produces reusable code modules. The language is somewhat irrelevant. I've written OOP programs in assembler, and C++ to write functional programs. Having a language that supports OOP concepts like polymorphism and encapsulation makes it easier to write an OOP program, but the OOP is really about the design stage, not the coding stage.

What is your question about, object oriented programming or classes and objects?
Reply
#3
(9 hours ago)deanhystad Wrote: Are you referring to how the object oriented programming is discussed in "How to think like a computer scientist"? You referenced that book in another post. That book covers classes and objects, but doesn't touch object-oriented programming at all. Classes and objects are central to Python since everything you use in your program, even strings and numbers, are objects and all objects are defined by classes. Knowing how to write you own classes is important for writing programs much larger than a few hundred lines.

Object oriented programming is completely different. OOP is a design philosophy that guides how you turn a programming problem into code. Instead of focusing on algorithms and functional decomposition (breaking large complex problems into smaller functions that work togeter), OOP focuses on the entities in your program and how they interact. For many types of problems this results in a design that is easier to understand, and produces reusable code modules. The language is somewhat irrelevant. I've written OOP programs in assembler, and C++ to write functional programs. Having a language that supports OOP concepts like polymorphism and encapsulation makes it easier to write an OOP program, but the OOP is really about the design stage, not the coding stage.

What is your question about, object oriented programming or classes and objects?
Thank you very much for reading my article. It was a rather clumsy algorithm, and when I have the ability, I will solve it in another way. As for what you mentioned, I think I'm not very clear on the concept of class and object. The book doesn't seem to explain it in detail, it just briefly mentioned it. The author used an analogy, saying that a class is like a factory, and an object is like a product produced on the factory floor, with attributes and behaviors. But if I were to write a class function myself, I wouldn't know where to start...
If you happen to see my reply in your spare time and are willing to help me, I would be extremely grateful.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb Object Oriented programming (OOP) problem OmegaRed94 6 4,299 May-31-2021, 07:19 PM
Last Post: OmegaRed94
  Understand what it means that everything in Python is an object... bytecrunch 8 5,372 Mar-19-2021, 04:47 PM
Last Post: nilamo
  Object Oriented Programming jackbk 8 6,031 Aug-24-2018, 01:13 PM
Last Post: Windspar
  Object Oriented DB Interactions datasundae 2 3,054 May-25-2018, 09:51 PM
Last Post: datasundae
  Oriented Object ldthan 1 3,017 Mar-27-2018, 11:26 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020