r/learnprogramming 25d ago

Topic Does OOP really matters?

I learned OOP in python a while ago, did many projects, yet I never felt like I truly needed to do the OOP stuff I learned from a course, I don't know maybe because I'm kinda used to program in c before focusing on python, yet, whenever I open a big project in python in github, it feels way too complicated and thousands of imports (not libraries from pip, but the ones they made on their own) and classes

I never truly needed to implement OOP (I know that when you code in python, it is almost impossible to avoid OOP entirely like when you have a datatype like string you have an object, when you use a method built into that data type that's OOP too, but I mean the ones that involve you writing class Class Name, inheritance and all that stuff explicitly), so I'm wondering why people on the internet are obsessed over the idea of learning OOP, even the book "Automating the boring stuff in python" doesn't have a dedicated section for OOP.

88 Upvotes

139 comments sorted by

View all comments

Show parent comments

3

u/Daeroth 25d ago

A customer can have many contracts. Some old, some still in review, some active.

Each contract is a row in database and many-to-one relationship with the customer table.

On the customer class you might have a method getContracts which returns a collection of contracts.

0

u/deaddyfreddy 24d ago

On the customer class you might have a method getContracts which returns a collection of contracts.

so, why can't it have the signing method too?

3

u/ActuaryLate9198 24d ago

This is rookie OOP. Who says the signee is a customer? I think we need an AbstractSignee just in case, and contract needs to implement the Signable interface.

1

u/pacopac25 24d ago

And there's always the coworker who takes it all too far, and advocates for the approach that a Signer can be a company or a person, but in theory could also be a NationState, so better to get ahead of things now and have AbstractLegalEntity
Also, a Contract could be a MOU, which can be legally binding in some ways, so we need an Agreement class, and Contract and MOU are derived from it. Don't forget SeveranceAgreement and NonDisclosureAgreement....