473,383 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

What are OOP's Jargons and Complexities?


What are OOP's Jargons and Complexities
Xah Lee, 20050128

The Rise of Classes, Methods, Objects

In computer languages, often a function definition looks like this:
subroutine f (x1, x2, ...) {
variables ...
do this or that
}

In advanced languages such as LISP family, it is not uncommon to define
functions inside a function. For example:
subroutine f (x1, x2, ...) {
variables...
subroutine f1 (x1...) {...}
subroutine f2 (x1...) {...}
}

Often these f1 f2 inner functions are used inside f, and are not
relevant outside of f. Such power of the language gradually developed
into a style of programing. For example:
subroutine a_surface () {
coordinatesList = ...;
subroutine translate (distance) {...}
subroutine rotate (angle) {..}
}

Such a style is that the a_surface is no longer viewed as a function.
But instead, a boxed set of functions, centered around a piece of data.
And, all functions for manipulating this piece of data are all embodied
in this function. For example:
subroutine a_surface (arg) {
coordinatesList = ...
subroutine translate (distance) {set coordinatesList to translated
version}
subroutine rotate (angle) {set coordinatesList to rotated version}
subroutine return () {return coordinatesList}

if (no arg) {return coordinatesList}
else { apply arg to coordinatesList }
}

In this way, one uses a_surface as a data, which comes with its owe set
of functions:
mySurface = a_surface();
mySurface(rotate(angle)); // now the surface data has been
rotated
mySurface(translate(distance)); // now its translated
newSurface = mySurface(return())

So now, a_surface is no longer viewed as a subroutine, but a boxed set
of things centered around a piece of data. All functions that work on
the data are included in the boxed set. This paradigm possible in
functional languages has refined so much so that it spread to other
groups and became known as Object Oriented Programing, and complete
languages with new syntax catered to such scheme emerged.

In such languages, instead of writing them like this:
mySurface = a_surface();
mySurface(rotate(angle));

the syntax is changed to like this, for example:
mySurface = new a_surface();
mySurfaceRotated = mySurface.rotate(angle);

In such languages, the super subroutine a_surface is no longer called a
function or subroutine. It is now called a “Class”. And nowthe
variable holding the function "mySurface = a_surface()" is now called a
“Object”. Subroutines inside the function a_surface() are no longer
called inner-subroutines. They are called “Methods”. The act of
assigning a super-subroutine to a variable is called instantiation.

This style of programing and language have become so fanatical that in
such dedicated languages like Java, everything in the language are
“Classes”. One can no longer just define a variable or subroutine.
Instead, one creates these meta-subroutine “Classes”. Everything
one do are inside Classes. And one assign Classes inside these Classes
to create “Objects”. And one uses “Methods”to manipulate
Objects. In this fashion, even basic primitives like numbers, strings,
and lists are no longer atomic entities. They are now Classes.

For example, in Java, a string is a class String. And inside the class
String, there are Methods to manipulate strings, such as finding the
number of chars, or extracting parts of the string. This can get very
complicated. For example, in Java, there are actually two Classes of
strings: One is String, and the other is StringBuffer. Which one to use
depends on whether you intend to change the data.

So, a simple code like this in normal languages:
a = "a string";
b = "another one";
c = join(a,b);
print c;

or in lisp style
(set a "a string")
(set b "another one")
(set c (join a b))
(print c)

becomes in pure OOP languages:
public class test {
public static void main(String[] args) {
String a = new String("a string");
String b = new String("another one");
StringBuffer c = new StringBuffer(40);
c.append(a); c.append(b);
System.out.println(c.toString());
}
}

Here, the "new String" creates a String object. The "new
StringBuffer(40)" creates the changeable string object StringBuffer,
with room for 40 chars. "append" is a method of StringBuffer. It is
used to join two Strings.

Notice the syntax "c.append(a)", which we can view it as calling a
inner subroutine "append", on a super subroutine that has been assigned
to c, where, the inner subroutine modifies the inner data by appending
a to it.

And in the above Java example, StringBuffer class has another method
"toString()" used to convert this into a String Class, necessary
because System.out.println's parameter requires a String type, not
StringBuffer.

For a example of the complexity of classes and methods, see the Java
documentation for the StringBuffer class at
http://java.sun.com/j2se/1.4.2/docs/...ingBuffer.html
(local copy)

In the same way, numbers in Java have become a formalization of many
classes: Double, Float, Integer, Long... and each has a bunch of
"methods" to operate or convert from one to the other.

Instead of
aNumber = 3;
print aNumber^3;

In Java the programer needs to master the ins and outs of the several
number classes, and decide which one to use. (and if a program later
needs to change from one type of number to another, it is often
cumbersome.)

This Object Oriented Programing style and dedicated languages (such as
C++, Java) have become a fad like wild fire among the programing mass
of ignoramuses in the industry. Partly because of the data-centric new
perspective, partly because the novelty and mysticism of new syntax and
jargonization.

It is especially hyped by the opportunist Sun Microsystems with the
inception of Java, internet, and web applications booms around 1995. At
those times, OOP (and Java) were thought to revolutionize the industry
and solve all software engineering problems, in particular by certain
"reuse of components" concept that was thought to come with OOP.

As part of this new syntax and purity, where everything in a program is
of Classes and Objects and Methods, many complex issues and concept
have arisen in OOP.

We now know that the jargon Class is originally and effectively just a
boxed set of data and subroutines, all defined inside a subroutine. And
the jargon "Object" is just a variable that has been set to this super
subroutine. And the inner subroutines are what's called Methods.

----------
to be continued tomorrow.

This is part of an installment of the article
“What are OOP's Jargons and Complexities”
by Xah Lee, 20050128. The full text is at
http://xahlee.org/Periodic_dosage_dir/t2/oop.html

© Copyright 2005 by Xah Lee. Verbatim duplication of the complete
article for non-profit purposes is granted.

The article is published in the following newsgroups:
comp.lang.c,comp.lang.c++,comp.lang.lisp,comp.unix .programmer
comp.lang.python,comp.lang.perl.misc,comp.lang.sch eme,comp.lang.java.programmer
comp.lang.functional,comp.object,comp.software-eng,comp.software.patterns

Xah
xa*@xahlee.org
http://xahlee.org/

Jul 19 '05
56 3672
Matthias Buelow wrote:
And btw., I haven't used Pascal in a dozen years but my latest info is
that Turbo Pascal still lives in the form of "Delphi" for the Windows
platform. Surely not "dead" as I understand it.


There's also FreePascal, which compiles approximately the
same language as Turbo Pascal/Delphi, (and inherits most of
Borland's linguistic extensions) and is opensource, works
fine on Unixes, etc. It's in active use by several people,
making games.

Bear

Jul 19 '05 #51
The Rise of “Inheritance”

In well-thought-out languages, functions can have inner functions, as
well as taking other functions as input and return function as output.
Here are some examples illustrating the use of such facilities:
subroutine generatePower(n) {
return subroutine (x) {return x^n};
}

In the above example, the subroutine generatePower returns a function,
which takes a argument and raise it to nth power. It can be used like
this:
print generatePower(2)(5) // prints 25

Example: fixedPoint:
subroutine fixedPoint(f,x) {
temp=f(x);
while (f(x) != temp) {
temp=f(temp);
}
return temp;
}

In the above example, fixedPoint takes two arguments f and x, where f
is taken to be a function. It applies f to x, and apply f to that
result, and apply f to that result again, and again, until the result
is the same. That is to say, it computes f[f[f[...f[x]...]]].
FixedPoint is a math notion. For example, it can be employeed to
implement Newton's Method of finding solutions as well as many problems
involving iteration or recursion. FixedPoint may have a optional third
parameter of a true/false function fixedPoint(func,arg,predicate) for
determining when the nesting should stop. In this form, it is
equivalent to the “while loop” in procedural languages.

Example: composition:
subroutine composition(a,b,c,...) {
return subroutine {a(b(...c...))};
}

The above example is the math concept of function composition. That is
to say, if we apply two functions in sequence as in g[f[x]], then we
can think of it as one single function that is a composition of f and
g. In math notation, it is often denoted as (g∘f). For example,
g[f[x]]→y is the same as (g∘f)[x]→y. In our pseudo-code, the
function composition takes any number of arguments, and returns a
single function of their composition.

When we define a subroutine, for example:
subroutine f(n) {return n*n}

the function is power of two, but the function is named f. Note here
that a function and its name are two different concepts. In
well-thought-out languages, defining a function and naming a function
are not made inseparable. In such languages, they often have a keyword
“lambda” that is used to define functions. Then, one can assign it
a name if one so wishes. This separation of concepts made many of the
lingustic power in the above examples possible. Example:
lambda (n) {return n^2;} \\ a function
(lambda (n) {return n^2;})(5) \\ a function applied to 5.
f = lambda (n) {return n^2;} \\ a function is defined and named
f(5) \\ a function applied to 5.
lambda (g) {return lambda {g(f)} } \\ a function composition of
(g∘f).
The above facilities may seem exotic to industrial programers, but it
is in this milieu of linguistic qualities the object oriented paradigm
arose, where it employees facilities of inner function (method),
assigning function to variable (instantiation), function taking
function as inputs (calling method thru object), and application of
function to expressions (applying method to data in a class).

The data-bundled-with-functions paradigm finds fitting application to
some problems. With the advent of such Objet-Oriented practice, certain
new ideas emerged. One of great consequence is the idea of inheritance.

In OOP practice computations are centered around data as entities of
self-contained boxed sets (objects). Thus, frequently one needs
slightly different boxed sets than previously defined. Copy and Pasting
existing code to define new boxed sets quickly made it unmanageable. (a
messy set of classes). With powerful lingustic evironment and
habituation, one began to write these new boxed-subroutines (classes)
by extending old subroutines (classes) in such a way that the new
subroutine contains all variables and subroutines of a base subroutine
without any of the old code appearing in the body of the subroutine.
Here is a pseudo-code illustration:
g = subroutine extend(f) {
new variables ...
new inner-subroutines ...
return a subroutine that also contains all stuff in subroutine f
}

Here, “extend” is a function that takes another function f,and
returns a new function such that this new function contains all the
boxed-set things in f, but added its own. This new boxed-set subroutine
is given a name g.

In OOP parlance, this is the birth of inheritance. Here, g inherited
from that of f. f is called the base class or superclass of g. g is the
derived class or subclass of f.

In functional terms, inheritance mechanism is a function E that takes
another function f as input and returns a new function g as output,
such that g contained all enclosed members of f with new ones defined
in E. In pure OOP languages such as Java, the function E is exhibited
as a keyword “extends”. For example, the above code would be in
Java:
class g extends f {
new variables ...
new inner-subroutines ...
}

Here is the same example in Python, where inheritance takes the form of
a class definition with a parameter:
class g(f):
new variables ...
new inner-subroutines ...
Data are the quintessence in computation. Because in OOP all data are
embodied in classes, and wrapping a class to each and every variety of
data is unmanageable, inheritance became the central means to manage
data.

-----
to be continued tomorrow.

This is part of an installment of the article
“What are OOP's Jargons and Complexities”
by Xah Lee, 20050128. The full text is at
http://xahlee.org/Periodic_dosage_dir/t2/oop.html

© Copyright 2005 by Xah Lee. Verbatim duplication of the complete
article for non-profit purposes is granted.

The article is published in the following newsgroups:
comp.lang.c,comp.lang.c++,comp.lang.lisp,comp.unix .programmer
comp.lang.python,comp.lang.perl.misc,comp.lang.sch eme,comp.lang.java.programmer
comp.lang.functional,comp.object,comp.software-eng,comp.software.patterns

Xah
xa*@xahlee.org
http://xahlee.org/

Jul 19 '05 #52
<posted & mailed>

Paul McGuire wrote:
we just recently on
this forum had someone ask about "polymorphism" when what they really
meant was "overloaded method signatures." (It is even more unfortunate
that language features such as overloaded method signatures and
operator overloading get equated with OOP


I've actually heard "overloaded method signatures" be referred to as ad-hoc
polymorphism. Aren't there like 4 types of polymorphism: inheritance,
ad-hoc, parameter templetization (sp?), and something else...can't
remember.

-- C

Jul 19 '05 #53
Xah Lee wrote:
to be continued tomorrow.


Please don't...

mkb.
Jul 19 '05 #54
On Wed, 01 Jun 2005 23:25:00 +0200, Matthias Buelow <mk*@incubus.de>
wrote:
Of course it is a language, just not a standardized one (if you include
Borland's extensions that make it practical).


The history of "runtime error 200" and its handling from
borland is a clear example of what I mean with a product.

You are of course free to call even Microsoft Access a
language (and make long term investment on it) if you want.

Andrea
Jul 19 '05 #55
On Sun, 05 Jun 2005 16:30:18 +0200, Matthias Buelow <mk*@incubus.de>
wrote:
Quite embarrassing, but it's a runtime bug and got nothing to do with
the language per se. And it certainly manifests itself after the
hey-days of Turbo Pascal (when Borland seems to have lost interest in
maintaining it.)


The point is not the bug, of course, but how borland handled
it. It appeared when the user community of borland pascal
was well alive and kicking, but borland didn't even invest
5 seconds for the issue. The users had to fix the library
themselves (possible because at that time with Borland Pascal
you were getting the whole source code of the library; but
note that it was a 100% genuine bug due to misprogramming,
fixing it even on a dead product would have been the a nice
move from borland). The user community went even further,
as so many executables were written witn borland pascal that
a special tool for binary patching executables was built
(actually a few of them, as being unofficial it wasn't
that simple to get to know that such a tool existed, so
different people independently resorted to the same solution).

Andrea
Jul 19 '05 #56
The Rise of Class Hierarchy

Because of psychological push for purity, in Java there are no longer
plain subroutines. Everything is a method of some class. Standard
functions like opening a file, square root a number, for loop thru a
list, if else branching statements, or simple arithmetic operations...
must now somehow become a method of some class. In this way, coupled
with the all-important need to manage data with inheritance, the OOP
Class Hierarchy is born.

Basic data types such as now the various classes of numbers, are now
grouped into a Number class hierarchy, each class having their own set
of methods. The characters, string or other data types, are lumped into
one hierarchy class of data types. Many types of lists (variously known
as arrays, vectors, lists, hashes...), are lumped into a one hierarchy,
with each Classe node having its own set methods as appropriate. Math
functions, are lumped into some math class hierarchy.

Now suppose the plus operation +, where does it go? Should it become
methods of the various classes under Number headings, or should it be
methods of the Math class set? Each language deals with these issues
differently. As a example, see this page for the hierarchy of Java's
core language classes:
http://java.sun.com/j2se/1.4.2/docs/...kage-tree.html
(local copy)

OOP being inherently complex exacerbated by marketing propaganda, and
the inheritance and hierarchy concept is so entangled in OOP, sometimes
OOP is erroneously thought of as languages with a hierarchy. (there are
now also so-called Object-Oriented databases that ride the fad of
“all data are trees” ...)

Normally in a program, when we want to do some operation we just call
the subroutine on some data. Such as
open(this_file)
square(4)

But now with the pure OOP style, there can no longer be just a number
or this_file path, because everything now must be a Object. So, the
"this_file", usually being just a string representing the path to a
file on the disk, is now some "file object". Initiated by something
like
this_file = new File("path to file");

where this file class has a bunch of methods such as reading or writing
to it.

see this page for the complexity of the IO tree
http://java.sun.com/j2se/1.4.2/docs/...kage-tree.html
(local copy)

see this page for the documentation of the File class itself, along
with its 40 or so methods and other things.
http://java.sun.com/j2se/1.4.2/docs/...a/io/File.html (local copy)

-------
to be continued...

This is part of an installment of the article
“What are OOP's Jargons and Complexities”
by Xah Lee, 20050128. The full text is at
http://xahlee.org/Periodic_dosage_dir/t2/oop.html

© Copyright 2005 by Xah Lee. Verbatim duplication of the complete
article for non-profit purposes is granted.

The article is published in the following newsgroups:
comp.lang.c,comp.lang.c++,comp.lang.lisp,comp.unix .programmer
comp.lang.python,comp.lang.perl.misc,comp.lang.sch eme,comp.lang.java.programmer
comp.lang.functional,comp.object,comp.software-eng,comp.software.patterns

Xah
xa*@xahlee.org
http://xahlee.org/

Jul 19 '05 #57

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Xah Lee | last post by:
in computer languages, often a function definition looks like this: subroutine f (x1, x2, ...) { variables ... do this or that } in advanced languages such as LISP family, it is not uncommon...
17
by: Xah Lee | last post by:
What are OOP's Jargons and Complexities Xah Lee, 20050128 The Rise of Classes, Methods, Objects In computer languages, often a function definition looks like this: subroutine f (x1, x2, ...)...
18
by: Xah Lee | last post by:
What are OOP's Jargons and Complexities Xah Lee, 20050128 Classes, Methods, Objects In computer languages, often a function definition looks like this: subroutine f (x1, x2, ...) {...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.