Php Tutorial: Introduction to PHP design patterns. Introduction to PHP design patterns when you constantly try to discover new features from your applications, are you aware of the solution you proposed and the problems you have implemented before?
Introduction to PHP design patterns
When you are constantly trying to discover new features from your application, do you find that the solution you proposed is so similar to something you have previously implemented? If you are a programmer (even if you start for a short time), you may answer "yes ". It seems that you have used some previous code to solve the newly discovered problems in the software development process. You may have realized that your solution is a basic principle and a method that is not only applicable to you but also widely used by all professional developers.
In fact, many program problems are constantly encountered, and many basic methods (or design patterns) used to solve these problems have emerged. The design pattern is a template that teaches you how to organize your code using authentic and reliable design.
Design Pattern History
The term "design patterns" was initially designed for the field of architecture. Christopher Alexander described some common architectural design problems in his 1977 book "A Pattern Language: Towns/Building/Construction" and explained how to use these existing, A collection of famous patterns to start a brand new effective design. Alexander's point of view is well transformed into software development, and long-term consensus is to use the original components to construct new solutions. Webpage Tutorial network
All design patterns have some common features: a name, a problem statement, and a solution ). Webjx. Com
The identifier of a design pattern is important, because it allows other programmers to understand the purpose of your code immediately without having to study it too deeply (at least the programmer will be familiar with this pattern through this identification ).
The problem description is used to describe the application fields of this model .?
The solution describes the execution of this model. The discussion of a good design model should cover the advantages and disadvantages of using this model.
One mode is an effective way to solve specific problems. A design pattern is not a library (a code library that can be directly included and used in your project) but a template used to organize your code. In fact, there are many differences between a code library and a design model in applications.
For example, the color, style, and size of a shirt you buy from a store is determined by the designer and manufacturer, but it meets your needs.
However, if there are no clothes in the store that suit you, you can create your own shirt (design its shape, select the fabric, and then make a tailor together ). But if you are not a tailor, you may find it easy to find a proper pattern and then design your shirt according to the pattern. With a model, you can get a well-designed shirt in less time.
Back to the discussion Software, a data extraction layer or a CMS (content management system) is a library-it was previously designed and encoded, if it meets your needs accurately, it is a good choice. But if you are reading this book, you may find that the inventory (original) solution is not always effective for you. So far you know what you want, and you can implement it, you only need a model to guide you.
Last thought: like a tailor model, a design itself is useless. After all, you cannot wear a clothing model-it is simply pieced together by thin paper. Similarly, a software design model is just a guide. It must be specifically designed based on the programming language and the characteristics and requirements of your application.
Objectives 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 patterns or terminology, but to highlight some existing well-known design patterns. This book introduces some design patterns that I think are helpful for 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 ideas are based on the natural design model of OOP and implemented using OOP.
If you are not familiar with OOP, there are many related resources (books, websites, magazines, classes, etc.) to help you better understand it. Most OOP materials praise its benefits-code reuse, robust code, code encapsulation, polymorphism, and scalability. of course, all these are also very important and useful. However, I think the main advantage of OOP is how it inspires you to break down the problem into easy-to-handle modules. Clear design and implementation into small modules, so that your code can be thoroughly tested and easier to understand and maintain.
Reader skill requirements
This book assumes that you can use PHP smoothly. In particular, this book assumes that you have learned how to operate PHP and PHP syntax and how to execute PHP code with OOP. This book is not an introduction to PHP programming, nor is it intended to introduce php oop programming.
Since not all OOP developers use the same term, I will define it in the text or toolbar when new terms are introduced.
- Three pages in total:
- Previous Page
- 1
- 2
- 3
- Next page
Introduction: when you are constantly trying to discover new features from your application, do you find the solution you proposed and some previous things you have implemented...