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

Simple is Good, Complex is Bad

Simple is Good, Complex is Bad

Talk given at New York for CakeFest 2015

Mariano Iglesias

May 31, 2015
Tweet

More Decks by Mariano Iglesias

Other Decks in Programming

Transcript

  1. “If I could create Symfony from scratch today, I'd do

    it totally different.” Fabien Potencier
  2. “MVC, MVVM, ADR, are all bad jokes. They solve the

    easy problem, and forget about the hard one.” Anthony Ferrara
  3.  Laravel: 273k lines, 0.19 complexity.  Silex + Doctrine:

    109k lines, 0.19 complexity.  Slim + Illuminate (ORM): 42k lines, 0.15 complexity.  Slim + PDO: 21k lines, 0.13 complexity
  4.  "illuminate/auth": "5.0.*",  "illuminate/bus": "5.0.*",  "illuminate/config": "5.0.*", 

    "illuminate/container": "5.0.*",  "illuminate/contracts": "5.0.*",  "illuminate/cache": "5.0.*",  "illuminate/console": "5.0.*",  "illuminate/cookie": "5.0.*",  "illuminate/database": "5.0.*",  "illuminate/encryption": "5.0.*",  "illuminate/events": "5.0.*",  "illuminate/filesystem": "5.0.*",  "illuminate/hashing": "5.0.*",  "illuminate/http": "5.0.*",  "illuminate/pagination": "5.0.*",  "illuminate/queue": "5.0.*",  "illuminate/session": "5.0.*",  "illuminate/support": "5.0.*",  "illuminate/translation": "5.0.*",  "illuminate/validation": "5.0.*",  "illuminate/view": "5.0.*",  "monolog/monolog": "~1.0",  "mtdowling/cron-expression": "~1.0",  "nikic/fast-route": "0.4.*",  "symfony/http-kernel": "2.6.*",  "symfony/http-foundation": "2.6.*",  "symfony/security-core": "2.6.*",  "symfony/var-dumper": "2.6.*"
  5.  Write programs that do one thing, and do it

    well.  Write programs to work together.  Write programs to handle text streams, because that is a universal interface. Doug McIlroy, inventor of the Unix pipe
  6. The more your application grows, the more you'll want to

    break it into pieces (aka SOA) #FACT
  7.  Use Disque/Gearman/RabbitMQ to implement worker queues.  Does it

    all have to be PHP? No, use the right tool for each job.
  8. class ArticleTable extends \Cake\ORM\Table { } class Article extends \Cake\ORM\Entity

    { } class ArticlesController extends \Cake\Controller\Controller { public function index() { $table = TableRegistry::get('Articles'); $query = $table->find()->where(['active' => 1]); $this->set('articles', $query->toArray()); } }
  9. interface ArticleInterface { public function getTitle(); public function setAuthor(Author $author);

    } interface ArticleRepositoryInterface { public function add(ArticleInterface $article); public function getActive(); } class Article implements ArticleInterface { // Don't make me dumb... } Pure Object (Not a Cake\Entity)
  10. use Domain\Repository\ArticleRepositoryInterface; use Domain\Entity\Article; class ArticleRepository extends Table implements ArticleRepositoryInterface

    { public function initialize(array $config) { $this->entityClass(Article::class); } public function add(ArticleInterface $article) { } public function getActive() { return $this->find()->where(['active' => 1]); } }
  11.  Look for a package in packagist.org  Found one

    but misses something? Collaborate.  Nothing there? Create (and submit) your own.
  12.  Use semantic versioning  Split itself into components 

    Decouple its components  Use standards (PSR-7 pretty please)  Have security reporting & disclosure procedures (PSR-9 and PSR-10)