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
Mastering PHP Design Patterns
Mastering PHP Design Patterns

Mastering PHP Design Patterns: Develop robust and reusable code using a multitude of design patterns for PHP 7

eBook
$35.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
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
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

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

Mastering PHP Design Patterns

Chapter 2. Anti-Patterns

Here's where we start on anti-patterns; before you get your hopes up thinking I'm about to tell you something amazing that will wonderfully streamline your code without using design patterns, I won't be doing that here (did I mention I'm great at crushing hopes and dreams?). Anti-patterns are, in short, things you don't want in your code.

Speaking of crushing hopes and dreams, should you ever have a junior developer, anti-patterns are also a great way of teaching methodologies that should be equally avoided. Learning anti-patterns also can boost the effectiveness of code reviews; instead of debating code quality on the basis of personal opinions, you can have an external source to consult on code quality.

Anti-patterns constitute a terrible method of resolving a recurring problem that is usually ineffective and risks being highly counterproductive. They can then create technical debt as developers must later struggle to refactor...

Why anti-patterns matter

Most programmers come from a background of adopting some form of anti-pattern until eventually realizing how it doesn't scale or doesn't work well. When I was 17 and in my first job as an apprentice developer, I would be whisked down to London Monday-to-Friday, somehow compressing my suit and my totally black clothing into a surprisingly miniscule suitcase, and would learn about software development. On Fridays, we were often released for a half-day at 12:00 but I would pre-book my company train tickets in the afternoon so I would spend my time in fast-food restaurants or coffee shops working on simple projects. Every week, when I came back and tried to scale one of these solutions I would realize new scalability issues and code quality issues. Of course, I had done development before, but these were largely dealing with either brand new incredibly short programming tasks, using pre-made frameworks or dealing with legacy code where the architecture had...

Not invented here syndrome

Cryptography can teach us a very important lesson about software; this is especially true about Kerckhoffs's principle. The principle states this:

"A cryptosystem should be secure even if everything about the system, except the key, is public knowledge."

This was reformulated by Claude Shannon in a form known as Shannon's Maxim:

"One ought to design systems under the assumption that the enemy will immediately gain full familiarity with them".

In layman's terms, in order to have a secure system, it shouldn't be secure just because no one knows how it's been implemented ("security through obscurity"). If you were to secure your money through obscurity, you'd bury it under a tree and hope no one would find it. Whereas, when you use a real security mechanism, such as putting your money in a safe in a bank, you can have every detail about the security system as public information, but providing the security...

God objects

God objects are a tempting consequence of bad software design and also badly implemented object orientation.

Essentially, a God object is an object with either too many methods or too many properties; essentially, it's a class that knows too much or does too much. The God object soon becomes tightly coupled to (referenced by) lots of other bits of code in the application.

So what's actually wrong with this? Well, in short, when you have one bit of code tied into every single other bit of code, you quickly find a maintenance disaster. If you adjust the logic for a method in a God object for one use case, you might find it having unintended consequences for another element.

In computer science, it is often a good idea to adopt a divide and conquer strategy. Often, big problems are just a set of little problems. By solving this set of little problems you can rapidly solve the overall problem. Objects should typically be self-contained; they should only know problems about...

Environment variables in PHP source

Far too often you come across a project on GitHub and you notice that the original developer has left in a config.php file that contains (in the best case) useless database information or (in the worst case) incredibly important API keys.

When these files aren't accidentally versioned they are often shoved in a .gitignore file with a sample file attached for developers to amend as they need. One example of a platform that does this is WordPress.

There are some minor improvements to this, such as putting core configuration in an XML file that is buried in some obscure document with plenty of irrelevant configuration.

I've found that there tend to be two good ways of managing environment variables in PHP. The first method involves putting them in a file on your root folder in a format such as YML and reading these variables as required.

The second way, which I personally prefer, is a method implemented by a library known as dotenv. Essentially, what...

Why anti-patterns matter


Most programmers come from a background of adopting some form of anti-pattern until eventually realizing how it doesn't scale or doesn't work well. When I was 17 and in my first job as an apprentice developer, I would be whisked down to London Monday-to-Friday, somehow compressing my suit and my totally black clothing into a surprisingly miniscule suitcase, and would learn about software development. On Fridays, we were often released for a half-day at 12:00 but I would pre-book my company train tickets in the afternoon so I would spend my time in fast-food restaurants or coffee shops working on simple projects. Every week, when I came back and tried to scale one of these solutions I would realize new scalability issues and code quality issues. Of course, I had done development before, but these were largely dealing with either brand new incredibly short programming tasks, using pre-made frameworks or dealing with legacy code where the architecture had already been...

Not invented here syndrome


Cryptography can teach us a very important lesson about software; this is especially true about Kerckhoffs's principle. The principle states this:

"A cryptosystem should be secure even if everything about the system, except the key, is public knowledge."

This was reformulated by Claude Shannon in a form known as Shannon's Maxim:

"One ought to design systems under the assumption that the enemy will immediately gain full familiarity with them".

In layman's terms, in order to have a secure system, it shouldn't be secure just because no one knows how it's been implemented ("security through obscurity"). If you were to secure your money through obscurity, you'd bury it under a tree and hope no one would find it. Whereas, when you use a real security mechanism, such as putting your money in a safe in a bank, you can have every detail about the security system as public information, but providing the security system is truly secure, you would really only have to keep...

God objects


God objects are a tempting consequence of bad software design and also badly implemented object orientation.

Essentially, a God object is an object with either too many methods or too many properties; essentially, it's a class that knows too much or does too much. The God object soon becomes tightly coupled to (referenced by) lots of other bits of code in the application.

So what's actually wrong with this? Well, in short, when you have one bit of code tied into every single other bit of code, you quickly find a maintenance disaster. If you adjust the logic for a method in a God object for one use case, you might find it having unintended consequences for another element.

In computer science, it is often a good idea to adopt a divide and conquer strategy. Often, big problems are just a set of little problems. By solving this set of little problems you can rapidly solve the overall problem. Objects should typically be self-contained; they should only know problems about themselves...

Environment variables in PHP source


Far too often you come across a project on GitHub and you notice that the original developer has left in a config.php file that contains (in the best case) useless database information or (in the worst case) incredibly important API keys.

When these files aren't accidentally versioned they are often shoved in a .gitignore file with a sample file attached for developers to amend as they need. One example of a platform that does this is WordPress.

There are some minor improvements to this, such as putting core configuration in an XML file that is buried in some obscure document with plenty of irrelevant configuration.

I've found that there tend to be two good ways of managing environment variables in PHP. The first method involves putting them in a file on your root folder in a format such as YML and reading these variables as required.

The second way, which I personally prefer, is a method implemented by a library known as dotenv. Essentially, what happens...

Singletons (and why you should be using dependency injection)


Singletons are classes which can only be instantiated once. You can effectively only have one object per Singleton class in an application. If you've never heard of Singletons before you may jump into the air thinking "Yes! I have a million and one use cases for this!" Well, please don't. Singletons are just terrible and can be effectively avoided.

So, a Singleton class in PHP looks something like this:

<?php 
 
class Singleton 
{ 
 
  private static $instance; 
 
  public static function getInstance() 
  { 
    if (null === static::$instance) { 
      static::$instance = new static(); 
    } 
 
    return static::$instance; 
  } 
 
  protected function __construct() 
  { 
  } 
 
  private function __clone() 
  { 
  } 
 
 
  private function __wakeup() 
  { 
  } 
} 

So here are the reasons...

Database as IPC


At the time of writing, I'm currently over the Atlantic, on my way from London to San Francisco, which is probably a good thing as it means my neck is decisively out of the reach of some previous developers I've worked with.

Let me clear this up for you; your database isn't a message queuing system. You don't use it schedule jobs or queue up tasks to be completed. If you need something to do that, use a queuing system. Your database is for data...the clue is in the name; don't shove temporary messages in there.

There are many reasons why this is a bad idea. One major issue is the fact that in databases there is no real way to not enforce a policy by which you can guarantee that a double-read will not occur, and that is by utilizing row locks. This in turn, results in processes (either incoming out outgoing) being blocked, which in turn results in processing only being able to be done in a serial fashion.

Furthermore, in order to check if there is any work to do you end up essentially...

Auto-increment database IDs


Database auto-increment is something I find incredibly frustrating; pretty much every PHP/MySQL beginner tutorial teaches people to do this, but you really shouldn't.

I have got experience trying to shard auto-increment database IDs, and it's messy. Let's suppose you shard the database so the dataset over two database servers...how on earth can you expect someone to scale auto-increment IDs?

MySQL now even features a UUID function, allowing you to generate good IDs with strong entropy, meaning it also features a higher theoretical limit than auto-increment triggers on tables with an int data type.

In order to use the UUID function, the database table should ideally be a CHAR(20).

Cronjob imitating service


This one is a personal hatred of mine. A developer needs a service to run indefinitely, so they just enable a cronjob that never ends, or simply have a cronjob that operates incredibly frequently (such as once every few seconds).

A cronjob is a scheduled job that will run at a predetermined time. It's not something that operates services for you. Not only is this messy from an architectural perspective, but it scales horribly and becomes terrible to monitor.

A constantly processing task should be treated as a daemon and not as something that runs on the basis of a cronjob.

Monit is a tool in Linux systems that allows you to imitate services.

You can install Monit using the apt-get command:

sudo apt-get install monit

Once Monit is installed, you can add processes to its configuration file:

sudo nano /etc/monit/monitrc

Monit can then be started by running the monit command. It also has a status command so you can verify it is still running:

monitmonit status

You can...

Software in place of architecture


Often, developers will seek to rectify a system's architectural issues at the software development level. While this has use cases, I am a huge fan of seeking to avoid this practice where it is not necessary. Moving issues from the software architecture layer to the infrastructure layer has its advantages.

For example, suppose you need to proxy a request for a particular URL endpoint off to another server. I believe this is best done at the web server level as opposed to writing a PHP proxy script. Apache and Nginx can both handle reverse proxying, but writing a library to do this may mean you come up against several unheard issues. Have you thought you that you'll handle HTTP PUT/DELETE requests? What about error handling? Assuming you nail your library, what about performance? Can a PHP proxy script really be faster than a web server level proxy, utilizing a web server written in a low-level systems engineering language? Surely one or two lines in your...

Interface Bloat


I have come across multiple instances of people thinking they're doing great architecture but it turns out their efforts turn out to be counterproductive. Interface Bloat is a common consequence of this.

Once, when I discussed the importance of Interfaces when doing polymorphism in PHP with a Scrum Master, he responded by telling me about an environment he once worked in where there was an engineer who spent months developing interfaces and thought he was doing brilliant architecture work. Unfortunately, it turns out he wasn't doing great infrastructure work, he was guilty of implementing Interface Bloat.

Interface Bloat is, as the name suggests, is where an Interface is excessively bloated. An interface can be so bloated that it becomes practically impossible for a class to be implemented any other way.

Interfaces should be used sparingly; do you actually need an interface if the class is only ever going to be implemented once and once alone (and realistically, no one is never...

Cart before the horse


Like most developers, I occasionally get bemused by some project management strategies; putting the cart before the horse is no exception.

Putting the cart before the horse is an anti-pattern under which features that never need to be built are architected, thus wasting time. The particular setting this annoys me is in technical meetings discussing a long-term technical plan where a project manager will discuss a feature and immediately demand the technical details of how this feature could be implemented.

Firstly, it's important to note that good developers should go away and have research time to come up with a solution. A developer is only made stronger by the ability to research their intended solution, to break out with their development team, to look online for other people facing similar issues, and then to come back with a unified, well-architected solution.

I spoke at the inaugural Lead Developer conference in London, and there was one quote that stood out to...

Separation of development and operations


I have encountered development environments where developers are expressly forbidden from doing anything at all operational, where traditional development structure is relentlessly battered by the 21st-century web environment. There were caged job roles; you were either a developer or you looked after hosting. They had separate budgets, despite the fact both departments had a clear common destiny.

The result of this kind of setup was that developers and operations technicians never shared knowledge. By combining development and operations (DevOps, if you will) there is not only an effective boost in the quality of the work delivered through a shared knowledge base, but efficiency increases by empowering developers.

In the example I gave, when a site hosted on a company server was hacked or vandalized, all operations would do was restore from a backup. Combining development efforts into this mix not only resulted in vulnerabilities being patched, but...

Excessive separation of development responsibilities


Development responsibilities being split too blatantly can be detrimental to a team.

Some separation is necessary. For example, teams working with Internet of Things (IoT) platforms cannot be expected to maintain a strong electronics engineering knowledge and a strong frontend web development knowledge. That said, developers should be expected to learn other skills they encounter and this can be assisted by encouraging knowledge sharing. Having multi-disciplined team members is not a business disadvantage, indeed it is an advantage.

Error suppression operator


The error suppression operator in PHP is a very dangerous tool indeed. Simply by putting an at symbol, @, in front of a statement, you can suppress any errors that result from it, including fatal errors that stop the execution of a script.

Unfortunately, this cannot necessarily be deprecated yet in PHP; having spoken to those in the PHP internals group, it is the case that there is a whole lot of prerequisite work that would need to be done first as some PHP functions do not have companion error functions to yield the error in the execution of a PHP script. As a result of this, the only way to show a non-fatal error that does not necessarily stop the execution of a script is to catch the error that is thrown during the operation of that particular function

The PHP core unfortunately, contains a considerable amount of technical debt in and of itself. Unfortunately, one thing that a good PHP developer should be good at is spotting technical debt in the PHP core itself...

Blind faith


Once when I was around 11 years old I was sitting in a physics lesson with a limited quantity of protractors and we were slowly passing them around in order to draw an angle. Being the devious short cutter that I was at such a young age, I decided not to wait and just trace a drawing someone else made. This was to the horror of my physics teacher at the time who stopped dead in his tracks and shouted "NO! PHYSICS IS ABOUT ACCURACY!"

He had a point and this is something that is also very true in the programming world.

To avoid blind faith, you should be aware of the following mistakes:

  • Failure to check return types

  • Failure to check your data models

  • Assuming data within your database is correct or is in the format you expect it to be

Let's take this to a more extreme level; take this code:

<?php 
 
$isAdmin = false; 
extract($_GET); 
 
if ($isAdmin === true) { 
  echo "Hey ".$name."; here, have some secret information!"; 
} 

In the preceding...

Sequential coupling


Sequential coupling is where you create a class that has methods that must be called in a particular order. Method names that start with init, begin, or start may be indicative of this behavior; this may be indicative of an anti-pattern depending on the context. Sometimes, engineers use cars to explain abstract concepts, here I'll do the same.

For example, take the following class:

<?php 
 
class BadCar 
{ 
  private $started = false; 
  private $speed = 0; 
 
  private $topSpeed = 125; 
 
  /** 
   * Starts car. 
   * @return bool 
   */ 
  public function startCar(): bool 
  { 
    $this->started = true; 
 
    return $this->started; 
  } 
 
  /** 
   * Changes speed, increments by 1 if $accelerate is true, else decrease by 1. 
   * @param $accelerate 
   * @return bool 
   * @throws Exception 
   */ 
  public function changeSpeed...

The big rewrite


One temptation of developers is to rewrite an entire codebase. There are pros and cons for you to decide, and yes, it is often harder to read existing code than it is to write new code; but please do bear in mind that rewrites take time and can be hugely costly for your business.

Always bear in mind that the sum of your technical debt from any one project can never be greater than starting the project from scratch.

Maiz Lulkin wrote the following in a brilliant blog post:

"The problem of big rewrites is that they are a technical solution to a cultural problem."

Big rewrites are horribly inefficient, especially when you simply cannot guarantee that developers will know any better now. Architecting the new system and migrating the data inside the deadlines can be a tall order.

In addition to this, deploying the big rewrite can be hugely problematic; deploying such a change to the entire codebase of an application can be lethal. Try to deploy code regularly in frequent intervals...

Tester-Driven Development


This is a tongue-in-cheek reference to Test-Driven Development (TDD). TDD is a software development strategy largely revolving around using development tests to drive implementation towards fulfilling the requirements.

Tester-Driven Development, however, is where the requirements are the shortcut and it becomes the case that the software team starts specifying the requirements through bug reports. Tester-Driven Development can also be referred to as Bug-Driven Development as it essentially results in bug reports being used to specify actions and features that developers should implement.

For example, a developer builds a tool to export data from a database to a spreadsheet. It works perfectly, but a tester still comes back and raises a ticket saying that there is a bug in the product; they say that it doesn't contain the ability to export to PDF. If this wasn't in the requirements it shouldn't be raised as a bug. And yes, you should have requirements.

QA teams and...

Bloated optimization


Often, developers may trip over themselves trying to optimize their code or their design artifacts to a ridiculous extent, often before their code even performs basic functions, or even before any code has been created at all. This can rapidly perform issues in production.

In this section, I wish to discuss three anti-patterns specifically relating to this topic:

  • Analysis paralysis

  • Bikeshedding

  • Premature optimization

Analysis paralysis

In short, this is where a strategy is over-analyzed to the point where progress is slowed down, or even stopped entirely in extreme cases. Not only can such solutions become obsolete rapidly, they can be made in under-educated circumstances, for example, in a meeting where an over-analytic boss tries to dig too deep into detail in advance without allowing their developers to actually do some research.

Over-analyzing a problem and seeking a perfect solution upfront just does not work; programmers should seek to refine their solution, not come...

Uneducated manager syndrome


Has your manager ever built a web app themselves? I find that this is a fairly important characteristic for a manager to have. The same way a junior doctor will report to a doctor who has been through the process of being a junior doctor themselves, or a teacher will report to a head teacher who themselves has been a teacher, a software developer should report to someone who has been through that process themselves.

Obviously, in small teams (for example, a small design house that does web development on the side), an engineering manager might not be strictly necessary. This works well where managers do understand the need to defer decisions to the programmers where necessary. However, as soon as things scale up, there needs to be structure.

Decisions such as who to hire, who to fire, how to address technical debt, which elements need most focus, and so on, need to be taken by developers; in addition to this, they sometimes mustn't be taken democratically because...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • *Learn about advanced design patterns in PHP 7
  • *Understand enhanced architectural patterns
  • *Learn to implement reusable design patterns to address common recurring problems

Description

Design patterns are a clever way to solve common architectural issues that arise during software development. With an increase in demand for enhanced programming techniques and the versatile nature of PHP, a deep understanding of PHP design patterns is critical to achieve efficiency while coding. This comprehensive guide will show you how to achieve better organization structure over your code through learning common methodologies to solve architectural problems. You’ll also learn about the new functionalities that PHP 7 has to offer. Starting with a brief introduction to design patterns, you quickly dive deep into the three main architectural patterns: Creational, Behavioral, and Structural popularly known as the Gang of Four patterns. Over the course of the book, you will get a deep understanding of object creation mechanisms, advanced techniques that address issues concerned with linking objects together, and improved methods to access your code. You will also learn about Anti-Patterns and the best methodologies to adopt when building a PHP 7 application. With a concluding chapter on best practices, this book is a complete guide that will equip you to utilize design patterns in PHP 7 to achieve maximum productivity, ensuring an enhanced software development experience.

Who is this book for?

This book is for PHP developers who wish to have better organization structure over their code through learning common methodologies to solve architectural problems against a backdrop of learning new functionality in PHP 7.

What you will learn

  • *Recognize recurring problems in your code with Anti-Patterns
  • *Uncover object creation mechanisms using Creational Patterns
  • *Use Structural design patterns to easily access your code
  • *Address common issues encountered when linking objects using the splObserver classes in PHP 7
  • *Achieve a common style of coding with Architectural Patterns
  • *Write reusable code for common MVC frameworks such as Zend, Laravel, and Symfony
  • *Get to know the best practices associated with design patterns when used with PHP 7
Estimated delivery fee Deliver to Argentina

Standard delivery 10 - 13 business days

$12.95

Premium delivery 3 - 6 business days

$40.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 28, 2016
Length: 270 pages
Edition : 1st
Language : English
ISBN-13 : 9781785887130
Category :
Languages :

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
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
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Argentina

Standard delivery 10 - 13 business days

$12.95

Premium delivery 3 - 6 business days

$40.95
(Includes tracking information)

Product Details

Publication date : Sep 28, 2016
Length: 270 pages
Edition : 1st
Language : English
ISBN-13 : 9781785887130
Category :
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 $5 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 $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 197.97
PHP 7 Data Structures and Algorithms
$48.99
Mastering PHP Design Patterns
$48.99
PHP 7: Real World Application Development
$99.99
Total $ 197.97 Stars icon

Table of Contents

8 Chapters
1. Why "Good PHP Developer" Isnt an Oxymoron Chevron down icon Chevron up icon
2. Anti-Patterns Chevron down icon Chevron up icon
3. Creational Design Patterns Chevron down icon Chevron up icon
4. Structural Design Patterns Chevron down icon Chevron up icon
5. Behavioral Design Patterns Chevron down icon Chevron up icon
6. Architectural Patterns Chevron down icon Chevron up icon
7. Refactoring Chevron down icon Chevron up icon
8. How to Write Better Code Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Half star icon Empty star icon Empty star icon Empty star icon 1.5
(2 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 50%
1 star 50%
Lawrence Jul 07, 2018
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Frustrating to read.* Calls it 'Packergist',* Says Dependency Injection is the 'antidote' to Singletons but doesn't say how. Only gives a poor explanation of DI.* Section named 'Database as IPC'. No mention that IPC means 'interprocess communication'.* Lacking meaningful examplesOverall, this book feels like a rough draft.
Amazon Verified review Amazon
Nikola Stojiljkovic Jan 20, 2023
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Both theory and examples presented in this book are plain wrong. Even junior programmers do not make the types of mistakes that the author here is publishing. Take the Adapter design patter chapter as an example. The author presents "Class Adapter" (which, by the way, can not be implemented in PHP since Class Adapter by definition requires a language to support multiple inheritance) as a simple - class extension. Yes... simply extend a class, add more methods to it and call that an Adapter... Don't touch any of the parent's methods, don't even think about actually adapting the properties available to your Client Service to the properties of the Adaptee class. Just extend it and you're done. These are beginner's mistakes which should not be published in a book which teaches theory.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the digital copy I get with my Print order? Chevron down icon Chevron up icon

When you buy any Print edition of our Books, you can redeem (for free) the eBook edition of the Print Book you’ve purchased. This gives you instant access to your book when you make an order via PDF, EPUB or our online Reader experience.

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
Modal Close icon
Modal Close icon