Alternative for ARRAY keyword

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Alternative for ARRAY keyword

Post by John Cartwright »

So I have this data factory class (seen below), which will populate the correct data container object with it's data depending on what type of data your specifying it as (or leaving it to auto detect if none specified). However, this is not my issue and just wanted to give a little background.

Now, my problem is ARRAY is a reserved word in PHP. So, instead of ARRAY, I have used the word COLLECTION. This doesn't quite sit well with me, and was wondering if anyone thought this was a good substitute or if they can recommend something better.

I know I'm kind of knit picking, but was just curious about public opinion.

Thanks!

Code: Select all

class Northern_Data
{
	const CURRENCY 	 = 'Northern_Data_Currency';
	const INT32 	 = 'Northern_Data_Int32';
	const INT64 	 = 'Northern_Data_Int64';
	const STRING     = 'Northern_Data_String';
	const COLLECTION = 'Northern_Data_Collection';
 
        //snip snip
}
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: Alternative for ARRAY keyword

Post by DigitalMind »

DIM, DIMENSION (like in Basic) :)
SET
but COLLECTION is good enough name. Maybe it's even the best choice for this case. :)
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Alternative for ARRAY keyword

Post by Eran »

I like LIST
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: Alternative for ARRAY keyword

Post by DigitalMind »

pytrin wrote:I like LIST
Yes, that's also good name for 1D arrays
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Alternative for ARRAY keyword

Post by John Cartwright »

LIST was what I was looking for! Thanks for all the good suggestions guys.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Alternative for ARRAY keyword

Post by josh »

You have a problem with array but not string? Its the inconsistency that kills me. Why not rename 'string' to 'text', either that or just 'array' to be consistent. I prefer 'array' if its a framework intended for programmer's consumption. As far as I know, if you won't need to create a function called array() you won't run into a reserved name issues. I name variables as $return and things like that all the time, no issues. A lot of old school programmers call it a bad practice but I don't see how. In Java or C++ or Ruby, maybe.... PHP not so much.
Post Reply