In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you an example analysis of discussing PHP with the boss. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Mind map
Talk to the boss about some of our code structure today, some of which may be helpful to you.
Dialogue
1 > A single file is huge (more than 5000 lines)
Me: the document conference will not affect the performance? When the PHP language deals with source files (this is mainly the lexical and syntactic analysis of php), it cuts the source files into token. If the file is very large, it will mark all the methods we don't need at present, which obviously affects the performance, doesn't it?
Boss: the impact on performance is relatively small. When we consider the performance, we should consider the overall view, for example, when displaying the page, it is very slow to open the page, then our first consideration is not the file size, but the loading speed of each module. For example, if you find that the reading of a product list is slow through your breakpoint setting, you should consider whether it is slow to assemble data or slow to read data from the interface (database or middle tier). If the assembly data is slow, you should reconstruct the algorithm, or discuss with the product staff whether you can modify the solution. If the interface is slow to read data, does it need to add a machine or index to solve the problem? Therefore, considering the performance problem, we should not grasp the small problem, but should consider the place that affects the performance most to make the modification.
Me: what's wrong with segmenting large file classes into different classes?
Boss: if you add a lot of class files through a lot of require_once in a method body, doesn't it also affect performance?-- require_once itself consumes performance!
Draw a picture for me (similar to the one above):
Me: then I can use include to logically load files and load files conditionally. This reduces the number of files loaded!
Boss: so how do you load according to the conditions?
Me: for example, I can load files by category. When I make a movie, I load the program files related to the movie, and when I am on TV, I load the program files related to the TV.
Boss: what will you do when TV is going to use the content in the movie in the future? Or what do you do when many categories use the content in your movie category?
Me: then I'll put a bunch of "| |" codes (such as if ('movie' = $category | |'TV'= = $category | | 'music' = $category) {}). Later, I thought, indeed, if I do so, there will be a lot of such if statements in a method, so when I have to deal with a certain category, I will have to look at a bunch of if. You might as well write it together or ReFactor the code!
2 > autoload () method.
Similar to the following code.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.