FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Dynamic form generation
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Dynamic form generation [message #177824 is a reply to message #177739] Sun, 22 April 2012 17:21 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
Tony Marston wrote:

> "Jerry Stuckle" wrote:
>> On 4/18/2012 4:33 AM, Tony Marston wrote:
>>>> If a framework attempts to be "all things to all people", then that's
>>>> quite true. But the same is true of *any* code.
>>>>
>>>> However, a limited framework with limited goals doesn't necessarily
>>>> have to be the case.
>>>>
>>>> For instance, in my case - I have a framework which builds PHP classes
>>>> to interface to a database. It generates a lot of usable code for
>>>> those classes, including form handling.
>>>
>>> So you framework generates "a lot" of code, does it? My framework
>>> generates very small amounts of code which call shared functions or
>>> which inherit code from abstract classes.
>>
>> Yup, for instance, it generates all the set and get methods for the
>> applicable class, as well as database access code (insert/update/delete
>> for single rows and single rows and lists of multiple rows for SELECT).
>> (Most of the access code is in parent classes).
>
> My framework does not bother generating set and get methods as they are
> inefficient. Data goes in and comes out as an array.

This means that you perform no type conversion or checking, or range
checking in the application, yes? Setters and getters maybe are less
efficient than direct access, but they can provide that functionality. They
also provide transparent access to the data model (i. e., if either your
requests or your database change, you do not have to change the request for
the database or the database for the request; you just change the mapping
code). Using arrays does not exclude the possibility for using setters and
getters or vice-versa, as setters and getters can be called implicitly, such
as from a constructor.

In the MVC-based framework I have written for my latest research, the parent
abstract `AbstractModel' class has an inherited public map() method that can
be passed an associative array (such as from a query result) and maps array
elements to object properties such that either all, only the specified or
not the specified elements in the passed array are mapped. That method is
called from the constructor so that I can write

$modelObj = new MyModel($array);

but if, and only if, I declare

public function setProperty($value)
{
$this->_property = convertPseudo($value);
return $this;
}

in the `MyModel' class, I can also add

$modelObj->setProperty($foo);

or

$modelObj->property = $foo;

to set the protected `_property' property of the object referred by
$modelObj to the value of $foo converted to a value of a type that
`_property' accepts, whereas the corresponding setter is called by the magic
`__set' method then. Likewise for read access and `__get'.

I have found that to be an effective, efficient and flexible combination.

>> It also generates the code necessary to validate a field. Some stock
>> fields (like "must be integer") have predefined validation functions.
>
> My framework does not generate any code to perform basic field validation
> as that is performed by a validation class which I wrote years ago.

So that validation class has become part of the framework, has it not?

>> It also has a function to populate the object from $_GET or $_POST values
>> (with validation).
>
> I don't need a whole function to do that when a single line will do:-
> $result = $object->insertRecord($_POST);
>
> This means that the same line will work on any object regardless of which
> class it came from. That is what polymorphism is all about.

It also means that your HTTP POST requests are inherently bound to the
structure of the database (table), does it not?

> I was never dishonest about the Radicore framework. I never said it was
> written by someone else. I even include a link to the radicore website in
> my signature.

I am going to look into it, then.

--
PointedEars
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Data injection problems
Next Topic: Do you want to develop PHP for the Web and make money
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 05:11:08 GMT 2024

Total time taken to generate the page: 0.04364 seconds