How to provide false data?

This is the back-end small class of the monastery. Each article is shared from

[background introduction] [knowledge analysis] [common problems] [solutions] [coding practice] [extended thinking] [more discussion] [References]

Eight aspects of in-depth analysis of back-end knowledge / skills. This article shares:

[how to provide false data?]

Hello, I'm the 10th student of Shenzhen Branch of it Academy. I'm an honest, pure and kind java programmer.

Today, I'd like to share with you Java task 10 on the official website of the Academy - how to provide false data?

1. Background introduction

In the development of a new project, the allowable development time is relatively short, and the front and back ends need to be developed at the same time. The back-end development does not depend on the front-end, and the technical level determines the development time. However, the front end is different. Static pages can be developed independently, but the development of dynamic pages depends on the data provided by the back end. If the front end is separated from the data support of the back end and works hard by itself, there will be a lot of changes before the project is released; The development time is limited, and it is not allowed to wait until the back-end interface is developed before the front-end development and debugging.

Let's discuss how to solve the above two problems:

A. No major changes?

Front and back end coordination is required to determine the data structure, data type, object name and other contents returned by the interface, that is, the protocol of the interface document needs front and back end coordination to determine the data structure, data type, object name and other contents returned by the interface, that is, the protocol of the interface document. In fact, the back-end writes interface documents, and then shows them to the front-end. After the front-end confirms that there is no problem, it can carry out development.

B. When the background is not fully developed, the front end is developed at the same time?

Use false data. Who provided this false data? The false data depends on the interface document, and the input and output parameters of the interface document depend on the DB design. The DB design is done by our back-end, so the false data is provided by our back-end.

2. Knowledge analysis

A. What is the type of false data?

False data is JSON type. JSON is a JS object representation that uses JavaScript syntax to describe data objects. JSON syntax is a subset of JS syntax, but JSON is still independent of language and platform. It is a syntax for storing and exchanging text information and a lightweight text data exchange format. Therefore, we use JSON format to provide false data.

B. Principle of providing false data

Simulate false data, not simulated garbage data. False data only means that the data is untrue and does not mean that the data can be filled in casually. When simulating data, ensure the diversity of data. 1. Simulate the normal use as much as possible; 2 is to simulate abnormal situations as much as possible.

3. How to provide false data?

A. The answers found on the Internet are that the front end uses mock JS to write false data, which has a certain risk. What are the risks? The false data mentioned above should be true. If the front end does not understand the interface documents thoroughly or has deviation, there will be problems with the false data written by it. There will still be many problems in the stage of interface joint commissioning.

B. Here, the method I use is rap mentioned in the last article. Rap itself supports automatic generation of false data. As long as we use rap to write interface documents, rap will help us generate false data. In rap, we can also use @ mock to specify the format of the generated false data. These contents are clearly written in the official user manual of rap. Rap also has an official demonstration video, which is very easy to get started, so I won't repeat it.

Return to the topic of providing false data. Rap provides a plug-in. The front end can use false data by introducing this plug-in into the code.

After the interface document written in rap on the back end, click the "configuration" button in the upper right corner of the page, and there will be a line of code, which is the rap plug-in mentioned above. The plug-in maps the interface document we just wrote. Give this line of code to the front end. The front end needs to introduce JQ in HTML first, followed by rap plug-in, so that false data can be used.

The detailed process is shown in the following video.

3. Frequently asked questions

How to write false data of multiple data

4. Solutions

String[] = {}String[] = {}String[] = {}String[] = {}String[] = {}String[] = {+
        }String[] = {}String[] = {}[] = {}[] = {}[] = {}
(num) {
    i = num % .= [i].= [i].= [i].= [i].= num.= [i].= [i].= [num % ].= [num % ].= .= [i].= [i].= [num % ]}

6. Expand thinking

1. Q: can spring cloud be combined with zookeeper?

A: spring cloud can use zookeeper as the registry or consumer as the registry. It doesn't have to use Eureka. But if you use Eureka, you can use the OSS components of Netflix, which is more convenient to build.

2. What is the content of the HTTP request address and resource file mapping

/{application}/{profile}[/{label}]

/{application}-{profile}. yml

/{label}/{application}-{profile}. yml

/{application}-{profile}. properties

/{label}/{application}-{profile}. properties

3. What dependencies are needed

Skill tree It Academy

"We believe that everyone can become an engineer. From now on, find a senior brother to introduce you, control your learning rhythm, and stop being confused on the way to learning.".

Here is the skill tree In it academy, thousands of senior brothers have found their own learning route here. Learning is transparent and growth is visible. Senior brothers have 1-to-1 free guidance.

Come and study with me~ http://www.jnshu.com/home

Tencent Video: https://v.qq.com/x/page/s0551tauvug.html

Ppt link video link

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>