In principle, according to the definitions given earlier in this
document, a generatable file can be any file that does not contain binary,
non human-readable data. Thus, the current implementation of
SoProTech could be theoretically used to generate any
single-byte file (typically, in ASCII or ISO8859) within a software
project, provided that a Software Mold be available for that purpose.
In practice, "casting" a Software Mold for a candidate generatable file
(for example, a "Home.java" or a ".cs" file) is
reasonable when the requirements
for reproducibility and relative redundancy of the candidate
are significant, which means:
- More than one Software Entity requires the generation of the candidate;
- A significant degree of similarities is expected between the files resulting by applying the same mold to two different entities.
The first point above is obvious: making a Software Mold to produce
one single file is a good exercise, but not really useful
in a real project. This is also true for industrial precision
molding of physical objects, generally applied in
high volume production processes.
As for the second point, the
similarities between the files should be considered
structural, rather than literal similarities.
For example, the source files for the Java[tm] classes of two
Software Entities may list all imports necessary for each class,
then the class definition, with all get and set
methods, and so on.
In a similar way, the HTML forms for two Software Entities
should have a common layout, such as a link to the home
page, a series of buttons, and so forth.
A detailed explanation of this concept is given in the next chapter.
The next paragraph contains eight examples of files generated with
the SoProMach by applying four Software Molds on two Software Entities.
Large software systems may involve several hundreds of
multifacet entities, each with a variable number of source files
related to them, so that the overall number of source files
may range in the thousands, or tens of thousands.
The SoProTech enables software development
teams to apply an appropriate number of Software Molds to the
project Software Entities, and thus generate such quantities of
files literally within minutes.
Moreover, it is possible to rapidly
regenerate the files (or a subset thereof) whenever required, for
instance in case of architectural changes in the software system, or
according to the technological evolution.
As an example, in a lab test on
a Linux® PC equipped with one 1.7 GHz Intel® x86 CPU and 256 MB RAM,
the SoProMach produced from scratch
about 1.2 million lines of source code (SQL, Java[tm], C++ and HTML - 6,000 files
in total) in less than 23 minutes,
averaging more than 50,000 generated lines of code
per minute.
Besides, it should be noted that the SoProMach provides
a trigger mechanism to ensure that only the files
strictly required by the project team get actually generated.
This mechanism allows the project team to keep the
combinatorial explosion of generated files under control.
The following eight generated files result from processing
the example entities listed before, namely "project.ef" and
"department.ef", through the four Software Molds
described in the previous chapter:
- "DB/mold1-.sql";
- "LOGIC/mold1-.java";
- "UI/mold3-.html";
- "DOC/mold1-.html".
The SQL script files of this paragraph derive from the
collections of entity fields contained in section DB
of the correspondent Software Entity file. The relevant collections
are labelled by project convention table and pkey.
Code Example 3 - From "project.ef" to "DB/project.sql"
|
Collection table from entity "business/project.ef" is
expanded by the SoProMach[tm] into the list of table columns of lines 6-14.
This is the first of the two steps of Software Mold "DB/mold1-.sql".
The second one translates
collection pkey to the primary key of line 15.
The heading and trailing parts of the file are respectively
derived from scripts "DB/mold1-.sql/file.hdr" (lines 1-5)
and "DB/mold1-.sql/file.trl" (lines 16-18).
|
|
Source code - File "business/DB/project.sql"
|
1 --
2 -- This SQL script created by somusar/SoProMach[tm]
3 --
4
5 create table project (
6 projid varchar(10),
7 projname varchar(40),
8 descr varchar(200),
9 companyname varchar(80),
10 budget decimal(10,2),
11 teammembersemplid int,
12 manageremplid int,
13 deptid varchar(10),
14 internal char(1),
15 constraint pk_project primary key (projid)
16 )
17 ;
18
|
|
Code Example 4 - From "department.ef" to "DB/department.sql"
|
Collections table and pkey of entity "department.ef"
are translated by the SoProMach[tm] into lines
6-9 and 10 respectively. Columns manageremplid and
membersemplid contain relationship keys to an employee
table: their counterparts in entity file "department.ef"
are respectively a link and a list of employees.
By project convention the identifiers of the SQL
table columns contain no underscore "_": the SoProTech[tm]
allows to implement such project-wide conventions in one mold,
so that these conventions can
be very easily and quickly changed, if needed, and re-applied
consistently to all projects and entities for which that
particular mold applies.
|
|
Source code - File "company/DB/department.sql"
|
1 --
2 -- This SQL script created by somusar/SoProMach[tm]
3 --
4
5 create table department (
6 deptid varchar(10),
7 deptname varchar(40),
8 manageremplid int,
9 membersemplid int,
10 constraint pk_department primary key (deptid)
11 )
12 ;
13
|
|
The generated Java[tm] source code files described in this paragraph
have been produced by SoProMach from collection class
in section LOGIC of the corresponding Software Entities. In the sample project
described in
"Somusar/Software Production Technique[tm]: A Sample Project
", the same collection class drives the generation
of C++ source files containing the C++ equivalent of the Java[tm] classes
listed below. The generation of C++ source code in the sample
project is achieved by means of another mold, namely
"LOGIC/mold3-.h".
Code Example 5 - From "project.ef" to "LOGIC/Project.java"
|
Some notes about the correspondence between the contents
of the Software Entity file business/project.ef and the contents
of the generated Java file:
- The comment at the beginning of project.ef has been carried over and properly formatted (lines 10-12);
- Sisendel enumeration proj_status has been mapped to a Java int and a set of values (lines 22-25 and 121-128);
- Relationships to other Software Entities have been mapped to members corresponding to the primary keys (pkey) of each related-to Software Entity: for example, the link to department in project.ef is implemented by member departmentDeptId (line 34), as department.ef defines dept_id as its pkey.
|
|
Source code - File "business/LOGIC/Project.java"
|
1 /*
2 * This Java class generated by somusar/SoProMach[tm].
3 */
4
5 package com.somusar.entdemo.business;
6
7 /**
8 * Class Project:
9 *
10 * A project within a company, some information about it,
11 * a project manager, the involved personnel, a project
12 * plan and budget.
13 */
14
15 import com.somusar.entdemo.business.Customer;
16 import com.somusar.entdemo.company.Employee;
17 import java.util.Collection;
18 import com.somusar.entdemo.company.Department;
19
20 public class Project {
21
22 // Map enum 'Proj. status' onto an int with a set of values
23 public final int OK = 0; // OK
24 public final int LATE = 1; // Late
25 public final int DANGER = 2; // Danger
26
27 private String projId;
28 private String projName;
29 private String descr;
30 private String customerCompanyName; // relationship to Customer
31 private double budget; // range 0-1000
32 private Collection teamMembers;
33 private int managerEmplId; // relationship to Employee
34 private String departmentDeptId; // relationship to Department
35 private boolean internal;
36
37 /*
38 * Get methods
39 */
40
41 public String getProjId() {
42 return projId;
43 }
44
45 public String getProjName() {
46 return projName;
47 }
48
49 public String getDescr() {
50 return descr;
51 }
52
53 public String getCustomerCompanyName() {
54 return customerCompanyName;
55 }
56
57 public double getBudget() {
58 return budget;
59 }
60
61 public Collection getTeamMembers() {
62 return teamMembers;
63 }
64
65 public int getManagerEmplId() {
66 return managerEmplId;
67 }
68
69 public String getDepartmentDeptId() {
70 return departmentDeptId;
71 }
72
73 public boolean getInternal() {
74 return internal;
75 }
76
77 /*
78 * Set methods
79 */
80
81 public void setProjId( String projId ) {
82 this.projId = projId;
83 }
84
85 public void setProjName( String projName ) {
86 this.projName = projName;
87 }
88
89 public void setDescr( String descr ) {
90 this.descr = descr;
91 }
92
93 public void setCustomerCompanyName( String customerCompanyName ) {
94 this.customerCompanyName = customerCompanyName;
95 }
96
97 public void setBudget( double budget ) {
98 this.budget = budget;
99 }
100
101 public void setTeamMembers( Collection teamMembers ) {
102 this.teamMembers = teamMembers;
103 }
104
105 public void setManagerEmplId( int managerEmplId ) {
106 this.managerEmplId = managerEmplId;
107 }
108
109 public void setDepartmentDeptId( String departmentDeptId ) {
110 this.departmentDeptId = departmentDeptId;
111 }
112
113 public void setInternal( boolean internal ) {
114 this.internal = internal;
115 }
116
117 /**
118 * Method 'Current proj. status'
119 */
120
121 // Return type corresponds to enum 'Proj. status'
122 public int curStatus (
123 Object plan,
124 double budget
125 )
126 {
127 // insert your Java method code here
128 }
129
130 }
|
|
Code Example 6 - From "department.ef" to "LOGIC/Department.java"
|
This second Java file demonstrates, when compared with Project.java,
the consistency achievable using Software Molds.
In particular, it should be noted that:
- The relationship between the department and its manager is implemented by the int member managerEmplId (line 20);
- The relationship between the department and the corresponding list of projects is implemented as a Java Collection (line 21): this project convention of mapping relationships of type 1-to-many to Java Collections is a good example of a software development best practice that can be recorded in a Software Mold and automatically reused by one or more development teams within one or more projects.
|
|
Source code - File "company/LOGIC/Department.java"
|
1 /*
2 * This Java class generated by somusar/SoProMach[tm].
3 */
4
5 package com.somusar.entdemo.company;
6
7 /**
8 * Class Department:
9 *
10 * A department within a company.
11 */
12
13 import com.somusar.entdemo.company.Employee;
14 import java.util.Collection;
15
16 public class Department {
17
18 private String deptName;
19 private String deptId;
20 private int managerEmplId; // relationship to Employee
21 private Collection members;
22
23 /*
24 * Get methods
25 */
26
27 public String getDeptName() {
28 return deptName;
29 }
30
31 public String getDeptId() {
32 return deptId;
33 }
34
35 public int getManagerEmplId() {
36 return managerEmplId;
37 }
38
39 public Collection getMembers() {
40 return members;
41 }
42
43 /*
44 * Set methods
45 */
46
47 public void setDeptName( String deptName ) {
48 this.deptName = deptName;
49 }
50
51 public void setDeptId( String deptId ) {
52 this.deptId = deptId;
53 }
54
55 public void setManagerEmplId( int managerEmplId ) {
56 this.managerEmplId = managerEmplId;
57 }
58
59 public void setMembers( Collection members ) {
60 this.members = members;
61 }
62
63 /**
64 * Method 'Current projects'
65 */
66
67 public Collection currProjects (
68 String deptId
69 )
70 {
71 // insert your Java method code here
72 }
73
74 }
|
|
The illustrations in this paragraph show
how collection full_view of section
UI is translated by the SoProMach
into a corresponding HTML form: the row-column
layout of the entity data fields in the form exactly matches
the row-column layout of the corresponding full_view.
The other parts of the form (such as the company logo,
navigation bar, and so on) are entity-independent, therefore
their design can be centralized in the HTML mold, rather than
being replicated for each entity. In this way a much higher
degree of maintainability is achieved: for example, applying a
generalized layout
change - like adding a new vertical bar - to
all forms in one or more projects only requires two simple steps:
- Apply that particular change only once in the appropriate mold;
- Re-impress (that is, regenerate) all HTML forms using the SoProMach.
This approach significantly increases productivity:
after applying the aforementioned change to the HTML mold
of the sample project, the re-impressing of
all HTML forms of the sample project,
which consists of ten Software Entities, required just one command
running for about five seconds on an Intel® x86-based
PC running either Linux® or Windows®,
thanks to the high speed of the SoProMach. A comparable
performance can also be achieved on Apple® computers running Mac OS® X.
Moreover, consistency
of the resulting software also becomes much higher, as the change
applied only once by hand in the mold is automatically replicated
across the generated files
rather than by copy-and-paste or by point-and-click.
Figure 11 - From "project.ef" to "UI/project.html"
Figure 12 - From "department.ef" to "UI/department.html"
The figures in this paragraph show the results of mold
"DOC/mold1-.html": two compact documents, each describing the
main features of an entity and containing useful information
about it, such as a cross-reference table
that summarizes the use of the entity fields in the different
entity collections.
Figure 13 - From "project.ef" to "DOC/project.html"
Figure 14 - From "department.ef" to "DOC/department.html"
[Previous chapter]
[Next chapter]
[Back to top]
|