当前位置:网站首页>On the full chain syntax of jsnpp framework

On the full chain syntax of jsnpp framework

2022-06-09 02:38:00 hengaogjh

Jsnpp The framework is an excellent PHP frame , It's been a while since I started to learn , One of the most impressive is Jsnpp Full chain grammar of . Because I am a beginner , So here is just a brief discussion of the whole chain grammar , For the purpose of casting a brick to attract jade .

The whole chain grammar looks like , It is very similar to the chain grammar we usually use , At first glance, you may think it is a common chain grammar . I just started to touch Jsnpp Frame time , That's the feeling , Even at that time, I thought the whole chain was nothing special . however , When I study deeply , It is found that the whole chain grammar is very different from the ordinary chain grammar , It's a two-level thing , Although we use arrows in writing , But when you really understand full chain programming , You'll find the new world .

On the practical application of full chain grammar , This article does not cover in detail , because Jsnpp The official website of the framework (http://www.jsnpp.com) There are detailed tutorials , Here I will mainly analyze the difference between full chain grammar and ordinary chain grammar .

Chain syntax is widely used in mainstream frameworks , As long as you've learned PHP Framework friends will be exposed to chain grammar , So chain grammar is familiar to us . Chain grammar is mainly used to facilitate code writing , You can use arrows to concatenate statements , For example, the following code :

Db::name('user')->where('id', '>', 10)->select();

The above code is the chain syntax of database operations that we often encounter ( Here's just an example , The above code is not Jsnpp Code for the framework ), This kind of grammar brings convenience to our writing . But chain grammar is based on the method level , Let's look at the picture below :

 

The picture above , Normal chaining syntax is simply concatenating methods , However Jsnpp The whole chain grammar of the framework is not just the chain grammar at the method level . Let's look at the picture below :

 

The picture above , yes Jsnpp The level of statements constructed by the whole chain syntax of the framework , We see , The whole chain syntax is implemented at the module or class level , So the whole chain grammar can be applied to the language level , That's what the authorities say “ You can use one line of statements to implement the whole process ”. This is a very big innovation , Full chain programming can bring the following benefits to programming :

1、 Programming thinking is clearer , We can easily view the process of the program along the flow of the whole chain , Not like ordinary programming , You may be confused by the code , Even the code you write is hard to understand after a period of time , These disadvantages can be avoided in the full chain programming mode .

2、 Programming is more efficient , Because we only need to master the flow direction of the whole chain to complete the whole code process , You can actually save a lot of code .

3、 It is especially suitable for company level development , We know that the turnover of the company is inevitable , The same project , Developed by predecessors , Descendants take over , It's something that happens all the time , So future generations need to spend a lot of time reading the original code . And because the Jsnpp The whole chain programming code flow of the framework is very clear , Therefore, it can greatly reduce the cost of personnel handover .

The above is learning Jsnpp A little experience and understanding after the framework , It is also a preliminary understanding of full chain programming , Welcome to have more discussion .

原网站

版权声明
本文为[hengaogjh]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090233597670.html