As a software test automation veteran, I know what it is to code manually for hours, and making mistakes is imminent.
Manual coding leads to human errors, and is also very time-consuming. Developers want to design a solution and build it quickly, without too much time coding.
One way to achieve this is to use Software Development Automation, or SDA for short.
This blog post will explain how to get started with SDA by using the SDA tool MetaFactory.
What is SDA?
For this blog, I define Software Development Automation as creating source code automatically by using a code generator tool.
Some examples of these tools are Hibernate Tools, MyBatis Generator, SpringFuse, Celerio, MetaFactory, etc.
Now, I’ll illustrate SDA with MetaFactory.
MetaFactory—What is it?
MetaFactory is developed by MetaFactory B.V. , a Dutch software house specializing in SDA.
MetaFactory is a desktop solution, which runs on Windows, Linux or Mac.
A developer can run it on his own computer as a plugin to the IDE he uses.
How does MetaFactory work?
The developer needs to run a number of instructions with XML, and with the use of template engines such as FreeMarker and Apache Velocity. Based on these instructions, MetaFactory promptly creates the source code you want.
Automatic updates are also possible. The developer can simply adjust the input (XML pattern or template) according to your requirements, and MetaFactory will automatically apply your changes to all the relevant lines of code. This coding can be automated by using the recurring patterns in your code.
This does not lead to redundant code because MetaFactory will add metadata to the patterns, and by using this metadata, MetaFactory can steer which code has to be generated (or not).
When do I need it?
As already mentioned, MetaFactory makes use of metadata of recurring code/patterns.
What is an example of recurring code? Well, what about code that enables a web or desktop application to connect and work with a database? This needs a lot of patterns, and MetaFactory is most suitable to automate this pattern generation.
And, using MetaFactory while refactoring is no issue because of the automatic updates through the whole code.
Who is MetaFactory for?
MetaFactory patterns are currently available for Angular (1.x and 2.0) and Java.
Clients of MetaFactory are developing C# and Python patterns for future use.
Do you have a practical example?
We will build a simple “Hello World” application with MetaFactory.cid:4601EFE4-DC08-4118-B5C6-CBDD4A4395F8@hsd1.ca.comcast.net.
Let’s assume MetaFactory is installed on your computer.
Generate an XML file named MetaFactory.xml with the following contents:
<?xml version=”1.0” encoding=”UTF-8”?>
<path type=”java” />
<path type=”xml” />
Now generate an XML file in the same folder named pattern.xml with the following contents:
<?xml version=”1.0” encoding=”UTF-8”?>
<operation name=”main” static=”true”>
< parameter name=”args”><datatype>strings[ ]/datatype></parameter>
// just output Hello World
System.out.println(“Hello World”) ;
Although we will not use a model in this example, we still need a valid model.xml file.
So, in the same folder, generate a model.xml file with the following contents:
<?xml version= “1.0” encoding=”UTF-8”?>
<attribute name=”firstAttribute” type=”string” />
Go to MetaFactory and open the project file. Click Transform, and select Run.
If everything went well, you’ll see MetaFactory produced one Java package with one Java class.
In the folder containing your project file, a new subfolder named generated/java has been created. This folder contains the generated Java package and Java class.
By using your IDE (eg. IntelliJ, Eclipse or NetBeans), you can verify your results.
This is just one simple example. Metafactory also has an account on GitHub, where you can find more advanced examples.
Software development automation is crucial in today’s agile development. It speeds up development and lowers the chance of failures due to manual coding. MetaFactory is a great tool to use with SDA. MetaFactory works on Mac, Windows and Linux, and a developer can use it on his own computer as a plugin to the IDE he uses.
MetaFactory makes use of metadata of recurring code/patterns. This automates the coding and even works when refactoring due to automatic updates. MetaFactory currently operates on Java and Angular, but metadata clients are busy developing patterns for more languages.
MetaFactory is SDA by developers, for developers!