[wp-trac] [WordPress Trac] #34432: Customizer subclasses can be broken out and remain BC

WordPress Trac noreply at wordpress.org
Sun Oct 25 20:06:58 UTC 2015


#34432: Customizer subclasses can be broken out and remain BC
----------------------------+---------------------
 Reporter:  wonderboymusic  |       Owner:
     Type:  task (blessed)  |      Status:  closed
 Priority:  normal          |   Milestone:  4.4
Component:  Customize       |     Version:  3.4
 Severity:  normal          |  Resolution:  fixed
 Keywords:                  |     Focuses:
----------------------------+---------------------

Comment (by azaozz):

 I'm not sure this is a good idea. It adds more server i/o to load 27
 files, so it is a bit worse for the users.

 I suspect the idea of "one class per file" comes from languages that are
 compiled (C, C++, etc.) where the code is combined before execution. It
 doesn't make much sense in languages that use interpreter like PHP where
 each file is "loaded" on every run. Especially when many of the files have
 only 2-3 lines of code in them.

 From "coding" point of view, IMHO having many files with just few lines of
 code makes it harder to edit anything as it requires you to have 15-20
 files opened at the same time and switching between them is disorienting
 after a while. Grouping similar (small/short) classes in one file will be
 better and make changing them easier IMHO.

 I've been having some doubts about #33413 too. The reason for splitting
 there was this part of PSR-1:
  A file SHOULD declare new symbols (classes, functions, constants, etc.)
 and cause no other side effects, or it SHOULD execute logic with side
 effects, but SHOULD NOT do both.

 As far as I understand it, that means there shouldn't be "loose" code and
 classes/functions in the same file, example:

 {{{
 echo '123';

 function my_func() {
   echo '456';
 }
 }}}

 I agree, this sounds good. Most of the WP code complies with it except few
 "template" files in wp-admin. This has nothing to do with splitting
 classes in separate files.

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


More information about the wp-trac mailing list