Home > Backend Development > PHP Tutorial > PHP Tutorial: 'Introduction to PHP Design Patterns' Introduction_PHP Tutorial

PHP Tutorial: 'Introduction to PHP Design Patterns' Introduction_PHP Tutorial

WBOY
Release: 2016-07-21 14:57:43
Original
743 people have browsed it

"Introduction to PHP Design Patterns" Introduction

When you are constantly trying to discover new features from your application, have you discovered the solutions you proposed? Is the method so similar to something you've implemented before? If you're a programmer (even if you've only been starting out for a short time), you probably answered "yes." It looks like you are using some old code to solve newly discovered problems during software development. You may have realized that your solution is a fundamental principle, a method that can be widely repeated not only by you but by all professional developers.

In fact, many programming problems are encountered repeatedly, and many basic methods (or design patterns) used to solve these problems have emerged. A design pattern is a template that teaches you how to organize your code using authentic and reliable designs.

History of Design Patterns

The term “design pattern” was originally coined in the field of architecture. In his 1977 book "A Pattern Language: Towns/Building/Construction", Christopher Alexander describes some common architectural design problems and explains how to use this collection of existing, well-known patterns to start new and effective designs. . Alexander's perspective translates well to software development, and there is a long-term consensus on using existing components to construct new solutions. Web Teaching Network

All design patterns have some common characteristics: a name, a problem statement, and a solution. Webjx.Com

A design pattern identification is important because it allows other programmers to immediately understand the purpose of your code without having to study too deeply (at least through this identification, programmers will be able to familiar with this pattern).
The problem description is used to illustrate the application domain of this pattern. ?
The solution describes the execution of this model. A good discussion of a design pattern should cover the advantages and disadvantages of using the model.
A pattern is an effective way to solve a specific problem. A design pattern is not a library (a library of code that can be included and used directly in your project) but a template for organizing your code. In fact, there are many differences in the application of a code base and a design pattern.

For example, a shirt you buy from a store is a code library. Its color, style and size are determined by the designer and manufacturer, but it meets your needs.

However, if there is nothing in the store that suits you, then you can create your own shirt (design its shape, choose the fabric, and tailor it together). But if you are not a tailor, you may find it easy to find a suitable pattern and then design your own shirt according to this pattern. Using a mockup, you can get a proficiently designed shirt in less time.

Back to discussing software, a data extraction layer or a CMS (content management system) is a library - it has been previously designed and coded, if it meets your needs accurately Then it's a good choice. But if you're reading this, you may have discovered that stock solutions don't always work for you. Now that you know what you want, and you can achieve it, you just need a model to guide you.

One final thought: Just like a tailoring model, a design is of little use on its own. After all, you can't wear a model of clothing - it's just pieced together from thin paper. Similarly, a software design model is just a guide. It must be specially designed according to the characteristics and requirements of the programming language and your application.

Goals of this book


The purpose of this book is not to comprehensively introduce various types of software design patterns, nor to develop a new design pattern or terminology, but In order to highlight some existing famous design patterns. What makes this book unique is that it introduces some design patterns that I think are helpful in developing dynamic WEB applications, and shows how to implement these design patterns in PHP.


Object-Oriented Programming OOP

One advantage of this book is that all viewpoints are based on OOP, a very natural design pattern, and are implemented using OOP.

If you are not familiar with OOP, there are many related resources (books, websites, magazines, classes, etc.) to help you understand it better. Most OOP literature extols its benefits - code reuse, code robustness, code encapsulation, polymorphism and extensibility, all of which are also very important and useful. However, I think the main advantage of OOP is how it encourages you to break down problems into tractable modules by yourself. Clear design and implementation, broken down into smaller modules, will allow your code to be more thoroughly tested and easier to understand and maintain.

Reader skill requirements

This book assumes that you are already fluent in PHP. In particular, this book assumes that you already have a working knowledge of PHP and PHP syntax and understand the basic principles of executing PHP code using OOP. This book is not an introduction to PHP programming, nor is it intended to introduce OOP programming in PHP.

Since not all OOP developers use the same terminology, when new terms are introduced, I will define them in the text or in the toolbar.

  • Total 3 pages:
  • Previous page
  • 1
  • 2
  • 3
  • Next page

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/363972.htmlTechArticle"Introduction to PHP Design Patterns" Introduction When you are constantly trying to discover new features from your application , do you find that the solution you proposed and some things you have implemented before...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template