Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!linac!att!ucbvax!BRFAPESP.BITNET!UNBCIC From: UNBCIC@BRFAPESP.BITNET Newsgroups: comp.lang.forth Subject: OOP Message-ID: <9105240407.AA06179@ucbvax.Berkeley.EDU> Date: 22 May 91 15:02:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: UNBCIC%BRFAPESP.BITNET@SCFVM.GSFC.NASA.GOV Organization: The Internet Lines: 82 => From: Ben Eaton => => 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