ID: 11567
User Update by: [EMAIL PROTECTED]
Status: Analyzed
Bug Type: Feature/Change Request
Operating system: Linux
PHP Version: 4.0.5
Description: True Dynamic Binding and Public/Private
I disagree with your comment on how dynamic bindings are used. The whole purpose of
dynamic binding is give a function whose purpose could be asked for in many different
ways yet is asking to do the same thing the ability to hide how it works from the
programmer using it. In C++, there is a function of exp, which could be sent four
different methods:
int exp (int base, int exponent)
double exp (int base, double exponent)
double exp (double base, int exponent)
double exp (double base, double exponent)
If anything, it makes the programmers job easier to utilize this function because they
only have to remember ONE function, not four different ones accomplishing the same
task.
Admittedly, PHP doesn't have data types in the traditional sense, however it should
have Dynamic Binding because one of the most fundamental rules of Object Oriented
Programming is the idea of hiding the how and just utilizing the functions and
classes.
The same argument can be made for the public/private distinction. Adding this feature
is an excellent way to make sure that programmers do not mess with the logical code
that you worked so hard on. Also, it forces programmers to use the functions of the
class, as the orginal programmer percieved it.
I want to see PHP become the best Web Programming Language out there, and proper OOD
techniques is fundamental to getting there.
Previous Comments:
---
[2001-06-20 00:42:51] [EMAIL PROTECTED]
I completely disagree with the concept of dynamic binding.
Calling different functions based on the number of arguments
is spaghetti code waiting to happen. PHP supports default
values for arguments which makes them optional. Your
would be much cleaner if written with defaulted x and y
arguments which you then check and if you have the default
value for x and/or y you would calculate the center value.
Or alternatively use func_num_args to see how many args were
passed. To me it is cleaner to collect the functionality for a function in a single
function instead of splitting it
out over multiple functions. Imagine trying to debug some
code and you end up looking at the wrong function just
because you counted 17 arguments instead of 18.
As for the public/private issue. Sure, from an OO purity
perspective it would be nice. But it is functionally irrelevant. ie. your code would
not work any better or
worse by having the public/private differentiation.
---
[2001-06-19 22:05:53] [EMAIL PROTECTED]
function drawMe()
{
if( 2 == func_num_args() ) {
doStuff( func_get_arg(0) , func_get_arg(1) ) ;
} else {
doStuff( $defaultX , $defaultY ) ;
}
}
private vars/methods would be good... :)
---
[2001-06-19 15:10:06] [EMAIL PROTECTED]
Ok Folks. I am really happy with PHP thus far. However to make it a true Object
Oriented Language you absolutly need Dynamic binding. This would be such a huge boon
for us developers who love to work within classes. Such as:
// Inside the class Circle
function DrawMe() {
// Getting Ceter Coords..
DrawMe($centX, $centY);
}
function DrawMe($x, $y) {
// Draws the circle at $x, $y
}
// End of code demo
This kind of ability can be extremely huge, if you use it right. Also, it allows for
developers to make a module extremely flexiable and powerful.
Secondly, I think that we are missing public and private sections of the OOP world.
In the above example, I would have the functions public, and the data structures
inside of it totally hidden (or private) so the programmer who is using my include
just has to deal with the interface, and can't touch the actual data. That is
strength and beauty of encapsulation.
I just thought you may want to hear this, and I am hoping to hear from you guys (and
gals) that you are hard at work to implement it and it is coming soon.
Thanks for reading my rant!!
Mike Eggleston
AmeriGroup
[EMAIL PROTECTED]
---
Full Bug description available at: http://bugs.php.net/?id=11567
--
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]