473,395 Members | 1,756 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,395 software developers and data experts.

objects,inheritance and insane abstraction

hi list,

i'm trying to lose some bad programming habits and write neat
and re-useable oo php5 code. At the moment i'm trying to write
a highly abstracted interface to ldap (just for fun) and I am not
sure if the way i'm proceeding is indeed the correct and sane way.

the way i see it, to accomplish the level of abstraction that i want,
i'll need objects like the following :
phpLdap(superclass), phpldapConnection, phpldapRecord, etc etc

<psuedo-ish code>

class phpLDAP { // a superclass ???
private $conn = NULL;
public $search;

function __construct ($someparms) {
// hand it of to a different class
$this->conn = new phpLDAPConnection($someparms);
}

function search($someparms) {
// hand this of to another class
$this->search = new phpLDAPSearchObject($someparms);
}
}

class phpLDAPConnection {
public $conn = NULL;

function __construct($someparms) {
// do ldap connection stuff
}

/** more stuff **/

function __destruct() { }
}

class phpLDAPSearchObject {

private $rawResult = NULL;
public $records = NULL;

function __construct($someparms) {
// search stuff
foreach($result as $searchResults) {
$this->records[z++] = new phpLDAPRecord($result);
}
}
}

</psuedo-ish code>

okay, above is a small piece of code example showing how i'm
connecting objects together.

the end result of all this should be being able to do something
like this :

<ldap-app.php>
$ldap = new phpLDAP($someparms);

if ($ldap->conn->Connected) { // property of phpLdapConnection
$ldap->search($someparms); // do a search

$search = &$ldap->search;

do {
// returns for ex: a phpLDAPRecord
$curRec = &$search->ActiveRecord;

// a method of a phpLDAPRecord
$curRec->count("DN");

// a property of a phpLDAPSearch
echo $search->count;

// a method of a phpLDAPSearch
echo $search->refresh();

// method of phpLDAPSearch
$search->next;

} while (!($search->BOF));
// etc etc
} // endif

</ldap-app.php>
I hope that what i'm trying to do is clear. I would like to now if
this is the correct way to do abstraction or if i'm missing the
plot completely.

thanks,
cillier

Jul 25 '06 #1
4 1367
in********@gmail.com wrote:
hi list,

i'm trying to lose some bad programming habits and write neat
and re-useable oo php5 code. At the moment i'm trying to write
a highly abstracted interface to ldap (just for fun) and I am not
sure if the way i'm proceeding is indeed the correct and sane way.

Just for the sake of adding some balance to any conversation that might
arise, many people believe that adopting too much OO is a worsening of bad
habits. It reveals itself in exactly the words you are using, "insane
abstraction".

There's a great satire (that I could not find on Google) about an
"advancing" computer programmer. As a beginner his Hello World! programs
take 2-3 lines. As he gets smarter and smarter they get larger and larger,
until it takes pages of OO-abstracted deeply nested hierarchies of objects
just to get a gol'darn Hello World! onto the page. Very sobering stuff.

--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)
Jul 25 '06 #2
Kenneth Downs wrote:
Just for the sake of adding some balance to any conversation that might
arise, many people believe that adopting too much OO is a worsening of bad
habits. It reveals itself in exactly the words you are using, "insane
abstraction".

There's a great satire (that I could not find on Google) about an
"advancing" computer programmer. As a beginner his Hello World! programs
take 2-3 lines. As he gets smarter and smarter they get larger and larger,
until it takes pages of OO-abstracted deeply nested hierarchies of objects
just to get a gol'darn Hello World! onto the page. Very sobering stuff.
Hehe. I call it the Emperor's New Coat syndrome. Even when it's plain
to see that there is not need to wrap something in a class, people do
it anyway because they're afraid that others will say they're stupid.

Jul 25 '06 #3

"Chung Leong" <ch***********@hotmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Kenneth Downs wrote:
>Just for the sake of adding some balance to any conversation that might
arise, many people believe that adopting too much OO is a worsening of
bad
habits. It reveals itself in exactly the words you are using, "insane
abstraction".

There's a great satire (that I could not find on Google) about an
"advancing" computer programmer. As a beginner his Hello World! programs
take 2-3 lines. As he gets smarter and smarter they get larger and
larger,
until it takes pages of OO-abstracted deeply nested hierarchies of
objects
just to get a gol'darn Hello World! onto the page. Very sobering stuff.

Hehe. I call it the Emperor's New Coat syndrome. Even when it's plain
to see that there is not need to wrap something in a class, people do
it anyway because they're afraid that others will say they're stupid.
This is the opposite (but similar) to what I called the "Name That Tune"
syndrome in the early days of C programming. Whiz kids would compete to see
how few lines they could use to write a For loop, for example. Often, when
for readability and debugging the code should have been 10 lines, it was
written as one line by some smartass, show-off programmer.

Shelly
Jul 26 '06 #4
Shelly wrote:
This is the opposite (but similar) to what I called the "Name That Tune"
syndrome in the early days of C programming. Whiz kids would compete to see
how few lines they could use to write a For loop, for example. Often, when
for readability and debugging the code should have been 10 lines, it was
written as one line by some smartass, show-off programmer.
One has to make a distinction between syntactical complexity and
analystical complexity. The human brain is very good at decoding
syntax. It's part of our innate capability to process language. Whereas
we're much more limited when it comes to solving analystical problems.
If you look at entries into the the Obfuscated C contest, for example,
you'll always find that their difficulty arises from twisted
logics--not strange syntax.

I am, of course, not arguing for hard to read code. I am just saying
that adding unnecessary structural complexity to a program is a far
greater sin. You can always clean up ugly code. You can't really fix an
overly complicated framework because your brain cannot fully understand
it.

Jul 26 '06 #5

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

Similar topics

6
by: Paul | last post by:
In real life situation, do we ever come across a situation where we would need two base objects in an object. A snippet is worth 1000 words (: so... class Base { }; class Derived1:public Base...
1
by: Tony Johansson | last post by:
Hello! What does this mean. "The use of inheritance to provide various implementations of a single abstraction tightly binds these implementations to the abstarction. Therfore it, is difficult...
2
by: Tony Johansson | last post by:
Hello! What does this mean. "The use of inheritance to provide various implementations of a single abstraction tightly binds these implementations to the abstarction. Therfore it, is...
8
by: Steven T. Hatton | last post by:
I've had an idea kicking around in my head regarding how to create a library of classes (templates?) that provide the same kind of functionality as do Java classes which all derive from the UBC...
38
by: Radi Radichev | last post by:
Hi! I'm making a database application and i heard from a friend that it is more proffecional and easy to do this with bussines objects. Can anyone tell me where i can find more info on bussines...
25
by: Penelope Dramas | last post by:
Hello, I'm in a front of very serious .net redesign/rewrite of an old VB6 application. I had been asked to make it .NET 2.0 and would like to ask couple of questions regarding data access as...
21
by: George Exarchakos | last post by:
Hi everyone, I'd like your help... Can we have a std::list<BASEwhere BASE be the base class of a class hierarchy? I want to add to this list objects that are inherited from BASE class but not...
14
by: JoeC | last post by:
I have been writing games and I also read about good programming techniques. I tend to create large objects that do lots of things. A good example I have is a unit object. The object controls...
6
by: Bart Simpson | last post by:
I remember reading on parashift recently, that "Composition is for code reuse, inheritance is for flexibility" see (http://www.parashift.com/c++-faq-lite/smalltalk.html#faq-30.4) This confused...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.