Junk Mail Development Meet-up
Upcoming SlideShare
Loading in...5
×
 

Junk Mail Development Meet-up

on

  • 346 views

 

Statistics

Views

Total Views
346
Slideshare-icon Views on SlideShare
346
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Junk Mail Development Meet-up Junk Mail Development Meet-up Presentation Transcript

    • DEV Meet-up
    • Test Driven Development (TDD)
    • Writing better code Understanding code. Managing complexity. Predicting outcomes. Evaluating results. Refactoring. Testing. Code Review.
    • Understanding code Your code. Compiler OR Interpreter ● Best Practices ● Coding Conventions ● Syntax
    • Managing Complexity. Complexity = Code size. ● Cyclomatic Complexity ● NPath Complexity
    • Cyclomatic Complexity ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● class Foo { 1 public function example() { 2 if ($a == $b) { 3 if ($a1 == $b1) { fiddle(); 4 } else if ($a2 == $b2) { fiddle(); } else { fiddle(); } 5 } else if ($c == $d) { 6 while ($c == $d) { fiddle(); } 7 } else if ($e == $f) { 8 for ($n = 0; $n > $h; $n++) { fiddle(); } } else{ switch ($z) { 9 case 1: fiddle(); break; 10 case 2: fiddle(); break; 11 case 3: fiddle(); break; 12 default: fiddle(); break; } } } } 12 Standard Threshold = 10 Rule: 1. Count Statements. 2. Add 1 point for function declaration. 3. Add 1 point for any (if, while, for, case) statements. If your code is above 10 points, you need to reduce it.
    • NPath Complexity function foo($a, $b) { if ($a > 10) { echo 1; } else { echo 2; Definition: The NPath complexity of a method is the number of acyclic execution paths through that method. Simply put, how many “paths” there are in the flow of your code in the function. } if ($a > $b) { echo 3; } else { echo 4; } } foo(1, 2); // Outputs 24 foo(11, 1); // Outputs 13 foo(11, 20); // Outputs 14 foo(5, 1); // Outputs 23 The following code has 4 possible outcomes. (2 * 2 = 4).
    • Predicting Outcomes ● ● Use a Blackbox approach. Use Cyclomatic and NPath complexity to traverse your code.
    • Evaluating Results ● So you done writing. ● Now, Let's see if anything breaks. Your code. Compiler OR Interpreter
    • Refactoring ● What works? ● What sucks? ● Too complex. Needs a rewrite?
    • Testing ● Unit test ● Functional test ● Acceptance test
    • Unit test ● ● ● ● A unit is simply a chunk of functionality. A unit test, on the other hand, is a sanity check to make sure that the chunk of functionality does what it’s supposed to. What is PHPUnit? A standard development tool for performing unit tests in PHP. See what we did: http://wiki.dev.jobmail.co.za/index.php/Testing _code#Unit_Tests
    • Functional test ● TDD, BDD, FDD (basically your -DDs) ● Automated Tests ● Frameworks: Symfony, Laravel ● PHPUnit: CodeCoverage ● Codeception
    • Acceptance test ● ● ● Acceptance testing is a test conducted to determine if the requirements of a specification or contract are met. Environments: Continuous Integration (e.g. Jenkins, Hudson) Tools: Browser, Selenium, BrowserStack, TestStudio, Codeception.
    • Code Review Code Quality: ● Who's involved? ● Developers: Pair programming ● QA Team ● Objective: ensure that code looks good and works effectively.
    • Demo ● Unit testing with PHPUnit
    • References ● ● ● ● Cyclomatic Complexity http://phpmd.org/rules/codesize.html#cyclomati ccomplexity Npath Complexity http://phpmd.org/rules/codesize.html#cyclomati ccomplexity PHPUnit http://phpunit.de/ Codeception http://www.codeception.com/
    • Presented by Biyi Akinpelu Email: biyi@junkmail.co.za Profile: http://akinbiyiakinpelu.junkmail.co.za Personal Blog: http://bee-yee.com