SlideShare una empresa de Scribd logo
1 de 45
Descargar para leer sin conexión
Learned lessons in a
real world project
Luis Rovirosa
@luisrovirosa
www.codium.team
About me
+10 years doing web
applications
Team transformations
Lean & Craftsmanship
Agenda
Context
How to deal with a new project
Automate everything
Domain at heart
Ensure quality
Context
2 + 1 month project
2 part time developers
Green field project
Turn system
Context
How to deal with a
new project
There is no trust
We don’t know each other
Lack of business knowledge
Problems at beginning
Difficult to estimate
10-100 pages
1+ requirement documents
All must be done
What we usually receive
Everything is important
User stories
Split into Sprints
Vertical slices
Our recipe: the Sprint 0
Prioritize / Reduce scope
Iterative
2nd - Support final hardware
1st - Minimal functionality
1 CCU, 1 dispenser & 1 display.
No services | No printing real tickets
Neither users nor roles
3rd - Services + basic actions
How we broke it
4th - Roles & permissions
Learned lessons
Sprint 0 is the key
Simplify the problem
Prioritize
Deal with expectations
How we develop
Ensure quality
Automate everything
Domain at heart
How we develop
Automate everything
Automate infrastructure
Public docker images
Our own docker images
Docker-compose
Own docker image
// Dockerfile
FROM php:7.1-apache
# Dependencies
RUN docker-php-ext-install mysqli pdo pdo_mysql
RUN a2enmod rewrite
RUN curl -sS https://getcomposer.org/installer | php && 
mv composer.phar /usr/local/bin/composer
# Configuration
COPY apache.conf
/etc/apache2/sites-available/001-our-project.conf
RUN ln -s /etc/apache2/sites-available/001-our-project.conf
/etc/apache2/sites-enabled/
# Git and unzip to use composer
RUN apt-get update && apt-get install git unzip -y
Docker-compose
version: '3.3'
services:
webserver:
container_name: our_project_webserver
image: our-project-apache
build:
context: .
dockerfile: docker/apache/Dockerfile
volumes:
- .:/var/www/html
- ./vendor:/var/www/html/vendor:delegated
Automate test execution
// bitbucket-pipelines.yml
image: composer:latest
pipelines:
branches:
master:
- step:
caches:
- composer
script:
- composer install
- composer tests:unit
definitions:
caches:
composer: vendor
Automate commands
// Composer.json
"scripts": {
"server:code:update":[
"git pull",
"docker exec own-project_webserver
composer local:dependencies:update"
],
"local:dependencies:update":[
"composer install",
"composer local:database:update",
"composer local:cache:clear"
],
Learned lessons
Easy setup/update
Documentation
Double check on tests
Domain at heart
Ubiquitous language
Use Business names
Only 1 word for concept
Ubiquitous language
DDD
Framework
Application
Domain
Infrastructure
Framework Example
/**
* @Route("/callNextCustomer", name="call_next_customer")
*/
public function callNextCustomerAction(Request $request)
{
$deviceId = $request->get('deviceId');
/** @var CallNextCustomer $action */
$action = $this->container->get(CallNextCustomer::class);
$response = $action->execute(
new CallNextCustomerRequest($deviceId)
);
return new JsonResponse($response->turn());
}
Framework Example
/** @Route("/call_next_customer", name="call_next_customer")*/
public function callNextCustomerAction(Request $request)
{
return new JsonResponse(
$this->execute('call_next_customer_action', $request)
);
}
protected function execute(string $name, Request $request)
{
/** @var ActionSequence $action */
$action = $this->get($name);
return $action->execute($request);
}
Application Example
public function execute(Request $request): Response
{
/** @var CallNextCustomerRequest $request */
$device = $this->findDevice($request);
$turn = $this->findNextTurn($device);
$user = $this->findUser($request);
$this->markTurnAsCalled($turn, $device, $user);
$this->showOnDisplays($turn);
$this->notifyPendingCustomerStats();
return new CallNextCustomerResponse(
$turn->id(), $turn->value(), $turn->service()->id()
);
}
Domain Example
namespace MyProjectDomainModelUser;
interface UserRepository
{
public function save(User $user): void;
public function findById(string $id): User;
public function all(): Users;
}
First class collection
class Users extends ArrayCollection
{
public function canTalkTo(User $theUser): Users
{
// Code
}
public function orderByFullName(): Users
{
// Code
}
}
Decoupling Libraries
and Infrastructure
Domain Interface
Infrastructure implementation
// Message.Message.orm.yml
MyProjectDomainMessageMessage:
type: entity
table: message
id:
id:
type: string
fields:
fromUserId:
type: string
toUserId:
type: string
message:
type: string
Database mapping
Learned lessons
Simplifies the communication
Really decoupled
Increases complexity
Ensure quality
TDD Development
Different levels of testing
Test doubles manually
Acceptance tests
/** @test */
public function its_possible_to_access_the_counter
_call_unit_when_you_are_log_in()
{
$this->loginAsEmployee();
$this->makeGetRequest('/counter_call_unit');
$this->assertResponseIsSuccessful();
}
Framework tests
/** @test */
public function the_first_value_generated_is_1()
{
$generator = $this->aGenerator();
$nextValue = $generator->next();
$this->assertSame(1, $nextValue);
}
Unit tests
public function retrieve_a_persisted_device_using_its_id()
{
$repository = $this->getRepository();
$message = $this->createNewMessage();
$repository->save($message);
$theMessage = $repository->findById($message->id());
$this->assertEquals($message->id(), $theMessage->id());
}
abstract protected function getRepository();
Infrastructure tests
class InMemoryMessageRepository
implements MessageRepository
{
private $messages = [];
public function save(Message $message): void
{
$this->messages[$message->id()] = $message;
}
public function findById(string $id): Message
{
return $this->messages[$id];
}
}
Fake implementations
class DummyPrinter implements Printer
{
public function printTurn(Turn $turn): void
{
}
}
Dummy implementation
// services_test.yml
services:
MyProjectDomainMessageMessageRepository:
class: MyProjectInfrastructurePersistence
InMemoryInMemoryMessageRepository
MyProjectDomainPrinterPrinter:
class: TestsMyProjectDomainPrinterDummyPrinter
public: true
Test dependencies
Learned lessons
High confidence
Allows refactoring
Simplifies the code
Needs discipline
Take aways
Try to simplify the problem
Talk the business language
Automate from the beginning
Use different TDD strategies
Try some DDD patterns
Take aways
Thank you
Questions?
Luis Rovirosa
@luisrovirosa
www.codium.team

Más contenido relacionado

Similar a Learned lessons in a real world project by Luis Rovirosa at PHPMad

App engine devfest_mexico_10
App engine devfest_mexico_10App engine devfest_mexico_10
App engine devfest_mexico_10
Chris Schalk
 

Similar a Learned lessons in a real world project by Luis Rovirosa at PHPMad (20)

Google App Engine Developer - Day2
Google App Engine Developer - Day2Google App Engine Developer - Day2
Google App Engine Developer - Day2
 
BP101 - 10 Things to Consider when Developing & Deploying Applications in Lar...
BP101 - 10 Things to Consider when Developing & Deploying Applications in Lar...BP101 - 10 Things to Consider when Developing & Deploying Applications in Lar...
BP101 - 10 Things to Consider when Developing & Deploying Applications in Lar...
 
Decomposing the Monolith using modern-day .NET and a touch of microservices
Decomposing the Monolith using modern-day .NET and a touch of microservicesDecomposing the Monolith using modern-day .NET and a touch of microservices
Decomposing the Monolith using modern-day .NET and a touch of microservices
 
App engine devfest_mexico_10
App engine devfest_mexico_10App engine devfest_mexico_10
App engine devfest_mexico_10
 
Google App Engine with Gaelyk
Google App Engine with GaelykGoogle App Engine with Gaelyk
Google App Engine with Gaelyk
 
Clean Architecture @ Taxibeat
Clean Architecture @ TaxibeatClean Architecture @ Taxibeat
Clean Architecture @ Taxibeat
 
Cloudbase.io MoSync Reload Course
Cloudbase.io MoSync Reload CourseCloudbase.io MoSync Reload Course
Cloudbase.io MoSync Reload Course
 
inventory mangement project.pdf
inventory mangement project.pdfinventory mangement project.pdf
inventory mangement project.pdf
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon Gauvin
 
Camunda BPM 7.2: Tasklist and Javascript Forms SDK (English)
Camunda BPM 7.2: Tasklist and Javascript Forms SDK (English)Camunda BPM 7.2: Tasklist and Javascript Forms SDK (English)
Camunda BPM 7.2: Tasklist and Javascript Forms SDK (English)
 
The web - What it has, what it lacks and where it must go - keynote at Riga D...
The web - What it has, what it lacks and where it must go - keynote at Riga D...The web - What it has, what it lacks and where it must go - keynote at Riga D...
The web - What it has, what it lacks and where it must go - keynote at Riga D...
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
OWASP TOP 10 for PHP Programmers
OWASP TOP 10 for PHP ProgrammersOWASP TOP 10 for PHP Programmers
OWASP TOP 10 for PHP Programmers
 
Droidcon Paris 2015
Droidcon Paris 2015Droidcon Paris 2015
Droidcon Paris 2015
 
Mobile optimization
Mobile optimizationMobile optimization
Mobile optimization
 
Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...
 
Beyond MVC: from Model to Domain
Beyond MVC: from Model to DomainBeyond MVC: from Model to Domain
Beyond MVC: from Model to Domain
 
RTI Data-Distribution Service (DDS) Master Class 2011
RTI Data-Distribution Service (DDS) Master Class 2011RTI Data-Distribution Service (DDS) Master Class 2011
RTI Data-Distribution Service (DDS) Master Class 2011
 
From framework coupled code to #microservices through #DDD /by @codelytv
From framework coupled code to #microservices through #DDD /by @codelytvFrom framework coupled code to #microservices through #DDD /by @codelytv
From framework coupled code to #microservices through #DDD /by @codelytv
 
How We Built the Private AppExchange App (Apex, Visualforce, RWD)
How We Built the Private AppExchange App (Apex, Visualforce, RWD)How We Built the Private AppExchange App (Apex, Visualforce, RWD)
How We Built the Private AppExchange App (Apex, Visualforce, RWD)
 

Último

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 

Learned lessons in a real world project by Luis Rovirosa at PHPMad