RE: [PHP] advise on new class of mine

2003-11-07 Thread Erik Osterman
It almost sounds like you've not yet drawn out an object map on a piece of
paper to see for youself how everything is inter-connected. I'm sure this is
the _perfect_ opportunity for using classes, but at the same time will
require some good thought now before you go a head and implement it. Good
object design doesn't just happen, it's thought out.

As for instantiation (creating the objects), don't worry about this just yet
(Unless you're using some gross amount of memory). Very often, the cost for
optimizing your code before it's actually written doesn't help. There are so
many unforeseen inefficiencies you will encounter; simply not allocating a
class here or there will be the least of your worries. 

Some advice: Write the code as it makes sense in your mind and on paper.
Then worry about how to optimize it. Even Knuth himself said, Premature
optimization is the root of all evil

 Best Regards,

Erik Osterman
http://osterman.com/


-Original Message-
From: jsWalter [mailto:[EMAIL PROTECTED] 
Sent: Sunday, September 21, 2003 4:12 PM
To: [EMAIL PROTECTED]
Subject: [PHP] advise on new class of mine

I'm in the process of building my first real class.

43 methods, 23 properties, nearly 1000 lines of codes.

What I would like to know...

Is it better to keep al this in a single file? Or break it up into
sub-classes?

This does have logical sections, so a breakup would be possible, but then
I'm not sure how I would piece it back together.

Also...

Many properties are not required at object instantiation, but I define them
none-the-less. Many are derived from multiple others.

It is better to define all properties, many may never be used, or simply
define them as they are called?

I define them all now, so there is a (ever so) slight hit on cycles for
this.

If I define them as they are called, then each needs a conditional to
process to run each time that GETTER is called.

Or is this 6 of one and half-dozen of another?

Now, this gets broken up, many of the properties correspond the different
sections. then he properties should be defined as called, because their
package would only be loaded when called.

Am I talking in circles here?

Does anyone have any advise?

Thanks

Walter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] advise on new class of mine

2003-09-22 Thread Curt Zirzow
* Thus wrote jsWalter ([EMAIL PROTECTED]):
 I'm in the process of building my first real class.
 
 43 methods, 23 properties, nearly 1000 lines of codes.

hmm. that is large.

 
 What I would like to know...
 
 Is it better to keep al this in a single file? Or break it up into
 sub-classes?

yes. 

 
 This does have logical sections, so a breakup would be possible, but then
 I'm not sure how I would piece it back together.

Now comes the hard part. its most likely going to take much
thought and probably some research as to how to seperate them.
Putting them back together is the easy part.

Here is a small simple example 

class Person {
  var $hand = array(2 hands);
  var $foot = array(2 feet);

  function drink($hand, $obj) { }
  function step($foot) { }
}

class beermug {
  var $amt = ! 0; // 
}

class car {
  var $seats = array(2 seats); // its a sports car.
  function gaspeddle($action, $amt) { };
}

// now the tying together...

$me = new Person();
$ipa = new beermug(100% full);
$me-drink(right, $ipa);

wait(1 hour);

$porche = new car('red'); // i wish it was that easy

// somehow magically get in the car

$car-gaspeddle($me-step(right), 100%);

There are proably better ways to approach my person/beerbug/car
relation ship, but I just put this quickly together to show how
items could be tied together.  OO programming can get very complex
and all depends on how detailed and isolated you want your objects.

 
 Also...
 
 Many properties are not required at object instantiation, but I define them
 none-the-less. Many are derived from multiple others.
 
 It is better to define all properties, many may never be used, or simply
 define them as they are called?
 
 I define them all now, so there is a (ever so) slight hit on cycles for
 this.

when you seperate the code this may not be a big issue.

 
 If I define them as they are called, then each needs a conditional to
 process to run each time that GETTER is called.
 
 Or is this 6 of one and half-dozen of another?
 
 Now, this gets broken up, many of the properties correspond the different
 sections. then he properties should be defined as called, because their
 package would only be loaded when called.
 
 Am I talking in circles here?

well sorta, i got kinda confuse with these last few items. 


HTH,

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] advise on new class of mine

2003-09-22 Thread jsWalter
Thanks Curt for your reply.

It helped my head a bit.

Walter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] advise on new class of mine

2003-09-21 Thread jsWalter
I'm in the process of building my first real class.

43 methods, 23 properties, nearly 1000 lines of codes.

What I would like to know...

Is it better to keep al this in a single file? Or break it up into
sub-classes?

This does have logical sections, so a breakup would be possible, but then
I'm not sure how I would piece it back together.

Also...

Many properties are not required at object instantiation, but I define them
none-the-less. Many are derived from multiple others.

It is better to define all properties, many may never be used, or simply
define them as they are called?

I define them all now, so there is a (ever so) slight hit on cycles for
this.

If I define them as they are called, then each needs a conditional to
process to run each time that GETTER is called.

Or is this 6 of one and half-dozen of another?

Now, this gets broken up, many of the properties correspond the different
sections. then he properties should be defined as called, because their
package would only be loaded when called.

Am I talking in circles here?

Does anyone have any advise?

Thanks

Walter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php