To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
Code CritiqueHaving someone critique your code is always a great way to hone the skills. Stop in and post your code to see what your peers may have done differently.
Re small functions:
Just how I was tought to do it. Makes a bit more sense in Java, I'd make all the class variables private and then access is only allowed to them through the relevant function making it imposible to update it accept through the proper means.
I have found out that it doesn't work if the number of pages is less than the IN_LIST variable. I made a change to it last night to cover this but I can;t quite remember it (and it's at home) If I get some time later I'll try and sort it out.
Bubble
__________________
If at first it doesn't work, slap it with a dirty hack.
Moral of the week: Never let a moral of the week go on for more than a week, it's even sillier than feeding the admins.
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,122
Quote:
Originally posted by bubblenut Re small functions:
Just how I was tought to do it. Makes a bit more sense in Java, I'd make all the class variables private and then access is only allowed to them through the relevant function making it imposible to update it accept through the proper means.
For example, a complex number might be described in either Cartesian form (x+iy) or in polar form (rcis(θ)). Enforcing a get/set interface means you can have $cx_num->getX(), $cx_num->getY(), $cx_num->getR(), $cx_num->getTheta() and corresponding set methods without having to expose just which representation is being used internally by the class (maybe one, maybe the other, maybe neither, maybe both either synchronously or asynchronously - it doesn't matter!).
Just as an FYI, PHP will distinguish between the property $object->foo and the method $object->foo(). Saves on using "get" a lot. If you don't mind something of an abuse of power, $object->foo() could get the value of $object->foo, and $object->foo($bar) could set it. Whether that's a good idea or not though is debatable.
Also, with PHP5, you can declare properties to be private, and so can enforce the interface.
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
Last edited by Weedpacket; 02-05-2004 at 05:55 AM.
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,122
Quote:
Originally posted by planetsim But that will only start to be used widely when PHP 5 is stable its currently still a beta be a few more months cannot wait.
I didn't realise you were in such a rush.
Besides, if you write get/set interface methods now, upgrading to declare properties private in PHP5 would just be a matter of putting "private" declarations in the class definition. Not doing so, and accessing properties directly, would mean privatising involves going through all the scripts that use the class and digging out all the places where those properties are accessed.
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
Last edited by Weedpacket; 02-05-2004 at 05:23 PM.
//logic for setting up parameters to send to Data Layer
//Get vars are different then keys
//set the default sort if no sort is given, primarily sent by the column icon
$Paging['SortType'] = ( isset($PARAMS['Sort']) ) ? $PARAMS['Sort'] : ASC;
//set the default order if no order is given, primarily sent by the column icon
$Paging['OrderBy'] = ( isset($PARAMS['Order']) ) ? $PARAMS['Order'] : $DEFAULT_ORDER_BY;
//always start at zero if and only if an offset is not supplied
$Paging['PageOffset'] = ( !empty($PARAMS['Offset']) ) ? $PARAMS['Offset'] : 0 ;