UNBCIC@BRFAPESP.BITNET (05/22/91)
=> From: Ben Eaton => <haven.umd.edu!uflorida!mlb.semi.harris.com!solman.mlb.semi.harris.com!bie@L OUIE.UDEL.EDU> => Subject: Object Oriented Programming ? => I know I am going to get flamed for asking this but I am going to => ask it any way. => => QUESTION - What is "Object Oriented Programming"? Well, I not going to be technical. I know that what I will said will be, at least, incomplete, and for many ones just wrong. But, although I can understand something by formal definitions, I know that many ones don't. So... Paradigm. OO is a paradigm. But what is a paradigm? Well, let's see examples: PROLOG (a language) is oriented to rules (that is it's paradigm). How it work? You define rules the rules, for example: brother(X,Y) :- male(X), father(Z,X), father(Z,Y). brother(X,Y) :- male(X), mother(Z,X), mother(Z,Y). Meaning that X is brother of Y if X is male and Z is father of X and Z is father of Y (Z is father of X *AND* Y). Also, X is brother of Y if X is male and Z is mother of X and Z is mother of Y. X,Y and Z are a kind of variable (I don't know the word in english for that) that can assume any value, but can't have it's value changed, as other computer variables. So, you enter information: male(peter). female(joan). male(john). father(john,peter). father(john,joan). and so on... This is the "program". When you use the program, you enter something like: ?brother(peter,joan) And the computer return TRUE. If you enter: ?brother(X,Y) The computer will return all pairs of brothers. There is also the procedural paradigm (the one you use), and the functional (or applicative) paradigm (used by List and Scheme, based on functions). Well, and now what is the Objects paradigm? First, lets understand what's an object: 1) Objects are data space (like space created by ALLOT) associated with a CLASS. 2) Classes contain data structure information (like TYPE) *AND* METHODS. Also, Classes have one or more parents. 3) Classes inherit everything from parents, including more parents, data structure information and methods. So, Numbers have some minimal representation, and some basical methods. Integers have everything Numbers does, and something more. 4) Methods are pieces of code that can manage the data of an object. ONLY THE METHODS OF AND OBJECT HAVE ACCESS TO OBJECT'S DATA. Example: Class Root: DATA: ? METHODS: create, destroy, ... No parents. Class Window: DATA: position, X-size, Y-size, ... METHODS: open, close, move, resize, ... PARENTS: Root Class Graphic Window: DATA: resolution, number of colors, ... METHODS: draw a point, return color of a point, ... PARENTS: Window Class Text Window: DATA: cursor position, rows, columns, font, ... METHODS: write text, move cursor, change font, ... PARENTS: Window, Character Text Window create (object) (parameters) Error_Messages Error_Message open (parameters) Error_Message write (parameters) Okay? If you did understand that, so you can go to the formal definition. (8-DCS) Daniel C. Sobral UNBCIC@BRFAPESP.BITNET
Mitch.Bradley@ENG.SUN.COM (05/28/91)
> My favorite definition of Object-Oriented Programming: > > "A paradigm focusing on data structures, providing methods for operating on > those data structures, and providing inheritance." > - Paul Snow > Now, does anyone want to elaborate on Paul's definition? That is indeed a nice definition, although the prominent place that it gives to data structures may be a bit misleading. In my mind, one of the key points of OOP is the fact that objects hide their data structures. I would add "without exposing their details" after "operating on those data structures". Mitch.Bradley@Eng.Sun.COM