[wp-trac] [WordPress Trac] #38098: Use common naming for context switching functions / classes

WordPress Trac noreply at wordpress.org
Mon Sep 19 18:30:56 UTC 2016


#38098: Use common naming for context switching functions / classes
--------------------------+------------------------------
 Reporter:  swissspidy    |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by swissspidy):

 Replying to [comment:1 flixos90]:
 > I think the suffix in `switch_to()` is unnecessary, we could also call
 the method `switch()` (also, I assume you simply missed that in the above
 snippet, but let's keep in mind that we need a parameter there :) ).

 `switch` is a reserved keyword in PHP. Using it as the method name is only
 allowed in PHP 7+ IIRC. It was only an example anyway :-)

 Replying to [comment:2 flixos90]:
 > Also, note that #37958 also includes popping all items off the stack
 ''until'' a certain "breakpoint" that has been set prior. This often will
 be the same as "popping ''all'' items off the stack", but it's a little
 more flexibility that this interface would need to support as well I
 think.

 Not sure how likely it is that you want to go to a specific point in the
 stack and how feasible it would be to implement this for locales for
 example. Sounds complex.

 Replying to [comment:3 ChriCo]:
 > When i see the word "State", then the first i think of is is somehow in
 the direction of the "State" or a "Memento"-Pattern.

 Maybe ''context'' is more appropriate.

 > Also important should be the functionality {{{undo}}} and {{{redo}}} for
 quick access/switching between states. Clear naming is here very
 important. When choosing something like {{{clear}}} or {{{delete}}}, we
 need to add at least {{{state}}} to the -function name. Additionally it
 would be useful to remove the {{{switch_to}}}-functions completely - yep i
 know..in future! Set it to deprecated and call the new class inside - and
 just use it in via the {{{WP_Service_Container}}} which is currently
 discussed in #37699.

 `undo` would be the current `restore` I guess? `redo` sounds unnecessary,
 but could be solved with a second stack.

 I haven't followed #37699 in a while, but it shouldn't affect this ticket
 in any way for now.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38098#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list