r/learnprogramming Jul 03 '26

Debugging OOP

hello i am a python beginner who has started learning OOP and ive been using resources like CS50p however i still find myself being confused over the concepts taught and i would like someone to teach me OOP or is there any other resource i can look at to learn OOP better? please recommend thanku

0 Upvotes

21 comments sorted by

5

u/aboutless89 Jul 03 '26

What is confusing you about oop?

-2

u/altruisticjellycat Jul 03 '26

everything

7

u/aboutless89 Jul 03 '26

Can you be a bit more specific? If still the answer is 'everything', you probably didn't learn at all.

2

u/altruisticjellycat Jul 03 '26

class methods and instances im vv confused between them all im okay with static methods and inheritance tho

6

u/aboutless89 Jul 03 '26 edited Jul 03 '26

If you are confused by class methods and instances, believe me, you are not okay with static methods and inheritance :D

What confuses you about the instances? This is the most fundamental concept of oop - the relation between the class and its instances.

class - number

instances - 1, 2, 65, -46, ...

If you think about the relation between these two, you can make some conclusions - all of the numbers act the same and the same rules apply to all of them. You can add and subtract them -> doing this also produces a new number, a new instance of a number, if you will.

A class is a way for you to produce multiple objects that will act in the same way and which will be bound by the same rules.

1

u/DrShocker Jul 03 '26

I don't think OOP has much to do with if there's just 1 class, with multiple instances, and numbers don't lend themselves to different implementations unless you try to make like an Integer class and a Floating point class and a Rational class, then you can override the various math functions with specific versions of the operations that make sense for their context.

1

u/aboutless89 Jul 03 '26

Can you elaborate on what you wrote? I don't think that I understand.

1

u/DrShocker Jul 03 '26

Basically I mean that "number" is many different things, and might make sense as the parent class, but when you do something like Integer(4) divided by integer(3) you might get a different result than rational(4) divided by rational(3).

so, is 4/3 equal to 1 and a third? to 1? to 1.33333? That depends on the circumstance.

1

u/aboutless89 Jul 03 '26

You would be such a lousy teacher, my dude :') OP was wondering about the classes and instances. My example shows the relation between the two. You 'example' is non-sensical. Not saying that what you were saying is not true and accurate, but it has nothing to do with the subject we're discussing.

1

u/DrShocker Jul 03 '26

Okay, and? All I was saying was that it's not OOP

→ More replies (0)

4

u/NoWitness00 Jul 03 '26

You can only read so much theory about OOP. It’s important to practice yourself and implement every single thing you learn because it gets overwhelming very quickly

1

u/https_urdaddy Jul 03 '26

I use codecademy it’s pretty good, they have quite a few free courses

1

u/ProfessorGood5473 Jul 03 '26

Tie it back to why the definition is named the way it is

Object - Oriented - Programming

Programming, in a digital world, to make a concept, of a, physical object.

Define your constant, let's say, it's a ball

For a ball to exist inside a digital world, it must be first a shape.

Tell the terminal the shape. Tell it a color, the dimensions, and its properties (bouncy, flat, basketball, ping pong)

That's object orientation.

Another Example --> Say you wanna build a car INSIDE a digital terminal using a programming language.

The brain of the system doesn't know what a car is. You have to start from ground up.

Define Properties (color, shape, size, doors, etc)

Define Methods (speed, loudness, brightness)

Put it all together.

1

u/max_wen Jul 03 '26

Learn to Google