A Talk About Naming Things Talk

A Talk About Naming Things Talk

This was Mitchell van Wijngaarden's and my uncon talk at Dutch PHP Conference 2015.

It's a talk about naming and other important things.

C7d7ea7ed7cdf742ebc2c9445b9928c3?s=128

Shawn McCool

June 27, 2015
Tweet

Transcript

  1. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    A Talk About Naming Things Talk
  2. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    Who are we even? Shawn McCool Human Mitchell van Wijngaarden Human
  3. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    This talk is about naming things.
  4. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    It can have dramatic consequences.
  5. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    It can have dramatic consequences.
  6. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    It’s cultural
  7. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    That’s a good thing!
  8. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    We can fix it!
  9. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    Disclaimer
  10. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    Interface Suffix
  11. interface PaymentProviderInterface { ... }

  12. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    Impossible to tell otherwise.
  13. interface PaymentProviderInterface { ... }

  14. interface PaymentProviderInterface { ... }

  15. interface PaymentProviderInterface { ... } class Stripe implements PaymentProviderInterface {}

  16. interface PaymentProviderInterface { ... } class Stripe implements PaymentProviderInterface {}

  17. interface PaymentProviderInterface { ... } class Stripe implements PaymentProviderInterface {}

  18. None
  19. class PaymentProcessor { public function process(PaymentProviderInterface $provider) { } }

  20. class PaymentProcessor { public function process(PaymentProviderInterface $provider) { } }

    class PaymentProcessor { public function process(PaymentProvider $provider) { } }
  21. class PaymentProcessor { public function process(PaymentProviderInterface $provider) { } }

    class PaymentProcessor { public function process(PaymentProvider $provider) { } }
  22. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    Interfaces aren’t special!
  23. class PaymentProcessor { public function process(PaymentProviderInterface $provider) {} }

  24. class PaymentProcessor { public function process(PaymentProviderInterface $provider) {} } class

    PaymentProcessorClass { public function process(PaymentProviderInterface $provider) {} }
  25. class PaymentProcessor { public function process(PaymentProviderInterface $provider) {} } class

    PaymentProcessorClass { public function process(PaymentProviderInterface $provider) {} } class PaymentProcessorClass { public function processMethod(PaymentProviderInterface $providerVariable) {} }
  26. class PaymentProcessor { public function process(PaymentProviderInterface $provider) {} } class

    PaymentProcessorClass { public function process(PaymentProviderInterface $provider) {} } class PaymentProcessorClass { public function processMethod(PaymentProviderInterface $providerVariable) {} }
  27. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    Readability
  28. public function __construct( PromotionRepositoryInterface $repository, PromotionEligibilityCheckerInterface $checker, PromotionApplicatorInterface $applicator, ChannelContextInterface

    $channelContext) { parent::__construct($repository, $checker, $applicator); $this->channelContext = $channelContext; }
  29. public function __construct( PromotionRepositoryInterface $repository, PromotionEligibilityCheckerInterface $checker, PromotionApplicatorInterface $applicator, ChannelContextInterface

    $channelContext) { parent::__construct($repository, $checker, $applicator); $this->channelContext = $channelContext; }
  30. public function __construct( PromotionRepositoryInterface $repository, PromotionEligibilityCheckerInterface $checker, PromotionApplicatorInterface $applicator, ChannelContextInterface

    $channelContext) { parent::__construct($repository, $checker, $applicator); $this->channelContext = $channelContext; }
  31. public function __construct( PromotionRepository $repository, PromotionEligibilityChecker $checker, PromotionApplicator $applicator, ChannelContext

    $channelContext) { parent::__construct($repository, $checker, $applicator); $this->channelContext = $channelContext; }
  32. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    Why does this happen?
  33. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    How do we fix it?
  34. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    TheNamingWentWrongException
  35. class CannotDrawFromAnEmptyDeck extends \Exception {} throw new CannotDrawFromAnEmptyDeck(); try {

    // do something } catch (CannotDrawFromAnEmptyDeck $e) { // oops }
  36. class CannotDrawFromAnEmptyDeck extends \Exception {} throw new CannotDrawFromAnEmptyDeck(); try {

    // do something } catch (CannotDrawFromAnEmptyDeck $e) { // oops }
  37. class CannotDrawFromAnEmptyDeck extends \Exception {} throw new CannotDrawFromAnEmptyDeck(); try {

    // do something } catch (CannotDrawFromAnEmptyDeck $e) { // oops }
  38. class CannotDrawFromAnEmptyDeck extends \Exception {} throw new CannotDrawFromAnEmptyDeck(); try {

    // do something } catch (CannotDrawFromAnEmptyDeck $e) { // oops }
  39. class CannotDrawFromAnEmptyDeck extends \Exception {} throw new CannotDrawFromAnEmptyDeck(); try {

    // do something } catch (CannotDrawFromAnEmptyDeck $e) { // oops }
  40. class CannotDrawFromAnEmptyDeck extends \Exception {} throw new CannotDrawFromAnEmptyDeck(); try {

    // do something } catch (CannotDrawFromAnEmptyDeck $e) { // oops }
  41. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    People who agree with us
  42. None
  43. None
  44. None
  45. None
  46. None
  47. None
  48. None
  49. None
  50. None
  51. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    Namespacing by Type
  52. None
  53. use Entities\Member; use Entities\Policy; use DTOs\BuyInsurancePolicy; use Repositories\CustomerRepository; use Repositories\PolicyRepository;

    use ValueObjects\Money; use ValueObjects\Currency; So, I heard you like namespace imports...
  54. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    Let’s talk about Cohesion!
  55. 1 2 3 4 5 x a b c i

    j $ % . ;
  56. $i = 0;

  57. $i = 0; while ($i < 1) { $i--; }

  58. function liveForever() { $i = 0; while ($i < 1)

    { $i--; } }
  59. class Member { public static function register() {} public function

    unregister() {} public function reregister() {} }
  60. What’s Next?

  61. Member.php class Member { public static function register() {} public

    function unregister() {} public function reregister() {} }
  62. Member.php class Member { public static function register() {} public

    function unregister() {} public function reregister() {} } class MemberOnlyRegisteredOnce extends \Exception {};
  63. namespace WhatIsANamespaceReally? { class Member { public static function register()

    {} public function unregister() {} public function reregister() {} } class MemberOnlyRegisteredOnce extends \Exception {}; function functions_toooooooooo() {} }
  64. None
  65. None
  66. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    People who agree with us
  67. None
  68. None
  69. None
  70. None
  71. None
  72. None
  73. None
  74. None
  75. Geeks & Games

  76. None
  77. None
  78. None
  79. None
  80. None
  81. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    Let’s hang out some time.
  82. A Talk About Naming Things Talk Dutch PHP UnCon 2015

    Find us here @shawnmccool @mitchellvanw =)