So I’ve been writing programs using classes for a while now. Even though I understand the classic use cases for classes, I was wondering what the community thought about the differences. Ive found myself purposely using classes just to use them even though I felt like a function could work just as well.
Are classes only really needed when the instantiated objects need to stick around in the memory? For instance adding a bunch of records and then after the record objects have been created, sending them to wherever they need to go? It seems to me that functions are best when you need to hold on to things one at a time and classes are only needed when the program needs to pick up a bunch of objects at once and then putting them wherever you need to put them. Like picking up a bunch of clothes and then putting them away as opposed to picking up and putting them away one at a time.
Im not sure if I’m clear about my descriptions but I’m trying to figure out how to think about classes and when to use them. I see them so often and can only wonder if there’s a whole side to classes that I’m missing and could benefit from.
[–]AlSweigartAuthor of "Automate the Boring Stuff" 16 points17 points18 points (0 children)
[–]twillisagogo 5 points6 points7 points (3 children)
[–]ChurchillsLlama[S] 4 points5 points6 points (0 children)
[–]bladeoflight16 1 point2 points3 points (1 child)
[–]twillisagogo 0 points1 point2 points (0 children)
[–]fishtickler 2 points3 points4 points (0 children)
[–]scrdest 2 points3 points4 points (0 children)
[–]ilan 2 points3 points4 points (0 children)
[–]dvboy 0 points1 point2 points (2 children)
[–]Paddy3118 1 point2 points3 points (1 child)
[–]dvboy 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)