CN113961183A - Visual programming method, device, equipment and storage medium - Google Patents

Visual programming method, device, equipment and storage medium Download PDF

Info

Publication number
CN113961183A
CN113961183A CN202111229751.7A CN202111229751A CN113961183A CN 113961183 A CN113961183 A CN 113961183A CN 202111229751 A CN202111229751 A CN 202111229751A CN 113961183 A CN113961183 A CN 113961183A
Authority
CN
China
Prior art keywords
primitive object
primitive
target
initial
java
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111229751.7A
Other languages
Chinese (zh)
Inventor
王辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202111229751.7A priority Critical patent/CN113961183A/en
Publication of CN113961183A publication Critical patent/CN113961183A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/24Object-oriented
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention relates to the field of research and development management and discloses a visual programming method, a visual programming device, visual programming equipment and a storage medium. The method comprises the following steps: acquiring a plurality of basic functions and description information thereof in a Java atomic function library, and constructing a plurality of initial Java primitive objects based on the basic functions; performing primitive conversion on each initial Java primitive object according to a preset conversion algorithm to obtain a corresponding initial Block primitive object; constructing a visual programming main page according to the description information and the initial Block primitive object; receiving operation information of a user on a visual programming main page, and generating an initial primitive object sequence; and searching a target Java primitive object according to the primitive information in the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and further generating a target program. The invention realizes the conversion between Java language and Blockly language, thereby realizing the visual programming based on Java and improving the development efficiency.

Description

Visual programming method, device, equipment and storage medium
Technical Field
The present invention relates to the field of research and development management, and in particular, to a visual programming method, apparatus, device, and storage medium.
Background
Blockly is a visual programming tool published by Google, which is built based on web technology. Similar in functional design to the child programming language Scratch of MIT (open source software licensing agreement). When using Blockly, the user can build the code logic by dragging the module, much like building a block. From the user perspective, Blockly is a simple and easy-to-use visualization tool for generating code. From the developer's perspective, Blockly is a text box that contains the code that the user has entered.
For a high-cooperation and high-agility ecological application system, business personnel use Blockly to perform simple graphic programming, developers use professional development languages to perform programming, and the business personnel and the development languages can be seamlessly converted.
In the prior art, for the open source version of Blockly, only the code conversion function with JavaScript, Python, PHP, Dart, Lua, and XML languages is provided. While Java language is currently the mainstream development language of business, the prior art does not support the interconversion with Blockly, thus resulting in low development efficiency.
Disclosure of Invention
The invention mainly aims to solve the problem of how to convert Blockly into Java so as to improve the development efficiency.
The invention provides a visual programming method in a first aspect, which comprises the following steps:
acquiring a plurality of basic functions in a preset Java atomic function library and description information of each basic function, and constructing a plurality of initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
performing primitive conversion on each initial Java primitive object according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each initial Java primitive object;
constructing a visual programming main page according to the description information of each basic function and the initial Block primitive object;
receiving operation information of a user on the visual programming main page, and generating an initial primitive object sequence for representing service requirements according to the operation information, wherein the initial primitive object sequence comprises at least one target Block primitive object selected by the user;
and searching a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence.
Optionally, in a first implementation manner of the first aspect of the present invention, the performing, according to a preset conversion algorithm, primitive conversion on each initial Java primitive object to obtain an initial Block primitive object corresponding to each initial Java primitive object includes:
performing syntax analysis on each initial Java primitive object based on a JavaParser tool library to obtain an initial abstract syntax tree of each initial Java primitive object;
based on a preset formatting algorithm, tiling a nested structure in the abstract syntax tree into an associated array structure to obtain a target abstract syntax tree;
and converting the atomic expression in the target abstract syntax tree into an extensible markup language based on a preset conversion rule to obtain an initial Block primitive object corresponding to each initial Java primitive object.
Optionally, in a second implementation manner of the first aspect of the present invention, the constructing a visual programming main page according to the description information of each base function and the initial Block primitive object includes:
constructing a primitive description tree according to the description information of each basic function and the initial Block primitive object;
performing page rendering based on a preset home page template file to obtain a static programming home page, wherein the static programming home page comprises a plurality of page modules;
and receiving a data request of each page module, acquiring tree node information corresponding to the primitive description tree according to the data request, and carrying out local reloading on the page modules to obtain a visual programming main page.
Optionally, in a third implementation manner of the first aspect of the present invention, after the constructing a primitive description tree according to the description information of each base function and the initial Block primitive object, the method further includes:
and storing the primitive description tree into a server, and updating the primitive description tree in the server when detecting that an initial Block primitive object is newly added.
Optionally, in a fourth implementation manner of the first aspect of the present invention, the performing page rendering based on a preset home page template file to obtain a static programming home page includes:
traversing document nodes in the homepage template file, and generating a document object node tree model corresponding to the homepage template file according to the document nodes;
analyzing the cascading style sheet mark in the homepage template file, and generating a cascading style sheet rule tree model corresponding to the homepage template file based on the analysis result;
constructing a rendering tree model corresponding to the homepage template file according to the document object model node tree model and the cascading style sheet rule tree model;
based on the rendering tree model corresponding to the homepage template file, laying out the elements in the homepage template file on the nodes corresponding to the rendering tree model;
and drawing each node in the rendering tree model in sequence to obtain a static programming main page.
Optionally, in a fifth implementation manner of the first aspect of the present invention, the receiving operation information of a user on the visual programming main page, and generating an initial primitive object sequence for representing a business requirement according to the operation information includes:
receiving operation information of a user on the visual programming main page, wherein the operation information comprises identification information of a dragged object and arrangement information of the dragged object;
determining at least one target Block primitive object according to the identification information of the dragged object;
and arranging the target Block primitive objects according to the arrangement information of the dragged objects to obtain an initial primitive object sequence.
Optionally, in a sixth implementation manner of the first aspect of the present invention, the searching, according to primitive information in the target Block primitive object, for a target Java primitive object corresponding to the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating, according to the target primitive object sequence, a target program includes:
detecting a target Java primitive object in a local storage space according to the identification information of the target Block primitive object, wherein the target Java primitive object corresponds to the target Block primitive object;
if the target Java primitive object is not detected in the local storage space, searching the target Java primitive object in a remote server according to the primitive information in the target Block primitive object;
lazily loading the target Java primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence.
The second aspect of the present invention provides a visual programming apparatus, comprising:
the primitive constructing single module is used for acquiring a plurality of basic functions in a preset Java atomic function library and description information of each basic function, and constructing a plurality of initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
the primitive conversion module is used for performing primitive conversion on each initial Java primitive object according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each initial Java primitive object;
the homepage construction module is used for constructing a visual programming homepage according to the description information of each basic function and the initial Block primitive object;
the sequence generation module is used for receiving operation information of a user on the visual programming main page and generating an initial primitive object sequence for representing service requirements according to the operation information, wherein the initial primitive object sequence comprises at least one target Block primitive object selected by the user;
and the program generation module is used for searching a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence.
Optionally, in a first implementation manner of the second aspect of the present invention, the primitive translation module specifically includes:
the syntax analysis unit is used for carrying out syntax analysis on each initial Java primitive object based on a JavaParser tool library to obtain an initial abstract syntax tree of each initial Java primitive object;
the formatting unit is used for tiling a nested structure in the abstract syntax tree into an associated array structure based on a preset formatting algorithm to obtain a target abstract syntax tree;
and the expression conversion unit is used for converting the atomic expression in the target abstract syntax tree into an extensible markup language based on a preset conversion rule to obtain an initial Block primitive object corresponding to each initial Java primitive object.
Optionally, in a second implementation manner of the second aspect of the present invention, the homepage building module specifically includes:
the description tree construction unit is used for constructing a primitive description tree according to the description information of each basic function and the initial Block primitive object;
the homepage template rendering unit is used for performing page rendering based on a preset homepage template file to obtain a static programming homepage, wherein the static programming homepage comprises a plurality of page modules;
and the data loading unit is used for receiving the data request of each page module, acquiring tree node information corresponding to the primitive description tree according to the data request, and carrying out local overloading on the page module to obtain a visual programming main page.
Optionally, in a third implementation manner of the second aspect of the present invention, the home page template rendering unit is specifically configured to:
traversing document nodes in the homepage template file, and generating a document object node tree model corresponding to the homepage template file according to the document nodes;
analyzing the cascading style sheet mark in the homepage template file, and generating a cascading style sheet rule tree model corresponding to the homepage template file based on the analysis result;
constructing a rendering tree model corresponding to the homepage template file according to the document object model node tree model and the cascading style sheet rule tree model;
based on the rendering tree model corresponding to the homepage template file, laying out the elements in the homepage template file on the nodes corresponding to the rendering tree model;
and drawing each node in the rendering tree model in sequence to obtain a static programming main page.
Optionally, in a fourth implementation manner of the second aspect of the present invention, the sequence generating module specifically includes:
the receiving unit is used for receiving operation information of a user on the visual programming main page, wherein the operation information comprises identification information of a dragged object and arrangement information of the dragged object;
the determining unit is used for determining at least one target Block primitive object according to the identification information of the dragged object;
and the arrangement unit is used for arranging the target Block primitive objects according to the arrangement information of the dragged objects to obtain an initial primitive object sequence.
Optionally, in a fifth implementation manner of the second aspect of the present invention, the program generating module specifically includes:
the local searching unit is used for detecting a target Java primitive object in a local storage space according to the identification information of the target Block primitive object, wherein the target Java primitive object corresponds to the target Block primitive object;
the remote searching unit is used for searching the target Java primitive object in a remote server according to the primitive information in the target Block primitive object if the target Java primitive object is not detected in a local storage space;
and the primitive replacing unit is used for lazily loading the target Java primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence.
A third aspect of the present invention provides a visual programming apparatus comprising: a memory and at least one processor, the memory having instructions stored therein; the at least one processor invokes the instructions in the memory to cause the visual programming apparatus to perform the visual programming method described above.
A fourth aspect of the present invention provides a computer-readable storage medium having stored therein instructions, which, when run on a computer, cause the computer to perform the above-mentioned visual programming method.
According to the technical scheme, a Java primitive object is constructed by a Java basic function, the Java primitive object is converted into a Block primitive object by a preset algorithm, a corresponding visual programming homepage is constructed according to the description of the basic function and the Block primitive object, an initial primitive object sequence composed of a plurality of Block primitive objects is generated after a user operates in the visual programming homepage, and finally the Block primitive object in the initial primitive sequence is replaced by the corresponding Java primitive object, so that the target program is generated. The invention realizes the conversion between Java language and Blockly language, and the user can generate corresponding Java code logic only by operating in a visual programming homepage, thereby improving the development efficiency.
Drawings
FIG. 1 is a schematic diagram of a first embodiment of a visual programming method according to an embodiment of the invention;
FIG. 2 is a schematic diagram of a second embodiment of a visual programming method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a third embodiment of a visual programming method according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a fourth embodiment of a visual programming method according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of an embodiment of a visual programming apparatus according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of another embodiment of a visual programming apparatus according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of an embodiment of a visual programming apparatus in an embodiment of the invention;
FIG. 8 is a diagram illustrating a structure of a syntax tree according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a visual programming method, a visual programming device, visual programming equipment and a storage medium, and the development efficiency is higher.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," or "having," and any variations thereof, are intended to cover non-exclusive inclusions, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For understanding, a specific flow of an embodiment of the present invention is described below, and referring to fig. 1, an embodiment of a visual programming method according to an embodiment of the present invention includes:
101. acquiring a plurality of basic functions in a preset Java atomic function library and description information of each basic function, and constructing a plurality of initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
it can be understood that Java is one of the mainstream development languages in the market currently, and a large number of native functions are encapsulated in a data packet (atomic function library) for a developer to call, so that corresponding product logic is realized by calling different types of native functions and combinations thereof. Specifically, the Java atomic function library f includes a relationship judgment function set, a character class operation function set, a date and time class operation function set, a basic type array set class operation function set, a numerical calculation class operation function set, an object list traversal operation function set, a mapping table operation function set, a basic attribute and a type conversion operation function set, and corresponds to classes respectively: logic, f.text, f.time, f.list, f.math, f.loop, f.map. Logic contains about 20 basic functions such as equal to or greater than, f.text contains about 80 basic functions such as start, end, intercept, etc., f.math contains about 40 basic functions such as four arithmetic operations, f.loop contains about 50 basic functions such as traversal, etc., and f.map contains about 8 basic functions such as get, put. Furthermore, the server constructs a corresponding primitive object by taking each basic function as a unit, wherein the primitive object is the encapsulation of the function, only the name of the primitive object is provided outwards, and no function details are provided.
102. Performing primitive conversion on each initial Java primitive object according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each initial Java primitive object;
it can be understood that the Java primitive object is based on a specific Java language development logic, which is not friendly to service personnel without language base, and in order to improve the collaborative development efficiency, the server converts the Java primitive object into a Block primitive object based on a preset conversion algorithm. The Block is a graphical programming language, simple programming can be realized by selecting and combining Block primitive objects, and each Block primitive object is a code Block. It is worth mentioning that the officials of blocky only provide for converting blocky to JavaScript, Dart, Python or XML languages, Java is not within its support scope, and other languages (non-blocky) to reverse conversion to blocky are not supported.
103. Constructing a visual programming main page according to the description information of each basic function and the initial Block primitive object;
it can be understood that a plurality of selectable and combinable Block primitive objects are provided for a user in the visual programming main page, each Block primitive object corresponds to one Java base function, description information of the function is added to the attribute node of the corresponding primitive object, and the description information can be seen when the user accesses the primitive object. Optionally, in order to improve programming efficiency and user experience, the visual programming main page is divided into three module areas, namely a classification area, a building block area and a script area. The classification area is used for classifying the Block primitive objects according to modules, each classification uses different colors and has different functions, such as Loops classification storage circulation building blocks, Math classification storage mathematic operation building blocks and the like; the building blocks are used for storing the classified building blocks (namely Block primitive objects), different building blocks represent different functions, and in Block, the building blocks can write codes by using a programming language including Java, so that the building blocks are flexibly defined. The script district is used for compiling the region of code, drags the building blocks in the building blocks district to the script district, thereby building blocks carry out the block and form building blocks group, and building blocks group can become executable code segment, and the execution code segment obtains the operation result. And then, the business personnel select the corresponding classification area and the building blocks under the classification area from the visual programming page according to business requirements and drag the classification area and the building blocks into the script area, so that a set of complete model calculation logic is constructed, and credit scores and the like are calculated according to data such as loan amount, repayment amount, overdue repayment times and the like.
104. Receiving operation information of a user on a visual programming main page, and generating an initial primitive object sequence for representing service requirements according to the operation information, wherein the initial primitive object sequence comprises at least one target Block primitive object selected by the user;
it can be understood that business personnel select corresponding Block primitive objects in the visual programming main page according to specific business requirements, and arrange and combine the Block primitive objects according to a certain sequence, so as to generate an initial primitive object sequence for representing an application program to be constructed. The mode that the user selects the Block primitive object in the visual programming main page may be touch, mouse dragging, sliding, and the like, which is not limited in this embodiment.
105. And searching a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence.
It can be understood that each Block primitive object has a corresponding relationship with a Java primitive object, and the corresponding relationship is stored in the primitive information, so that the server can find the corresponding Java primitive object according to the primitive information in the Block primitive object. The initial primitive object sequence is formed by arranging a plurality of Block primitive objects according to a certain sequence, the target primitive object sequence is formed by arranging a plurality of Java primitive objects according to a certain sequence, each Java primitive object represents a section of Java code segment, and the Java code segments are spliced according to the sequence of object sequencing in the target primitive object sequence so as to construct an application program.
Optionally, the server first detects a target Java primitive object in a local storage space according to identification information of the target Block primitive object, where the target Java primitive object corresponds to the target Block primitive object; secondly, if the target Java primitive object is not detected in the local storage space, searching the target Java primitive object in a remote server according to the primitive information in the target Block primitive object; and secondly, lazily loading a target Java primitive object by the server, replacing a target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program file according to the target primitive object sequence.
It is understood that the local storage space is a storage medium of the terminal, for example, in the case of data security, the local storage space is a Read-Only Memory (ROM) in the terminal, so as to implement non-destructive reading and searching of data. And if the local storage space does not store the Java primitive object corresponding to the target Block primitive object, searching the corresponding target Java primitive object from the remote server by using the primitive resource position information in the target Block primitive object, and performing lazy loading on the target Java primitive object. The lazy loading (Load On Demond) is a data acquisition method for improving the response speed of the system, and loads corresponding data as a user scrolls a page, namely, only data required by content displayed On the current page is loaded, so that the resource consumption of a server is effectively reduced.
In the embodiment, the Java primitive object is constructed by the Java function and converted into the Block primitive object, so that the user only needs to operate in the visual programming homepage to generate the corresponding Java code logic, and the development efficiency is improved.
Referring to fig. 2, a second embodiment of the visual programming method according to the embodiment of the present invention includes:
201. acquiring a plurality of basic functions in a preset Java atomic function library and description information of each basic function, and constructing a plurality of initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
step 201 is similar to the step 101, and is not described herein again.
202. Performing syntax analysis on each initial Java primitive object based on a JavaParser tool library to obtain an initial abstract syntax tree of each initial Java primitive object;
it is understood that JavaParser is a Java source code parsing tool library that can parse Java code fragments into corresponding abstract syntax trees, thereby facilitating further analysis and modification of the code. Further, the abstract syntax tree may be divided into a conditional syntax branch for representing a conditional control logic section in the code segment and a result syntax branch for representing a result behavior corresponding to the conditional control logic section in the code segment, such as "if a >1& & (b >0| | c <2), { d ═ 10 }; ". Where "if a >1& & (b >0| | c < 2)" is a conditional syntax branch and "d ═ 10" is a result syntax branch, the corresponding syntax tree please refer to fig. 8.
203. Based on a preset formatting algorithm, tiling a nested structure in the abstract syntax tree into an associated array structure to obtain a target abstract syntax tree;
further, the server traverses the abstract syntax tree obtained by analysis, so as to determine a nested structure therein, and converts the nested structure into a tiled structure through a preset formatting algorithm, and specifically, the tiled structure is an associated array. Suppose a Java code fragment is "if (a >0& & b >0) { c ═ 1; d is 2; -else if (a >0) { c ═ 2; else { c ═ 3; -tiled by the formatting algorithm to [ [ a >0& & b >0, [ c ═ 1, d ═ 2] ], [ a >0, [ c ═ 2] ], [ c ═ 3] ]; the nested conditional syntax tree structure is formatted as a semi-tiled structure, with identical relational statements merged together, such as { V0 ═ 0& & (V1>5| | V2<6) | | V5>0| | | V3 |! 2 is formatted as { [ OR, [ AND, V0 ═ 0, [ [ OR, V1>5, V2<6] ] ], V5>0, V3! 2.
204. Converting the atomic expression in the target abstract syntax tree into extensible markup language based on a preset conversion rule to obtain an initial Block primitive object corresponding to each initial Java primitive object;
it will be appreciated that the server differentiates the processing of atomic expressions according to their type, converting them into corresponding Xml (extensible markup language) node fragments. Specifically, the server divides the atomic expression into a relational operation expression, a method call expression, and a field expression. For the relational operation expression, after obtaining a left value, an operator and a right value, the server replaces the left value, the operator and the right value with corresponding parameter node values in a preset relational operation Xml template; for the method call expression, the server obtains the method name and the method parameters of the method call expression, converts the method parameters into the parameters in the Xml format, further matches corresponding templates from a plurality of preset method Xml templates according to the method names, and replaces corresponding default parameters in the templates with the method parameters converted into the Xml format; for the field expression, the value of the field expression is directly filled into a corresponding Xml template, for example, the attribute expression, and the server directly replaces the default attribute value in the variable Xml template with the attribute value. And (4) a character string expression, wherein the server directly fills the character string into a default value in the character Xml template.
205. Constructing a visual programming main page according to the description information of each basic function and the initial Block primitive object;
206. receiving operation information of a user on a visual programming main page, and generating an initial primitive object sequence for representing service requirements according to the operation information, wherein the initial primitive object sequence comprises at least one target Block primitive object selected by the user;
207. and searching a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence.
Wherein, the steps 205-207 are similar to the steps of the steps 103-105, and detailed description thereof is omitted here.
In this embodiment, a process of converting a Java primitive object into a Block primitive object is described in detail, and a nested structure and an atomic expression of the Java primitive object are converted by parsing a syntax tree, so that conversion between Java and Block is realized.
Referring to fig. 3, a third embodiment of the visual programming method according to the embodiment of the present invention includes:
301. acquiring a plurality of basic functions in a preset Java atomic function library and description information of each basic function, and constructing a plurality of initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
302. performing primitive conversion on each initial Java primitive object according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each initial Java primitive object;
wherein, the steps 301-302 are similar to the steps 101-102 described above, and detailed description thereof is omitted here.
303. Constructing a primitive description tree according to the description information of each basic function and the initial Block primitive object;
it can be understood that the primitive description tree refers to tree description information formed according to the category feature information of the primitive, and branches of the tree have a superior-inferior relationship. For example, the square primitives are all lower primitives that depend from the branches of the square primitives described by the class tree.
304. Performing page rendering based on a preset home page template file to obtain a static programming home page, wherein the static programming home page comprises a plurality of page modules;
it can be understood that the preset homepage template file is an Html page file, the file comprises a cascading style (CSS) and a Script (Script), the server first traverses the document nodes in the homepage template file, and generates a document object node tree model corresponding to the homepage template file according to the document nodes; secondly, analyzing the cascading style sheet marks in the homepage template file, and generating a cascading style sheet rule tree model corresponding to the homepage template file based on an analysis result; constructing a rendering tree model corresponding to the homepage template file according to the document object model node tree model and the cascading style sheet rule tree model; then based on the rendering tree model corresponding to the homepage template file, elements in the homepage template file are distributed to nodes corresponding to the rendering tree model; and finally, drawing each node in the rendering tree model in sequence to obtain a static programming main page.
305. Receiving a data request of each page module, acquiring tree node information corresponding to a primitive description tree according to the data request, and carrying out local overloading on the page modules to obtain a visual programming main page;
it can be understood that the server first performs page rendering on a preset homepage template file to generate a static page, then executes an initial script file to generate a data request of each module in the static page, and acquires corresponding tree node information in the primitive description tree according to the data request to perform local reloading. In a specific implementation, the primitive description tree can be regarded as a data storage structure, and the generated data request can realize local data interaction based on asynchronous Ajax without refreshing all resources of the whole page, so that the generation efficiency of the visual programming main page is improved.
306. Receiving operation information of a user on a visual programming main page, and generating an initial primitive object sequence for representing service requirements according to the operation information, wherein the initial primitive object sequence comprises at least one target Block primitive object selected by the user;
307. and searching a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence.
Wherein, the steps 306-307 are similar to the steps of 104-105, and detailed description thereof is omitted here.
In this embodiment, a process of constructing a visual page is described in detail, a plurality of node information is generated by constructing a primitive description tree, and a data request is performed when rendering of an initial page is completed, so that corresponding node information is obtained, and a dynamically interactive visual programming homepage is loaded.
Referring to fig. 4, a fourth embodiment of the visual programming method according to the embodiment of the present invention includes:
401. acquiring a plurality of basic functions in a preset Java atomic function library and description information of each basic function, and constructing a plurality of initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
402. performing primitive conversion on each initial Java primitive object according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each initial Java primitive object;
403. constructing a visual programming main page according to the description information of each basic function and the initial Block primitive object;
wherein, the steps 401-403 are similar to the steps 101-103 described above, and detailed description thereof is omitted here.
404. Receiving operation information of a user on a visual programming main page, wherein the operation information comprises identification information of a dragged object and arrangement information of the dragged object;
it can be understood that, in the embodiment, the user generates an initial primitive object sequence corresponding to the business requirement by dragging the graphic block in the visualization programming main page. The graphic blocks dragged by the user have unique identification information, such as a graphic Block serial number, and the identification information of the graphic blocks has a corresponding mapping relation with the Block primitive object.
405. Determining at least one target Block primitive object according to the identification information of the dragged object, and arranging the target Block primitive objects according to the arrangement information of the dragged object to obtain an initial primitive object sequence;
it can be understood that, when a graphics Block dragged from a selected area by a user is detected in a script area, a server firstly obtains identification information of the graphics Block, secondly searches for a corresponding Block primitive object according to a mapping relation, and then sequentially sorts the corresponding Block primitive objects according to an arrangement sequence of the graphics Block in the script area, thereby forming an initial primitive object sequence.
406. And searching a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence.
Step 406 is similar to the step performed in step 105, and is not described herein again.
In this embodiment, a process of constructing an initial primitive object sequence is described in detail, and a Block primitive object Block is dragged by a user in a visual page and arranged according to a certain sequence, so that the initial primitive object sequence is generated.
With reference to fig. 5, the visual programming method in the embodiment of the present invention is described above, and a visual programming apparatus in the embodiment of the present invention is described below, where an embodiment of the visual programming apparatus in the embodiment of the present invention includes:
a primitive constructing single module 501, configured to obtain multiple basic functions and description information of each basic function in a preset Java atomic function library, and construct multiple initial Java primitive objects based on the basic functions, where each initial Java primitive object corresponds to one basic function;
a primitive conversion module 502, configured to perform primitive conversion on each initial Java primitive object according to a preset conversion algorithm, to obtain an initial Block primitive object corresponding to each initial Java primitive object;
a homepage building module 503, configured to build a visual programming homepage according to the description information of each basic function and the initial Block primitive object;
a sequence generating module 504, configured to receive operation information of a user on the main page of the visual programming, and generate an initial primitive object sequence used for representing a service requirement according to the operation information, where the initial primitive object sequence includes at least one target Block primitive object selected by the user;
and a program generating module 505, configured to search a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replace the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generate a target program according to the target primitive object sequence.
In the embodiment, the Java primitive object is constructed by the Java function and converted into the Block primitive object, so that the user only needs to operate in the visual programming homepage to generate the corresponding Java code logic, and the development efficiency is improved.
Referring to fig. 6, another embodiment of the visual programming apparatus according to the embodiment of the present invention includes:
a primitive constructing single module 501, configured to obtain multiple basic functions and description information of each basic function in a preset Java atomic function library, and construct multiple initial Java primitive objects based on the basic functions, where each initial Java primitive object corresponds to one basic function;
a primitive conversion module 502, configured to perform primitive conversion on each initial Java primitive object according to a preset conversion algorithm, to obtain an initial Block primitive object corresponding to each initial Java primitive object;
a homepage building module 503, configured to build a visual programming homepage according to the description information of each basic function and the initial Block primitive object;
a sequence generating module 504, configured to receive operation information of a user on the main page of the visual programming, and generate an initial primitive object sequence used for representing a service requirement according to the operation information, where the initial primitive object sequence includes at least one target Block primitive object selected by the user;
and a program generating module 505, configured to search a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replace the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generate a target program according to the target primitive object sequence.
The primitive conversion module 502 specifically includes:
a syntax parsing unit 5021, configured to perform syntax parsing on each initial Java primitive object based on a JavaParser tool library to obtain an initial abstract syntax tree of each initial Java primitive object;
a formatting unit 5022, configured to tile a nested structure in the abstract syntax tree into an associated array structure based on a preset formatting algorithm, so as to obtain a target abstract syntax tree;
and the expression conversion unit 5023 is used for converting the atomic expressions in the target abstract syntax tree into extensible markup language based on a preset conversion rule to obtain an initial Block primitive object corresponding to each initial Java primitive object.
The homepage building module 503 specifically includes:
a description tree construction unit 5031, configured to construct a primitive description tree according to the description information of each base function and the initial Block primitive object;
a homepage template rendering unit 5032, configured to perform page rendering based on a preset homepage template file to obtain a static programming homepage, where the static programming homepage includes multiple page modules;
a data loading unit 5033, configured to receive a data request of each page module, obtain, according to the data request, tree node information corresponding to the primitive description tree, and perform local reloading on the page module to obtain a visual programming main page.
The homepage template rendering unit 5032 is specifically configured to:
traversing document nodes in the homepage template file, and generating a document object node tree model corresponding to the homepage template file according to the document nodes;
analyzing the cascading style sheet mark in the homepage template file, and generating a cascading style sheet rule tree model corresponding to the homepage template file based on the analysis result;
constructing a rendering tree model corresponding to the homepage template file according to the document object model node tree model and the cascading style sheet rule tree model;
based on the rendering tree model corresponding to the homepage template file, laying out the elements in the homepage template file on the nodes corresponding to the rendering tree model;
and drawing each node in the rendering tree model in sequence to obtain a static programming main page.
The sequence generating module 504 specifically includes:
a receiving unit 5041, configured to receive operation information of a user on the main page of the visual programming, where the operation information includes identification information of a dragged object and arrangement information of the dragged object;
a determining unit 5042, configured to determine at least one target Block primitive object according to the identification information of the dragged object;
and the arranging unit 5043 is configured to arrange the target Block primitive objects according to the arrangement information of the dragged object, so as to obtain an initial primitive object sequence.
The program generating module 505 specifically includes:
a local search unit 5051, configured to detect a target Java primitive object in a local storage space according to identification information of the target Block primitive object, where the target Java primitive object corresponds to the target Block primitive object;
a remote search unit 5052, configured to search the target Java primitive object in a remote server according to the primitive information in the target Block primitive object if the target Java primitive object is not detected in a local storage space;
and a primitive replacing unit 5053, configured to lazily load the target Java primitive object, replace the target Block primitive object in the initial primitive object sequence with the target Java primitive object, obtain a target primitive object sequence, and generate a target program according to the target primitive object sequence.
In the embodiment of the invention, the modularized design ensures that hardware of each part of the visual programming device is concentrated on realizing a certain function, the performance of the hardware is realized to the maximum extent, and meanwhile, the modularized design also reduces the coupling among the modules of the device, thereby being more convenient to maintain.
Fig. 5 and fig. 6 describe the visualization programming apparatus in the embodiment of the present invention in detail from the perspective of the modular functional entity, and the visualization programming apparatus in the embodiment of the present invention is described in detail from the perspective of the hardware processing.
Fig. 7 is a schematic structural diagram of a visual programming device 700 according to an embodiment of the present invention, which may have a relatively large difference due to different configurations or performances, and may include one or more processors (CPUs) 710 (e.g., one or more processors) and a memory 720, one or more storage media 730 (e.g., one or more mass storage devices) for storing applications 733 or data 732. Memory 720 and storage medium 730 may be, among other things, transient storage or persistent storage. The program stored on the storage medium 730 may include one or more modules (not shown), each of which may include a sequence of instructions operating on the visualization programming device 700. Still further, the processor 710 may be configured to communicate with the storage medium 730 to execute a series of instruction operations in the storage medium 730 on the visualization programming device 700.
The visualization programming apparatus 700 may also include one or more power supplies 740, one or more wired or wireless network interfaces 750, one or more input-output interfaces 760, and/or one or more operating systems 731, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, and so forth. Those skilled in the art will appreciate that the configuration of the visualization programming device illustrated in FIG. 7 does not constitute a limitation of the visualization programming device, and may include more or fewer components than illustrated, or some components in combination, or a different arrangement of components.
The present invention also provides a visualization programming device, which includes a memory and a processor, wherein the memory stores computer readable instructions, and the computer readable instructions, when executed by the processor, cause the processor to execute the steps of the visualization programming method in the above embodiments.
The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium, and which may also be a volatile computer-readable storage medium, having stored therein instructions, which, when executed on a computer, cause the computer to perform the steps of the visualization programming method.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A visual programming method, comprising:
acquiring a plurality of basic functions in a preset Java atomic function library and description information of each basic function, and constructing a plurality of initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
performing primitive conversion on each initial Java primitive object according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each initial Java primitive object;
constructing a visual programming main page according to the description information of each basic function and the initial Block primitive object;
receiving operation information of a user on the visual programming main page, and generating an initial primitive object sequence for representing service requirements according to the operation information, wherein the initial primitive object sequence comprises at least one target Block primitive object selected by the user;
and searching a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence.
2. The visual programming method according to claim 1, wherein the performing primitive conversion on each initial Java primitive object according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each initial Java primitive object comprises:
performing syntax analysis on each initial Java primitive object based on a JavaParser tool library to obtain an initial abstract syntax tree of each initial Java primitive object;
based on a preset formatting algorithm, tiling a nested structure in the abstract syntax tree into an associated array structure to obtain a target abstract syntax tree;
and converting the atomic expression in the target abstract syntax tree into an extensible markup language based on a preset conversion rule to obtain an initial Block primitive object corresponding to each initial Java primitive object.
3. A visual programming method according to claim 1, wherein the constructing a visual programming main page according to the description information of each said basic function and said initial Block primitive object comprises:
constructing a primitive description tree according to the description information of each basic function and the initial Block primitive object;
performing page rendering based on a preset home page template file to obtain a static programming home page, wherein the static programming home page comprises a plurality of page modules;
and receiving a data request of each page module, acquiring tree node information corresponding to the primitive description tree according to the data request, and carrying out local reloading on the page modules to obtain a visual programming main page.
4. A visualization programming method according to claim 3, wherein after the building a primitive description tree according to the description information of each of the base functions and the initial Block primitive object, further comprising:
and storing the primitive description tree into a server, and updating the primitive description tree in the server when detecting that an initial Block primitive object is newly added.
5. A visualization programming method according to claim 3, wherein the page rendering based on the preset home page template file to obtain the static programming home page comprises:
traversing document nodes in the homepage template file, and generating a document object node tree model corresponding to the homepage template file according to the document nodes;
analyzing the cascading style sheet mark in the homepage template file, and generating a cascading style sheet rule tree model corresponding to the homepage template file based on the analysis result;
constructing a rendering tree model corresponding to the homepage template file according to the document object model node tree model and the cascading style sheet rule tree model;
based on the rendering tree model corresponding to the homepage template file, laying out the elements in the homepage template file on the nodes corresponding to the rendering tree model;
and drawing each node in the rendering tree model in sequence to obtain a static programming main page.
6. The visual programming method according to claim 1, wherein the receiving operation information of a user on the visual programming main page and generating an initial primitive object sequence for representing business requirements according to the operation information comprises:
receiving operation information of a user on the visual programming main page, wherein the operation information comprises identification information of a dragged object and arrangement information of the dragged object;
determining at least one target Block primitive object according to the identification information of the dragged object;
and arranging the target Block primitive objects according to the arrangement information of the dragged objects to obtain an initial primitive object sequence.
7. The visual programming method according to any one of claims 1 to 6, wherein the searching for the target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replacing the target Java primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating the target program according to the target primitive object sequence comprises:
detecting a target Java primitive object in a local storage space according to the identification information of the target Block primitive object, wherein the target Java primitive object corresponds to the target Block primitive object;
if the target Java primitive object is not detected in the local storage space, searching the target Java primitive object in a remote server according to the primitive information in the target Block primitive object;
lazily loading the target Java primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence.
8. A visual programming apparatus, comprising:
the primitive constructing single module is used for acquiring a plurality of basic functions in a preset Java atomic function library and description information of each basic function, and constructing a plurality of initial Java primitive objects based on the basic functions, wherein each initial Java primitive object corresponds to one basic function;
the primitive conversion module is used for performing primitive conversion on each initial Java primitive object according to a preset conversion algorithm to obtain an initial Block primitive object corresponding to each initial Java primitive object;
the homepage construction module is used for constructing a visual programming homepage according to the description information of each basic function and the initial Block primitive object;
the sequence generation module is used for receiving operation information of a user on the visual programming main page and generating an initial primitive object sequence for representing service requirements according to the operation information, wherein the initial primitive object sequence comprises at least one target Block primitive object selected by the user;
and the program generation module is used for searching a target Java primitive object corresponding to the target Block primitive object according to the primitive information in the target Block primitive object, replacing the target Block primitive object in the initial primitive object sequence with the target Java primitive object to obtain a target primitive object sequence, and generating a target program according to the target primitive object sequence.
9. A visualization programming device, the visualization programming device comprising: a memory and at least one processor, the memory having instructions stored therein;
the at least one processor invokes the instructions in the memory to cause the visualization programming device to perform the visualization programming method of any of claims 1-7.
10. A computer-readable storage medium having instructions stored thereon, wherein the instructions, when executed by a processor, implement the visualization programming method of any of claims 1-7.
CN202111229751.7A 2021-10-22 2021-10-22 Visual programming method, device, equipment and storage medium Pending CN113961183A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111229751.7A CN113961183A (en) 2021-10-22 2021-10-22 Visual programming method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111229751.7A CN113961183A (en) 2021-10-22 2021-10-22 Visual programming method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113961183A true CN113961183A (en) 2022-01-21

Family

ID=79466046

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111229751.7A Pending CN113961183A (en) 2021-10-22 2021-10-22 Visual programming method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113961183A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114461204A (en) * 2022-04-12 2022-05-10 南京飓风引擎信息技术有限公司 Development system and method for translating multi-level object data into native code
CN117270838A (en) * 2023-11-22 2023-12-22 太平金融科技服务(上海)有限公司 Method, device, equipment and medium for generating universal formula script

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114461204A (en) * 2022-04-12 2022-05-10 南京飓风引擎信息技术有限公司 Development system and method for translating multi-level object data into native code
CN114461204B (en) * 2022-04-12 2022-06-17 南京飓风引擎信息技术有限公司 Development system and method for translating multi-level object data into native code
CN117270838A (en) * 2023-11-22 2023-12-22 太平金融科技服务(上海)有限公司 Method, device, equipment and medium for generating universal formula script
CN117270838B (en) * 2023-11-22 2024-02-13 太平金融科技服务(上海)有限公司 Method, device, equipment and medium for generating universal formula script

Similar Documents

Publication Publication Date Title
RU2666238C2 (en) Compilation of transformations in recalculation user interface
Schulte et al. A multi-language computing environment for literate programming and reproducible research
CN111241454B (en) Method, system and device for generating webpage codes
Eaton Toytree: A minimalist tree visualization and manipulation library for Python
US9087296B2 (en) Navigable semantic network that processes a specification to and uses a set of declaritive statements to produce a semantic network model
US20100070852A1 (en) Method for Transforming the Source Documents to Corresponding Web Pages
US20140306964A1 (en) Incremental compiling of a declarative program
CN104662514A (en) Modernization of legacy software systems based on modeled dependencies
CN113961183A (en) Visual programming method, device, equipment and storage medium
CN112199086A (en) Automatic programming control system, method, device, electronic device and storage medium
EP2984585B1 (en) Binding of data source to compound control
CN105517681A (en) Chart conversion system using metadata and method therefor
CN104798067A (en) Web server system, dictionary system, dictionary call method, screen control display method, and demonstration application generation method
Grammel et al. A survey of mashup development environments
KR101552914B1 (en) Web server application framework web application processing method using the framework and computer readable medium processing the method
Antonov et al. An AlgoView web-visualization system for the AlgoWiki project
Okamoto et al. SUNPRISM: An approach and software tools for collaborative climate change research
Namee et al. A form and API data management platform for progressive web application and serverless application architecture
Cheon et al. VizMe: An annotation-based program visualization system generating a compact visualization
Zosimov et al. Development of domain-specific language for data processing on the internet
US20230153079A1 (en) Visual representations of source code portions in integrated development environments
Nasiri et al. Generation of User Interfaces and Code from User Stories
CN113608726B (en) Code generation method, device, electronic equipment and storage medium
Ma et al. Ontology-based computerized representation of specifications for construction cost estimation
Sung et al. Working with HTML5 and WebGL

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination