Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

Nikolay Bachiyski

October 06, 2013
Tweet

More Decks by Nikolay Bachiyski

Other Decks in Programming

Transcript

  1. OOP

  2. A big reason WP is so popular is because it

    is not infatuated with the latest, greatest developer lust objects… “
  3. 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… “
  4. ?

  5. 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… “
  6. 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… “
  7. 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(); }
  8. 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(); }
  9. 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. “
  10. 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:
  11. 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 ); }
  12. $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();
  13. function save( $filename = null, $mime_type = null ) {

    … $jpeg_quality = apply_filters( 'jpeg_quality', … ); $this->image->save( $filename, $mime_type, array( 'jpeg_quality' => $jpeg_quality ) ); … }
  14. ?