gwowen a écrit :
Data and methods encapsulated together. That's an object, by every
definition I've ever heard.
Yes, that is one part of object oriented programming.
But inheritance and classes are as essential to it as are methods.
I do not want to denigrate OO programming. There are some useful usages, for instance
in GUI programming, and where a hierarchical view of the data is appropiate.
Here in the container library I do not see any big hierarchy.
If you look at the way they are traversed there are just groups
of similar containers:
(1) Sequential containers. Here we have a meaning for "Next", "Previous", and they
can be seen as a sequence of some kind of object
(2) Associative containers like hashtables or trees where you associate a key with some
data. There are no meanings to "next" oder "previous"
If you look at the contents you can have
(1) Abstract containers that work with void pointers
(2) Concrete containers where the members are fixed: int lists, double vectors, etc.
If you look at whether you can have duplicates or not you have sets or multisets,
etc.
I am sure we could go on classifying things, and in some situations some classifications
could be useful in another situations they could be a hindrance.
That is why I do not try to over-classify containers in some way. Obviously bitstrings
are a specialization of a vector, it would not be very useful to store each bit in a
doubly linked list for instance ... even if it could be done.
As you can see, object oriented programming doesn't apply here specially well.
But it could be a way of describing things. If you have a classification in mind
be free to propose it
There's no data hiding, and no
polymorphism, but they're still objects.
There is a limited polymorphism since I will group all common methods to sequential
containers at the same place for the different container vtables so that you will
access the same position when using them. This makes the client code independent
of the specific sequential container used and allow easy migration from one container
to a different one.
Objects with ugly syntax and
no language support are still objects.
"Ugly" is in th eyes of the person making that judgement... What is ugly for you is
beautiful for me. No longer we have some language abstraction that interposes
between you and what you are doing. YOU are the one doing everything, there is
PRECISELY no language support what gives you an absolute freedom of expression.
YOU CAN DO WHAT YOU WANT. No limits.
This is the C language