WordPress: To OOP or not to OOP

WordPress: To OOP or not to OOP

Thoughts on incremental structure in larger software projects, the WordPress community, and few OOP examples

75fb365927cb3f5f7b677682d6249406?s=128

Nikolay Bachiyski

October 06, 2013
Tweet

Transcript

  1. 2.
  2. 11.
  3. 14.
  4. 20.
  5. 21.
  6. 23.
  7. 24.
  8. 25.
  9. 26.
  10. 27.
  11. 36.

    OOP

  12. 39.

    A big reason WP is so popular is because it

    is not infatuated with the latest, greatest developer lust objects… “
  13. 40.

    One of the biggest problems I've found with OOP is

    that it forces the developer to bake in structure long before the developer actually understands what that structure should be… “
  14. 43.

    ?

  15. 44.

    One of the biggest problems I've found with OOP is

    that it forces the developer to bake in structure long before the developer actually understands what that structure should be… “
  16. 45.

    One of the biggest problems I've found with OOP is

    that it forces the developer to bake in structure long before the developer actually understands what that structure should be… “
  17. 48.
  18. 50.
  19. 51.
  20. 52.
  21. 53.
  22. 54.
  23. 56.
  24. 57.
  25. 58.
  26. 61.
  27. 62.
  28. 63.

    class WP_Screen { function get( $hook_name = '' ); function

    set_current_screen(); function in_admin( $admin = null ); function add_old_compat_help( $screen, $help ); function set_parentage( $parent_file ); function add_option( $option, $args = array() ); function get_option( $option, $key = false ); function get_help_tabs(); function get_help_tab( $id ); function add_help_tab( $args ); function remove_help_tab( $id ); function remove_help_tabs(); function get_help_sidebar(); function set_help_sidebar( $content ); function get_columns(); function render_screen_meta(); function show_screen_options(); function render_screen_options(); function render_screen_layout(); function render_per_page_options(); }
  29. 64.

    class WP_Screen { function get( $hook_name = '' ); function

    set_current_screen(); function in_admin( $admin = null ); function add_old_compat_help( $screen, $help ); function set_parentage( $parent_file ); function add_option( $option, $args = array() ); function get_option( $option, $key = false ); function get_help_tabs(); function get_help_tab( $id ); function add_help_tab( $args ); function remove_help_tab( $id ); function remove_help_tabs(); function get_help_sidebar(); function set_help_sidebar( $content ); function get_columns(); function render_screen_meta(); function show_screen_options(); function render_screen_options(); function render_screen_layout(); function render_per_page_options(); }
  30. 67.
  31. 68.

    The big idea is “messaging” [...] The key in making

    great and growable systems is much more to design how its modules communicate rather than what their internal properties and behaviors should be. “
  32. 74.

    if ( ! $this->make_image( $filename, 'imagejpeg', array( $image, $filename, apply_filters(

    'jpeg_quality', $this- >quality, 'image_resize' ) ) ) ) $this->image->setImageCompressionQuality ( apply_filters( 'jpeg_quality', $quality, 'image_resize' ) ); GD: ImageMagick:
  33. 75.

    GD: ImageMagick: protected function update_size( $width = null, $height =

    null ) { … return parent::update_size( $width, $height ); } protected function update_size( $width = null, $height = null ) { … return parent::update_size( $width, $height ); }
  34. 86.

    $this->engine = new WP_Image_Engine_GD(); $this->engine = new WP_Image_Engine_ImageMagick(); $this->image =

    $this->engine->load( $filename ); $new_size = $this->image->update_size();
  35. 87.

    function save( $filename = null, $mime_type = null ) {

    … $jpeg_quality = apply_filters( 'jpeg_quality', … ); $this->image->save( $filename, $mime_type, array( 'jpeg_quality' => $jpeg_quality ) ); … }
  36. 92.
  37. 94.

    ?