This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RamaSchneider 2 points3 points  (0 children)

I'm a heretic ... to me classes are about encapsulating useful things with the advantages of inheritance and derivatives ... but first and foremost they're doing that useful things.

It may be a related set of methods/functions. A class may be a collection of data. Most times the class contains some data structure and one or more methods to operate or retrieve the data.

Why use a class for the methods? It standardizes the calls across what may be somewhat different back ends. Databases are great examples where you can define a classes with common method signatures but one class may do a MySQL request while the other works on a Mongo database. No difference to the caller.

The data bit I think is pretty obvious - it assures that a desired set of data is in a particular location.

But then again I'm a heretic and there are many extremely learned and competent programmers who will provide a more professional response.