Object-oriented programming
What is ‘‘Object-Oriented Programming’’? (1991 revised version)
Bjarne Stroustrup AT&T Bell Laboratories Murray Hill, New Jersey 07974
ABSTRACT ‘‘Object-Oriented Programming’’ and ‘‘Data Abstraction’’ have become very common terms. Unfortunately, few people agree on what they mean. I will offer informal definitions that appear to make sense in the context of languages like Ada, C++, Modula2, Simula, and Smalltalk. The general idea is to equate ‘‘support for data abstraction’’ with the ability to define and use new types and equate ‘‘support for object-oriented programming’’ with the ability to express type hierarchies. Features necessary to …ver más…
A language is not necessarily better than another because it possesses a feature the other does not. There are many example to the contrary. The important issue is not so much what features a language possesses but that the features it does possess are sufficient to support the desired programming styles in the desired application areas: [1] All features must be cleanly and elegantly integrated into the language. [2] It must be possible to use features in combination to achieve solutions that would otherwise have required extra separate features. [3] There should be as few spurious and ‘‘special purpose’’ features as possible. [4] A feature should be such that its implementation does not impose significant overheads on programs that do not require it. [5] A user need only know about the subset of the language explicitly used to write a program. The last two principles can be summarized as ‘‘what you don’t know won’t hurt you.’’ If there are any doubts about the usefulness of a feature it is better left out. It is much easier to add a feature to a language than to remove or modify one that has found its way into the compilers or the literature. I will now present some programming styles and the key language mechanisms necessary for supporting them. The presentation of language features is not intended to be exhaustive. 2.1 Procedural Programming The original (and probably still the most