Jump to content

Always Include Options Or Check For Them


Liquid Fire

Recommended Posts

I am in the process of rebuild my ORM(or model) portion of my framework as my first version was very bulky and hard to maintain(even tho my out of the box, no extra configuration testing showed it was 2X faster then doctrine).  Now i am not sure which way is better or faster so let me ask here.  Basically i stored a static member that stores the configuration options for each field being pulled like:

 

<?php
self::$fields = array
(
'field1' => array
(
	'config1' => 'value1',
	'config2' => 'value2'
	//etc...
),
'field2' => array
(
	'config1' => 'value1',
	'config2' => 'value2'
	//etc...
)
etc...
);
?>

 

Right now there are a total of 9 possible configuration values(an by the end their might be a few more) and all but 2 have default values and don't need to be manually set.  Now i have 2 options and not sure which one will effect performance more, but i have an idea.  The 2 options are:

 

1. Make sure each configuration is set(required large file size but no code to check if a configuration is set so warning don't show).  This way i just set every configuration option for every field and that way i don't need !empty() or isset() code so that warning don't show up.  the thing is it could really up the file size where if the you only need on average 4 configuration but you always have all 11 and you have like 50 fields, that is a lot of extra code to parse.

 

2. Only put the configures you need and leave the rest out(smaller file sizes but code to make sure things are set to not throw warnings).  This will make the base model file smaller but i will need to add code to check to make sure configurations are set so no warning show up.

 

Now i am assuming that loading/parsing a large file is faster than doing check for configurations every time but maybe that is not the way i should go.  What do you think?

 

SIDE NOTE: The files i am taking about are automatically generated through a xml configuration file so tme to code the file is not a issue.

Link to comment
Share on other sites

I think the difference will be negligible. There's a third option btw: assign default values to optional indexes, then merge with given values. A lot less messy IMO.

 

If you really want to know, bench. It makes no sense asking us, when you could just test for it.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.