|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
PHP 5 Inheritance
I am making my first real journeys into OO development, using
PHP 5 if you are interested ![]() Anyway, I have several classes that have nothing in common except that they all need the same validation performed on some of their properties. They do not / can not extend from the same parent. My question is quite simply, is building a static validator class and calling the class methods the proper OO Way to solve this. If so is it a pattern and does it have a name? |
|
#2
|
||||
|
||||
|
I'm not familiar with PHP however talking purely of OO programming, you need to
be able to inherit multiply parents, or at least be able to implement more than one Interface. is this possible in PHP? if so, build interface/base class with the common properties that will also contain the validator as virtual function. then, each implementing class will have this validator. |
|
#3
|
||||
|
||||
|
PHP is single inheritance.
Anyway I decided that if an item needs specific validation, I should make it a class. That way I can encapsulate any functionality within it. Examples of what I will use this for Email Addresses URLs |
|
#4
|
||||
|
||||
|
yep having class with "static" functions like VerifyEmail, VerifyURL should be
good enough. are you doing it for experience only? ![]() |
![]() |
| Viewing: ASP Free Forums > Other > Programming Help > PHP 5 Inheritance |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|