Project Iterative Development Instruction - Document Segmentation Storage Case Implementation Process (1)

xiaoxiao2021-03-06  81

Summary This article describes the implementation examples of implementing the use cases in small horizontal iteration development in the attempt to use extreme programming in software development, while each iteration can integrate implementation.

Keyword limit programming

In a project development, our development group has encountered a demand. The technology to be used is what we are not familiar, that is, in the development process, we must gradually master the technology, and hope to keep the code as much as possible. Have a good structure, because in the process of increasing the function, the code will gradually reduce the readability.

The use case of this demand is simple, that is, saving the file file into the database, and extracts when you need it. However, some of the file files will be relatively large, and there may be performance problems during submission to the database, and there is a problem with the file file format, (. BMP, .jpeg)

When the group discussed, everyone proposed to first compress the data to be saved, and simultaneously divide a large file into a suitable block, so that there will be no performance issues in the database. In this way, the data is extracted and spliced ​​in the process of extracting the file, and the original data can be obtained, and there is a conversion problem in the file format.

This feature I would like to be very simple for familiar developers, but because of the developers in our group, it is impossible to get excellent design at the beginning, can only improve you in a constant development process. Design, in the past, we tried the benefits of small steps, which is to achieve demand for the demand in the continuous accumulation, while reducing the frustration in the process - your one is very good to achieve demand. Function, you can also integrate your software daily, master your development progress in real time.

Each iterative implementation is a function of high priority.

We believe that the premium and extraction of the file file is the highest priority, we first guarantee that you can submit the diagram to the database, and you can file the archive. This allows the other development group to use this feature after we complete this feature (although there will be highly saved and extracted efficiency issues because the picture is too large, it is the functionality that can be used). The development tool we use is Delphi database is Oracle

Iteration 1: The file is saved in binary form to the database, and then extract from the database in binary form.

By looking for information, we decide that the Oracle database uses the LONG RAW type field to save binary data, and Delphi uses TBLOBField to submit the stream load field in the database. Example of this article simplifies the design of the table and the simplified code

Design

Field Name Field Type Field Length Field Description

FID NUMBER

Primary key

F_name varchar2 50 file name

F_binary_data long raw

Binary file data

Procedure TFORM1.BUTTON2CLICK (Sender: TOBJECT);

VAR

OpenDialog: TopEndialog;

LfileFullname: String;

Lblobstream: TmemoryStream;

Begin

LfileFullname: = '';

OpenDialog: = Topendialog.create (Self);

LBLOBSTREAM: = TMEMORYSTREAM.CREATE;

Try

OpenDialog.initialDir: = extractFilePath (Application.exename);

If OpenDialog.execute THEN

LfileFullname: = OpenDialog.FileName;

IF LFILEFULLNAME <> '' THEN

Begin

Lblobstream.loadfromfile (LfileFullname);

ClientDataSet1.Append;

ClientDataSet1.fieldByname ('f_id'). Value: = 2; ClientDataSet1.fieldByname ('f_name'). Value: = lfilefullname;

(ClientDataSet1.fieldbyName ('f_binary_data') as tblobfield) .loadFromstream (LBLOBSTREAM);

ClientDataSet1.post;

END;

Finally

OpenDialog.Free;

Lblobstream.free;

END;

END;

This allows you to submit the file data to the database, where the file file is loaded into a stream and then submitted to the database in the form of binary stream.

The way the extraction is

(ClientDataSet1.fieldByname ('f_binary_data') as tblobfield). SaveTostream (LBLOBSTREAM);

This completes the saving and extraction of the file file. Since this technology is not familiar with this function, we will spend 3 hours of time. We submit programs that can be used to save the files in the afternoon.

转载请注明原文地址:https://www.9cbs.com/read-107011.html

New Post(0)