Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Some OOP-related Contents to the List #50

Open
lemorage opened this issue Apr 1, 2024 · 2 comments
Open

Add Some OOP-related Contents to the List #50

lemorage opened this issue Apr 1, 2024 · 2 comments

Comments

@lemorage
Copy link

lemorage commented Apr 1, 2024

That's really a good tutorial to start with. After learning some of the basics of Python, however, classes seem to be a quite sophisticated topic. Do you think it would be better to add more conceptual stuff built on classes, like inheritance or polymorphism, etc?

@Akuli
Copy link
Owner

Akuli commented Apr 1, 2024

We could add more OOP stuff, but before doing that, we should explain when classes are used. Currently the tutorial does a good job explaining how classes work, but not so much when to use them. IMO you should use:

  • a plain old class when you end up with many functions that all access the same data
  • a dataclass when you just want to group together related data (similar to struct in other languages)
  • fancy OOP things (inheritance etc) only in some rare cases.

Many people overuse fancy OOP things, and are too arfaid to break OOP's "rules" when it makes sense. Most of the time it's best to use a plain old simple class. That said, sometimes inheritance is the right tool for the job, and programmers should know it.

@lemorage
Copy link
Author

lemorage commented Apr 2, 2024

Yep, yep, really class is a quite complicated topic for me compared to those basic things in Python, and sometimes I just can't find a practical way to apply the OOP concepts to my case, and I can only handle a simple old class which seems pretty lame. We really need to make a good structure of these concepts and explain the possible use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants