Status update: ActiveRecord

I don’t like ‘self’ as it is used as ‘this’ in some languages.

How about @me and @rel ?

It’s short. :)

Can’t say I particularly fancy shortened versions :) Here are some/the currently suggested alternatives:

@this and @that

@self and @foreign

@self and @other

@self and @related

@self and @link

@self and @rel

@this and @rel

@me and @rel

I like @self and @rel best. They are easy/fast to type, descriptive and consistent with Yii’s terminology.

Trying to imagine myself in the place of a Yii learner, i gotta disagree. @rel is almost as cryptic as the original proposal of @ and ?.

Of all the proposals made so far, i think

[b]@self

@foreign[/b]

are most likely to be readily understood by a noob.

Saving 4 characters isn’t worth it.

This is a good question!

In a relation spec, @foreign clearly has a role.

But in other contexts, is there a use for a shorthand for one of the relation names in the global relation namespace? How do I (and AR) know which it refers to?

In Yii 1.1 AR, queries and scopes can be used with zero, 1 or more related models. Unless Yii 2 AR has methods specifically for using 1 specified related model, where’s the opportunity to use @foreign?

What? No. We’re using a technique called related Active Records. Used to fetch related entries from the database. related -> @rel. Easy to remember, fast to type. Really can’t share your view on that.

IMO there is no need to shorten as much as possible… @related makes more sense then @rel and has same number of letters as foreign… but it’s more intuitive and easier to write for non-english users

I too am part of the school that prefers elaborate naming of variables, functions, etc. I don’t see the use in saving a few characters as in @rel at the cost of cluttering code with shortened keywords, when it can instead look like beautifully written poetry (that is actually well written) :3

I agree.

I suggest

@own and @other

Is there any answer to my question about when the "?." applies?

Either all this discussion over a better name for ?. is stupid or rAWTAZ and I are stupid. (no disrespect :)

Does anyone have some insight on what ?. is used for other than in a relation definition?

For me discussion about replacments for ‘@’ and ‘?’ is discussion about nothing.

It seems like we pick less important design solution from the Qiang’s post and have a lot of buzz about it.

For Yii newcomers it is absolutely not necessary to use such things. Placeholders can be extremely useful when writing unified code such as active record behavior to avoid hardcoding of table names or configuration for table names. And writing behaviors is not what new users will start from.

So I think original proposal (@ and ?) is good.

Regarding the use of "?" - as I remember there was such feature in Yii 1.0 where we had aliasToken in CActiveRelation class, so we could use something like "??.name" to refer related table column.

And (I may be wrong) it only worked when you have one relation - in other cases you had to set aliasToken properties for relations manually. So I guess here we can have similar situation - ‘?’ will work only when one related table is involved.

Personaly I prefer more meaningfull names for the aliases - "@" and "?" looks fine, but if you do not use them all the time you will have to look up the docs to refresh the memory of what is what. In this case "@self" and "@related" (or "@foreign") are better.

I’m actually a Professional Product Designer, with a thesis on user interface and interactions, that loves programming and web technologies. I’ve been programming computers, robots and web sites since I was 12 (pardon the lengthy introduction).

If I where to define these keywords, according to the user experience and interaction principles I would definitely go for @self and @related/@linked

- ?

@related is self explanatory for anyone that knows what a foreign key relationship is. it’s easy to write for non native English speakers, and the keys are grouped near on the keyboard.

@linked could be an option, but again, related is better in my opinion, because of the consistency with SQL language.

@foreign easier to understand than @related, but MUCH more difficult to write even for native English speakers; GN NG endings on words are hard to discriminate for most non natives, also EI IE is a problem for many non natives because of accent and pronunciation.

@rel doesn’t offer any real advantages over “?”, opens up to subjective interpretation and confusion.

- @

@self is self explanatory, easy to write and it’s consistent with PHP/YII language dynamics.

@this can cause confusion because it can easily be taken out of context, and it’s not any easier to write than “self”.

I hope this helps out!

@3amsleep you explained very well all my thoughts about those names :D

So maybe this nasty naming discussion can come to an end now :). Must be very frustrating for core developers to see, that all that people care about in this awesome new code is a tiny naming issue. I trust the team, that they will now have all information they need to take the right decision. We would only repeat ourselves. Or, as a german saying goes: Every aspect was mentioned - but not yet by everyone ;)

Super nice summary and thoughtful details 3amsleep!

I agree with Mike. I have no idea why this naming discussion had to be so insanely long. @self and @related is a no-brainer :P

The reason why we discuss tiny issues is that we’ve run out of bigger issues, so the Yii team should take that as a compliment IMO. ;)

@self and @related sounds great to me. :)

Well put :D

Bikeshedding - http://en.wikipedia.org/wiki/Parkinson’s_Law_of_Triviality

A group of people give weight to trivial issues, obscuring the important issues at hand. This occurs because the important issues generally require significant domain knowledge or complicated mental evaluation, whereas the trivial issues are by definition trivial and therefore it’s easy to have an opinion one way or the other.