[wp-trac] [WordPress Trac] #12267: Upgrade loop objects to provide identical presentational interfaces.

WordPress Trac wp-trac at lists.automattic.com
Thu Feb 18 02:31:18 UTC 2010


#12267: Upgrade loop objects to provide identical presentational interfaces.
-------------------------+--------------------------------------------------
 Reporter:  andy         |       Owner:            
     Type:  enhancement  |      Status:  new       
 Priority:  normal       |   Milestone:  Unassigned
Component:  General      |     Version:            
 Severity:  normal       |    Keywords:            
-------------------------+--------------------------------------------------

Comment(by filosofo):

 I think it's a great idea for each post/comment object to have getter
 methods. It's something I've done in several projects.

 Here are some concerns about this specific proposal (now committed code):

  * It's not obvious why the "Interface" of the particular object types is
 also the "factory." It's somewhat odd in theory, it goes against the
 allowed behavior of real PHP Interfaces, and it forces you to do some code
 gymnastics. Rather, it would be better to have an independent factory with
 that as its single purpose.  By "better" I mean it would make the code
 easier to understand, simpler to test and more flexible to use.
  * The "Interface" should have a name that reflects its behavior and
 structure rather than what happens to be the source of the data, in this
 case a database "row."  "Rows" don't usually have permalinks, dates, or
 titles.  Maybe something like "Loop_Object"?
  * The WP_Error object should not be one of the possible objects.  A
 WP_Error object violates the "Interface" implementation, and WP usually
 doesn't return error objects in the context of themes.
  * Method names should follow the WP convention of being prefixed by
 "get_", since they get the values, not print them.
  * Class names should follow the WP convention of being capitalized.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12267#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list