Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Modular Programming with PHP 7
Modular Programming with PHP 7

Modular Programming with PHP 7: Utilize the power of modular programming to improve code readability, maintainability, and testability

Arrow left icon
Profile Icon Branko Ajzele
Arrow right icon
Mex$812.69 Mex$902.99
Full star icon Full star icon Full star icon Full star icon Full star icon 5 (1 Ratings)
eBook Sep 2016 332 pages 1st Edition
eBook
Mex$812.69 Mex$902.99
Paperback
Mex$903.19 Mex$1128.99
Subscription
Free Trial
Arrow left icon
Profile Icon Branko Ajzele
Arrow right icon
Mex$812.69 Mex$902.99
Full star icon Full star icon Full star icon Full star icon Full star icon 5 (1 Ratings)
eBook Sep 2016 332 pages 1st Edition
eBook
Mex$812.69 Mex$902.99
Paperback
Mex$903.19 Mex$1128.99
Subscription
Free Trial
eBook
Mex$812.69 Mex$902.99
Paperback
Mex$903.19 Mex$1128.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Modular Programming with PHP 7

Chapter 2. GoF Design Patterns

There are a handful of things that make a great software developer. Knowledge and usage of design patterns is one of them. Design patterns empower developers to communicate using well-known names for various software interactions. Whether someone is a PHP, Python, C#, Ruby, or any other language developer, design patterns provide language agnostic solutions for frequently occurring software problems.

The concept of design patterns emerged in 1994 as part of the Elements of Reusable Object-Oriented Software book. Detailing 23 different design patterns, the book was written by four authors Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. The authors are often referred to as the Gang of Four (GoF), and the presented design patterns are sometimes referred to as GoF design patterns. In Today, more than two decades later, designing software that is extensible, reusable, maintainable, and adaptable is near to impossible without embracing design...

Creational patterns

Creational patterns, as the name suggests, create objects for us, so we do not have to instantiate them directly. Implementing creation patterns gives our application a level of flexibility, where the application itself can decide what objects to instantiate at a given time. The following is a list of patterns we categorize as creational patterns:

  • Abstract factory pattern
  • Builder pattern
  • Factory method pattern
  • Prototype pattern
  • Singleton pattern

Note

See https://en.wikipedia.org/wiki/Creational_pattern for more information about creational design patterns.

Abstract factory pattern

Building portable applications requires a great level of dependencies encapsulation. The abstract factory facilitates this by abstracting the creation of families of related or dependent objects. Clients never create these platform objects directly, the factory does it for them, making it possible to interchange concrete implementations without changing the code that uses them, even at runtime.

The...

Structural patterns

Structural patterns deal with class and object composition. Using interfaces or abstract classes and methods, they define ways to compose objects, which in turn obtain new functionality. The following is a list of patterns we categorize as structural patterns:

  • Adapter
  • Bridge
  • Composite
  • Decorator
  • Facade
  • Flyweight
  • Proxy

Note

See https://en.wikipedia.org/wiki/Structural_pattern for more information about structural design patterns.

Adapter pattern

The adapter pattern allows the interface of an existing class to be used from another interface, basically, helping two incompatible interfaces to work together by converting the interface of one class into an interface expected by another class.

The following is an example of adapter pattern implementation:

class Stripe {
    public function capturePayment($amount) {
        /* Implementation... */
    }

    public function authorizeOnlyPayment($amount) {
        /* Implementation... */
    }

    public function cancelAmount($amount) {
...

Behavioral patterns

Behavioral patterns tackle the challenge of communication between various objects. They describe how different objects and classes send messages to each other to make things happen. The following is a list of patterns we categorize as behavioral patterns:

  • Chain of responsibility
  • Command
  • Interpreter
  • Iterator
  • Mediator
  • Memento
  • Observer
  • State
  • Strategy
  • Template method
  • Visitor

Chain of responsibility pattern

The chain of responsibility pattern decouples the sender of a request from its receiver, by enabling more than one object to handle requests, in a chain manner. Various types of handling objects can be added dynamically to the chain. Using a recursive composition chain allows for an unlimited number of handling objects.

The following is an example of chain of responsibility pattern implementation:

abstract class SocialNotifier {
    private $notifyNext = null;

    public function notifyNext(SocialNotifier $notifier) {
        $this->notifyNext = $notifier;
        return $this-&gt...

Summary

Design patterns are a common, high-level language for developers. They enable a short-hand way of communicating application design among team members. Understanding how to recognize and implement design patterns shifts our focus to business requirement solving, rather than tinkering with how to glue our solution together on a code level.

Coding, like most hand-crafted disciplines, is one of those where you get what you pay for. While implementing a number of design patterns takes a certain amount of time, lack of doing so on a larger project will likely catch up with us in the future, one way or another. Similar to the "use a framework or not" debate, implementing the right design patterns affects extensibility, re-usability, adaptability, and maintainability of our code. Therefore, making it more future proof.

Moving forward, in the next chapter, we will look into the SOLID design principles and the role they play in software development processes.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • This book demonstrates code reusability and distributed development to get high speed, maintainable, and fast applications
  • It illustrates the development of a complete modular application developed using PHP7 in detail
  • This book provides a high-level overview of the Symfony framework, a set of tools and a development methodology that are needed to build a modular web shop application

Description

Modular design techniques help you build readable, manageable, reusable, and more efficient codes. PHP 7, which is a popular open source scripting language, is used to build modular functions for your software. With this book, you will gain a deep insight into the modular programming paradigm and how to achieve modularity in your PHP code. We start with a brief introduction to the new features of PHP 7, some of which open a door to new concepts used in modular development. With design patterns being at the heart of all modular PHP code, you will learn about the GoF design patterns and how to apply them. You will see how to write code that is easy to maintain and extend over time with the help of the SOLID design principles. Throughout the rest of the book, you will build different working modules of a modern web shop application using the Symfony framework, which will give you a deep understanding of modular application development using PHP 7.

Who is this book for?

This step-by-step guide is divided into two sections. The first section explores all the fundamentals of modular design technique with respect to PHP 7. The latter section demonstrates the practical development of individual modules of a web shop application.

What you will learn

  • * Discover the new features of PHP 7 that are relevant to modular application development
  • * Write manageable code based on the GoF design patterns and SOLID principles
  • * Define the application requirements of a working modular application
  • * Explore the ins and outs of the Symfony framework
  • * Build a set of modules based on the Symfony framework that comprise a simple web shop app
  • * Use core modules to set the structure and dependencies for other modules to use
  • * Set up entities that are relevant to the module functionality and see how to manage these entities

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 09, 2016
Length: 332 pages
Edition : 1st
Language : English
ISBN-13 : 9781786461469
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Sep 09, 2016
Length: 332 pages
Edition : 1st
Language : English
ISBN-13 : 9781786461469
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Mex$ 2,610.37 3,262.97 652.60 saved
PHP 7 Programming Cookbook
Mex$903.19 Mex$1128.99
Modular Programming with PHP 7
Mex$903.19 Mex$1128.99
Mastering PHP Design Patterns
Mex$803.99 Mex$1004.99
Total Mex$ 2,610.37 3,262.97 652.60 saved Stars icon

Table of Contents

13 Chapters
1. Ecosystem Overview Chevron down icon Chevron up icon
2. GoF Design Patterns Chevron down icon Chevron up icon
3. SOLID Design Principles Chevron down icon Chevron up icon
4. Requirement Specification for a Modular Web Shop App Chevron down icon Chevron up icon
5. Symfony at a Glance Chevron down icon Chevron up icon
6. Building the Core Module Chevron down icon Chevron up icon
7. Building the Catalog Module Chevron down icon Chevron up icon
8. Building the Customer Module Chevron down icon Chevron up icon
9. Building the Payment Module Chevron down icon Chevron up icon
10. Building the Shipment Module Chevron down icon Chevron up icon
11. Building the Sales Module Chevron down icon Chevron up icon
12. Integrating and Distributing Modules Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(1 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Paul McDowell Dec 01, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
If you have heard of the term "DRY Programming" (Don't Repeat Yourself) this is an excellent book to break the repetitive code habit.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.

Modal Close icon
Modal Close icon