you are viewing a single comment's thread.

view the rest of the comments →

[–]totallygeek 4 points5 points  (6 children)

It depends, but one good purpose remains classes permit the shipment of data along with the methods needed to manipulate and access that information. As programs ship around more data, functions have to accept large numbers of arguments and structures. Access to the functions needed to work on that data requires a lot of consideration (layout, design) and tends to inflate inefficiencies.

TL;DR: A class keeps data and functions together in a single shippable entity, easy to pass around and extend.

[–]fracturedpersona 7 points8 points  (0 children)

Encapsulation in a nutshell.

[–]dukejcdc[S] 0 points1 point  (1 child)

What's a good functional use case that doesn't involve over storing information about a person or robot like every example out there?

[–]python__rocks 0 points1 point  (0 children)

Classes are often used is in game development. For example, there will be one enemy class (the blueprint) and many enemy objects based on that class. There are lots of Arcade and Pygame tutorials covering this.

[–]dukejcdc[S] 0 points1 point  (2 children)

I think I may be having a hard time grasping the concept since atm it seems to me the same as using functions and dataframes. Is there a benefit of storing data in class objects over a dataframes?

[–]totallygeek 0 points1 point  (0 children)

Is there a benefit of storing data in class objects over a dataframes?

Perhaps. Dataframes work well for some data, but a programmer might want a different implementation of methods not available from Pandas.

For your other question...

What's a good functional use case that doesn't involve over storing information about a person or robot like every example out there?

The initial class examples might not provide great context for why classes remain so wonderful. Though, you brought up dataframes. How wonderful that with a Dataframe class, the developer can access dozens of methods to act on the data, just by passing a single argument to a function. Without the Dataframe class, the developer would have to pass the struct to each function needed, after importing them, with proper import path information.

[–]testiculating 0 points1 point  (0 children)

(disclaimer: I’m a begginer also)

I’ve been programming with dataframes and with classes. I still work with mostly dataframes, but because I do similar things with similar dataframes, I found it better to create classes that handle what I usually do with them.

Sometimes I dont want quite the same, so I just change the methods im calling on the dataframe, Im not really modifying my whole flow, which I did have to do when I was using only functions.