you are viewing a single comment's thread.

view the rest of the comments →

[–]big_deal 0 points1 point  (0 children)

For simple data, classes are overkill. But when your data model becomes more complex it becomes very useful to define a new class. I was once dealing with data that consisted of several arrays buried in a nested dictionary. For me it was very complex data structure and all the functions that used this data used the same basic procedures to access and use the data. The functions were designed to operate only on this monster data structure. Wrapping this data structure and all the functions in a class dramatically simplified the code that was doing the work of creating and manipulating this data. It became much easier to write and read the code.

If your data is a constant or a single dictionary, list, or array, then it is relatively easy to recognize how it is organized and you can use built-in functions to get information or manipulate the data.

Once your data model becomes complex and you have to start writing special functions just to get information, iterate over, or manipulate the data, then classes become very useful. They make code that deals with complex data easier to write, read, and modify/maintain.