Xavier Briand – Business – Problem



Xavier Briand – Business – Problem

0 0


Presentation_SOA

True North PHP 2013 talk

On Github xavierbriand / Presentation_SOA

Xavier Briand

Senior Web Application Developer

ExperiencePoint Inc

(please excuse my accent)

SensioLabs trainings/coaching
not only for the amazing styles not only a Hypterish trend Movember is a month long global event in November where men grow moustaches to raise awareness and funds for men's health issues.

mobro.co/xavierbriand

Moving to aService Oriented Architecturefrom tightly coupledapplications

kitten free presentation

ExperiencePoint

"The best way to learn is to experience."

21 employees academics and corporations Change Management Innovation (Design Thinking)

Business

(1+½)+(4+3) simulations

Frontend App Backend App (simulation + Flash app) x5 Low load, high available (2lb fallback + 3 server + 2 db server fallback + backup infra)

Previous Architecture

Old: All symfony1.0 app (created in 2005, end of support jan 2010 (symfony1.4 november 2012)) Physical env = sf env Shared models and plugins without dependency management Quality nightmare, deployed form dev env "it works for me"

Problems

tightly coupled applications

no dependency management

no tests

deprecated technologies

1 dev symptoms

2 environments

SVN

manage the existant while migrating, no big switch to convert everything can simply deploy one app if model changed No way to know which application use which part of the other application Physical environment (platform) == framework environment SVN, hard to branch, hard to merge => dev don’t branch Flash AMF (support issues), hard to debug; symfony1.0, no php 5.4

ExperienceChange Model

internal culture teaches use this envisage Enlist Communicate Act Consolidate

Meet the dev team

+ 2 designers Holy Trinity

Step 1

Reset ⟲

Goal: efficient dev environment

VM

Modern SCM

Modern Frameworks

Tasks automation

VM: FreeBSD jails (can be cloned, saved, restored) => consistent dev env while keeping dev in different env. Can achieve prod = dev Git + Coding tools (vim) Sf2 Framework (conventiosn, best practices, libs), Backbone, Angular Physical env != Sf env Tests Makefile, PHP CI, Static code analysis

Problem

Dependency management

logo: WizardCat

$ make build

Composer As easy as adding a package.json file as easy as: composer install Fetch code source from outside (scscmgnostic) Set dependencies on your php version and packages Satis for private repository
{
    "name"     : "ep/ec",
    "license"  : "proprietary",
    "autoload" : {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php"                   : ">=5.3.3",
        "symfony/symfony"       : "~2.4",
        "doctrine/orm"          : "~2.2,>=2.2.3",
        "ep/backend-sdk-bundle" : "dev-master",
        "ep/old-stuff"          : "dev-trunk"
    },
    "require-dev": {
        "phpunit/phpunit": "3.7.*"
    }
}
$ php composer.phar
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/

Available commands:
  install          Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.
  require          Adds required packages to your composer.json and installs them
  search           Search for packages
  self-update      Updates composer.phar to the latest version.
  status           Show a list of locally modified packages
  update           Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file.
  validate         Validates a composer.json

Problem

App config management

composer (Platform packages)

incenteev/composer-parameter-handler

$ make build

Application should be unaware of physical environment details, but should provide requirements. composer help to define those requirements Dependency injection container and bundle extension make the work pretty easy for sf2 Use those good practices for sf1

Problem

QA

$ make prepare analysis

check style complexity duplication tests + code coverage trend

Step 2

“Defeat in detail”

Divide and gather (DRY)

Keep things small + KISS

Design by contract

Leverage your architecture

Where there code duplication there is an opportunity to gather this code and create a new module\ Small concern == small responsability => easier to dev/test/deploy Design by contract Black box, expose interfaces. Benefits: Easy to manage, defined boundaries, independant Constraints: interface versioning

Opportunity: GlobalTech

From scratch, Sf2 + Flex Plan to merge every similar product into one application => ExperienceChange But don’t abstract too soon, build what you need and embrace possibilities

Inside

Remove Flash... No! Ok but:

Let’s use the best technologyto do the job

AMF => plain HTTP via browser

Business Logic => Backend

Frontend UI => Flash

Hypermedia API

> POST /games/ + content < 201 Created < Location /games/1

> GET /games/1 < 200 Ok < < <game> <     <!-- ... --> <     <links rel=”actionX” src=”...”></links> <     <links rel=”actionY” src=”...”></links> < </game>

David Zuelke "Designing HTTP Interfaces and RESTful Web Services"

The HATEOAS constraint serves to decouple client and server in a way that allows the server to evolve functionality independently, browse a collection with previous/next links

Globally

Delegate session logic Delegate user logic Delegate authentication Focus on simulation logic Serve everything related to the simulation

Implementation

Strategy Pattern

Old applications need to know when delegate new features: Array of enabled products

Solutions

OAuth2

Shared auth between Frontend app and Auth app

Solutions

Backend App API

Standalone application Future Backend App v3 Leverage Doctrine2 mapping to change the model

Solutions

Product API

Serve data and reports to Frontend and Backend App epExperienceChangePlugin API consumers deal with representation.

The other way around

Product options: Remove every simulation details from Backend App

Step 3

Consolidate

BackendAppSdkBundle

OAuth2ClientBundle

ApiBundle

AssetsBundle

Rinse and repeat...

What do you do before starting a new project? refactoring refactoring extract common feature into bundles share those bundles accross new apps

Step 4

Plan for the futur

wrapping old app into sf2 (session bridge) divide and gater (again) (old backend app with sf2 app, extract auth layer) get ride of flash = html5+js (Angular?) more and nore mobile app to train/prepare transition Pilot cache strategy from client

Question?

joind.in/9999 (four 9)

Symfony

Symfony Toronto Meetup group