Yii Framework Forum: Status update: ActiveRecord - Yii Framework Forum

Jump to content

  • (7 Pages)
  • +
  • « First
  • 3
  • 4
  • 5
  • 6
  • 7
  • You cannot start a new topic
  • You cannot reply to this topic

Status update: ActiveRecord

#81 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 08 June 2012 - 10:33 AM

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

How about @me and @rel ?

It's short. :)
"Less noise - more signal"
0

#82 User is offline   rAWTAZ 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 08-January 10

Posted 08 June 2012 - 10:46 AM

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
0

#83 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,222
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 08 June 2012 - 11:25 AM

I like @self and @rel best. They are easy/fast to type, descriptive and consistent with Yii's terminology.
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
0

#84 User is offline   fsb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 123
  • Joined: 09-January 11

Posted 11 June 2012 - 09:29 AM

View PostDa:Sourcerer, on 08 June 2012 - 11:25 AM, said:

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

@self
@foreign


are most likely to be readily understood by a noob.

Saving 4 characters isn't worth it.
Join the happiest place on Freenode: #yii
We've got a MrFisk the bot, hilarious banter and all kinds of other groovy stuff going on.
Comparison of Internet Relay Chat clients
Web IRC client
0

#85 User is offline   fsb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 123
  • Joined: 09-January 11

Posted 11 June 2012 - 09:43 AM

View PostrAWTAZ, on 08 June 2012 - 06:42 AM, said:

I may look like an idiot now, but I haven't seen a real example use of "?.". The ?/@foreign/@related/whatever, is it only usable/applicable inside relation definitions (where there is the local and only one foreign table)?

In Qiang's first post in this thread, he said "?." can be used "in queries and scopes to represent the table alias prefix to columns" and that it represents "the foreign table". This makes me wonder how (if at all) it applies in a query/scope where we have more than one foreign/related table. Take the following example:

// Yii 1.1 syntax.
// Find all posts for a public blogs and where the author's account is still active (whatever that means in this example).
Post::model()->with('blog', 'author')->findAll('blog.is_public=true and author.is_active=true');

// Yii 2.0 syntax (attempt).
// Find all posts for a public blogs and where the author's account is still active (whatever that means in this example).
Post::find()->with('blog', 'author')->where('blog.is_public=true and author.is_active=true')->all();

So in the above example, is "?." applicable, and if so what foreign/related table would it reference?


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?
Join the happiest place on Freenode: #yii
We've got a MrFisk the bot, hilarious banter and all kinds of other groovy stuff going on.
Comparison of Internet Relay Chat clients
Web IRC client
0

#86 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,222
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 11 June 2012 - 01:37 PM

View Postfsb, on 11 June 2012 - 09:29 AM, said:

@rel is almost as cryptic as the original proposal of @ and ?.

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.
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
0

#87 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 11 June 2012 - 02:25 PM

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
Find more about me.... btw. Do you know your WAN IP?
0

#88 User is offline   rAWTAZ 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 08-January 10

Posted 11 June 2012 - 02:48 PM

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
0

#89 User is offline   ekerazha 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 526
  • Joined: 10-October 08
  • Location:European Union

Posted 12 June 2012 - 01:02 AM

View Postjacmoe, on 08 June 2012 - 10:33 AM, said:

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


I agree.

I suggest

@own and @other
Yii user #37
0

#90 User is offline   rAWTAZ 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 08-January 10

Posted 12 June 2012 - 04:09 AM

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

#91 User is offline   fsb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 123
  • Joined: 09-January 11

Posted 12 June 2012 - 08:10 AM

View PostrAWTAZ, on 12 June 2012 - 04:09 AM, said:

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?
Join the happiest place on Freenode: #yii
We've got a MrFisk the bot, hilarious banter and all kinds of other groovy stuff going on.
Comparison of Internet Relay Chat clients
Web IRC client
0

#92 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 13 June 2012 - 12:02 AM

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.
0

#93 User is offline   Psih 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 115
  • Joined: 30-June 10

Posted 13 June 2012 - 03:07 AM

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.
0

#94 User is offline   3amsleep 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 27-May 12

Posted 15 June 2012 - 02:15 AM

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!
4

#95 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 15 June 2012 - 02:42 AM

@3amsleep you explained very well all my thoughts about those names :D
Find more about me.... btw. Do you know your WAN IP?
0

#96 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 15 June 2012 - 02:53 AM

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 ;)
2

#97 User is offline   rAWTAZ 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 08-January 10

Posted 15 June 2012 - 03:57 AM

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
0

#98 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 15 June 2012 - 04:02 AM

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. :)
"Less noise - more signal"
0

#99 User is offline   rAWTAZ 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 08-January 10

Posted 15 June 2012 - 04:15 AM

Well put :D
0

#100 User is offline   phpnode 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 18-April 11

Posted 15 June 2012 - 05:17 AM

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.
0

Share this topic:


  • (7 Pages)
  • +
  • « First
  • 3
  • 4
  • 5
  • 6
  • 7
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users