software engineering in php
DESCRIPTION
Software Engineering in PHP - M A Hossain TonuTRANSCRIPT
OBJECTIVE
Adopting some engineering into your PHP Development
Quick view on enterprise PHP development process
Will give you concept, not complete set of details
CONTENTS Engineering Approach Design Patterns Architectural Patterns PHP Development Methodology PHP Development Process Best Practices Successful PHP Projects Open source Revenue Model User Documentation Commercial Support
ENGINEERING APPROACH
DESIGN PATTERNS
A general reusability solution Shows relationships and interactions
between classes or objects
Four common design patterns Strategy Pattern Singleton Pattern Factory Pattern Adapter Pattern
DESIGN PATTERNS : STRATEGY PATTERN Enables us to make decisions on different cases Example: User notification systemclass.emailnotifier.php
class.faxnotifier.php
class.smsnotifier.php
interface.Notifier.php
DESIGN PATTERNS : SINGLETON PATTERN Delivers a single instance of an object no matter how
many times you instantiate it. Example:
Self refers to current class and $this refers to current object
ARCHITECTURAL PATTERNS
An image of a system Describes software behavior
Common Example: MVC (Model-View-Controller) SOA (Service Oriented Architecture) Multi-tier (Frontend, Application, Data)
ARCHITECTURAL PATTERNS: MVC Model–View–Controller
Model is responsible to manage the data; it stores and retrieves entities used by an application, i.e.
from a database contains the logic implemented by the application.
View (presentation) is responsible to display the data provided by the model similar usage with the template modules present in some
popular web applications, like wordpress, joomla, …
Controller Perform as glue between Model and View Helps to persist data from Model to View
PHP DEVELOPMENT METHODOLOGY
Defines development infrastructure Provides a framework that is used to
structure, plan, and control the process of developing
Common Example: Water Fall Agile(SCRUM, XP ) RAD
DEVELOPMENT METHODOLOGY: WATER FALL
Classical method
DEVELOPMENT METHODOLOGY: AGILE
Mostly used agile philosophy are XP and SCRUM
Generic Agile development process:
PHP DEVELOPMENT PROCESS
FOUNDATION
Start with a foundation Use a framework
Provides guidelines Off the shelf components
Examples Code Igniter http://www.codeigniter.com/ CakePHP http://cakephp.org/ Zend Framework http://framework.zend.com/ Symfony http://www.symfony-
project.org/
SECURITY
Not a language feature It is you who writes secure PHP application
Common security check list: User input/From validation XSS SQL/Code Injection Session hijacking Error reporting
TESTING
More testing = less debugging Unit Testing
Verify the functionality of a specific section of code
Integration testing Verify the interfaces between components against a
software design
Acceptance Testing Verify customer acceptance
Tools: PHPUnit http://www.phpunit.de Selenium http://seleniumhq.org/
DEBUGGING
If you don’t have bugs in your code, you are not smart enough to debug
Checklist: function call flow error notification variable values with a given scope
Debugger/Profiler Tools: Xdebug http://www.xdebug.org
OPTIMIZATION
Caching Op-code caching {Page|Database|Module|…} caching Optimized Database Design Database Indexing strategy Writing good SQL
DEPLOYMENT Always automate your deployment Deploy to
Develop env Test env LIVE
LIVE = Shared server/Cloud server/…
Use SVN
Code is just a part, don’t forget the database
Create a “Deployment and Release” Profile
PERFORMANCE
Consider you have bought the product worth $1k$
How fast system performs under a particular work load
Tests scalability, reliability and resource usage.
REFACTORING
Cleaning up code
Without changing behavior
Not adding new feature
Use unit test you ensure you don’t break anything
BEST PRACTICES
Don’t re-invent the wheel Follow coding standards Write reusable code Use components/frameworks
Good communication and collaboration Commitment (On time – On mark)
Document your application (code comments & API docs)
SUCCESSFUL PHP PRODUCT
OPENSOURCE WWW.OPENSOURCE.ORG
Access to code Freedom to change Freedom to distribute Freedom to use Doesn’t mean free of cost, but may be. Collaborative software engineering Open source enabled business Famous Examples:
REVENUE MODEL ( EARNING MONEY )
Not traditional BUY & SELL method Describes the way of business Typically an online business Monetizes its services Example:
Freemium: "free" and "premium" Subscription Affiliate marketing Ad-funded Online shopping
USER DOCUMENTATION
Describes how to use the software
As product documentation to User
Way of documentation Tutorials Thematic List of reference
COMMERCIAL SUPPORT
Maintain support system i.e. ticketing system
Maintain user forum
Maintain product blog
Maintain email newsletter (inform user inside scoop)
QUESTIONS?