PHP Design Patterns

Story About Starting of PHP Design Patterns : Rohit works at a large insurance firm . His most recent task was dveloping a way to show coustomer information to the call center representative over a web interface. He designed a complex system that would allow the reps to reach for a customer, enter call logs, update customer coverage information, and process payments. The system went into place smoothly , minus the few bumps and hiccups that a new installation in a production environment always runs into. Rohit is happy , relaxed, and ready to sit back in the break room sipping his free coffee.

Overnight, the insurance company triples in size from it's most recent investment. Not only is Rohit called back to work on providing new scalability and enhncements to the call center software but there has been buzz about adding some new feature to the corporate site to support the new acquistions's customers . Rohit's department is also increased to include two new developer , Mohit and Sonia.

The news comes down from the vice president that the corporate site needs to allow customers to process their payment after they have completed a successful, secure user log in . Additionaly, the system needs to show how many times the customer has called in to the call center. Fanally, it needs to show an audit log of every change the call center has made to the customer's account .

Rohit knows that he can easily update the call center software to provide the audit log and then copy over the code, tweak it, and make use of the payment processing . However, the new programmers need to be tasked without without much time to get up to speed on the new system . Rohit's boss has assigned them the portions of the project that Rohit is most familiar with. Since Rohit is the rock-star PHP programmer with the most experience, his boss needs him to work on the other portions of the corporate site as soon as possible after which he'll then come around and make use of the new programmers's changes to the auditing on the call center software . In the end, it will be his responsbility to provide hooks for the new payment-processing portion of the user login screen.

Rohit's code isnot bad, but it seems to be taking Mohit a bit longer to follow through and part the payment-processing portion into the corporate site. Instead, he detemines he could finish faster by writeing it in his own method . He mentions this to Rohit and continues on his way. Sonia is also struggling. Since her Master in computer science is newly acquired, she hasn't had much time to gain experince with the jumbled code that sometimes supports existing enterprises

Through much struggle and late nights, the team is successful and deploys the new code changes. Sonia feels like everything could have been architected better. Rohit thinks that if the other programmers would have just copied and pasted his code, thing would have gone must faster; Mohit and Sonia just needed to make few tweaks and it would have been solid. Mohit mentioned that he was confused about why some functionality was implemented in one section of the code and in a different way in different piece. That what threw him off.

As the website continues to gain more visitors, the performance begin to suffer. Rohit's boss suggests that the team take a few days and look at the code for optimization.

Mohit discovers that the method that he wrote for payment processing is nearly the same as Rohit's. Mohit combines and tweaks the mathods into one class. Rohit is starting to see similaries between the authentication code that he wrote for call center site and the classes he authored for corporate site's user login. Sonia is realizing that every PHP page they created has the same set of function call at the top of it . She creates a bootstrap type class to bring this all into one locationto reduce code duplication.

We can Objectively see many thing. Rohit's code could have benefited from commonality in it's approch. Sonia's formal education in software design made her sometimes quetion PHP's ability to accomplish the tasks and question the architecture. Mohit couldn't easily understand Rohit's payment system, so he opted to create his own, causing code duplication. Fanally, after the software analysis, the team started discovering patterns in their seemingly jumbled code base. This the beginig of this team's foray into design Patterns.

Here (Below) we are explaining in brief about all applicable PHP design patterns like adapter pattern, builder pattern, decorator patterns, delegate pattern , facde pattern, factory pattern , interator pattern, mediator pattern, observer pattern, prototype pattern, proxy pattern,singleton pattern, stratagy pattern , template pattern, visitor pattern and also if you need interview questions with answers on php design patterns just need to fill the form below for that


Below are the some PHP Design Patterns in brief

Addepter patern

The Adapter Design Patterns simply adapts one object's interface to what another object expects. Implementing an adapter object is both best practice and a headache saver when one object's interface needs to be translate for use by another

Builder Pattern

The Builder Design Pattern defines the design of an object that handles the complex building of another object. The Builder Design Pattern is Meant to eliminate the complex creation of other objects. Using the builder Design pattern is not only best practice but also reduces the chances of having to repeatedly alter pieces of code if an object's construction and configuration method change.

Decorator Pattern

The Decorator Design Pattern is best suited for altering or decorating portions of an existing object's content or functionality without modifying the structure of the original object. so to make small modifications to content or functionality of existing objects without modifying their structure, the Decorator Design Pattern should be used.

Delegate Pattern

The Delegate Design Pattern removes decisions and complex functionality from the core object by distributing or delegate them to other objects. So To remove complexity from the core object while making the process dynamic to add more functionality , The delegate pattern should be used.

Factory Pattern

The Factory Design Pattern provides a simple interface to acquire a new instance of an object, while sheltering the calling code from the steps to determine which base class is actually instantiated. while requesting an istance of a class that requires some logic and step to determine its base, it is best practice to use a class based on the Factory Design Pattern.

Observer Pattern

The Observer Design Pattern facilitates the creation of objects that watch the state of target object and provides state targated functionality that is uncoupled from the core object.

Singleton Pattern

The Singleton Design Pattern is used to restrict the number of times a specific object can be created to a single time by providing accesss to a shared instance of itself. So When the instantiation of an object should only be allowed to happen one time during the code stream, using the Singleton Design Pattern is best practices

Next Page 1 | Next Page 2 | Next Page 3



Ask your interview questions on PHP Design Pattern

Write Your comment or Questions if you want the answers on PHP Design Pattern from PHP Design Pattern Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 






--------- Tutorials ---