
Can you explain to a beginner why we use OOP? - what-lisp
https://www.quora.com/Can-you-explain-to-a-beginner-why-we-use-OOP/answer/Max-Thompson-41?share=1
======
kazinator
A lot of the time we use OOP is for this simple reason: we need a record
structure to keep related properties together, as if it were one value.

The features of a language that are recognized as its "OOP system" are
organized around the record-defining capability. Record types may be called
classes, and operations on records may be called methods and so on.

If we need a record structure to keep related properties together, say three
of them, we could use an array or list of three elements. In some languages
that would be a non-starter for records whose elements have different types,
because an array or list has to be of items of the same type. In dynamic
languages, it would work. However, we then have to remember that emp[0] is the
employee ID, emp[1] is their telephone extension, and so on. We could define
constants for these so we can access emp[id] and emp[phone]. We are then on
our way toward creating an _ad hoc_ , record system. We notice limitations,
like we would like customers to have an "id" and employees to have an "id",
but since id is a constant, we have to put the "id" at the same array offset
in the employee array and the customer array. This approach will not scale;
there will be clashes requiring us to put these offsets into namespaces. These
arrays all have the same type. We'd like to know, given this object P, are we
looking at an employee or customer? So we can come up with a convention like
element P[0] always holds a type code. Problem: Bob, Alice and Mallory want to
integrate their separately developed modules into one program. Each of these
programmers has come up with their own record-in-array type system,
incompatible with the other two. It's a mess! Mallory took advantage of arrays
with negative indices and put the type at [-1]. It's not a simple integer code
but itself an array with multiple properties. Bob and Alice used [0], but with
different integer codes whose values clash.

Instead of this _ad hoc_ approach, we have some sort of record or structure
type in the language.

------
seeker61
Real reason: that's the only thing most beginners are taught. (For better or
worse, but that's the facts.)

