Your SlideShare is downloading. ×
Development Approach
Development Approach
Development Approach
Development Approach
Development Approach
Development Approach
Development Approach
Development Approach
Development Approach
Development Approach
Development Approach
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Development Approach

245

Published on

Some general coding approach

Some general coding approach

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
245
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. Development Notes Alex King
    • 2. Transparency FTW• Code should be obvious (comments help, but are supplemental)• Abstraction worth layers of complexity (it’s got to be adds it, frameworks vs. one- offs)• Searchability is important• Readability > most of the time) (within reason, Performance
    • 3. Example class Example { static $meta_prefix = ‘_foo_’;NO! [...] function bar() { update_post_meta($post_id, self::$meta_prefix.‘my_key’, 1); } } class Example {YES [...] function bar() { update_post_meta($post_id, ‘_foo_my_key’, 1); } }
    • 4. Refactoring is Development• Clever = brittle• Avoid too many levels of abstraction• Shallow code is more readable/ changable• Consistent variable names foreach ($objects as $object) {...
    • 5. Data Formats / APIs• Keep data as “pure” as possible• Can always refactor what the accessor functions do, but don’t change the formats (if at all possible)• JSON encode vs. serialize for serialized data (allows for SQL find/
    • 6. Example// hard-coded // database backedfunction foo() { function foo() { return array( global $wpdb; ‘bar’, ‘baz’, // some stuff happens here );} return $wpdb->get_col(“ SELECT [...] ”);// filtered }function foo() { return apply_filters( ‘foo_data’, array( ‘bar’, ‘baz’, ) );}
    • 7. Micro-MVC• Model = Get / prep data• Controller = Do something with it• View = Return / Output
    • 8. Example// munged controller / view // controllerforeach ($items as $item) { $_items = array(); $item->prop = utility($item); foreach ($items as $item) { echo [$item...]; $item->prop = utility($item);} $_items[‘id_’.$item->id] = $item; } $items = $_items; // we can insert another step here // easily when refactoring // view foreach ($items as $item) { echo [$item...]; }
    • 9. Getting / Saving Data• Basic utility (method on a Model)• Run everything through this• Do thosecheck permissions/validation (do not in a Controller)• One place to make changes• Easier refactoring
    • 10. Recap• Transparency FTW• Developing = Refactoring• Embrace MVC
    • 11. Dev Plans, Comments & Commit Messages• Convey intent• When code cannot be readable, outline what the code is doing• Document decisions

    ×