Back to Java

In august 2018 I decided to develop Enigma in Free Pascal. The main reason was that Oracle terminated the support for JavaFX. A company called Gluon would support it as an open source project, but I did not believe that JavaFX would last. Swing and SWT were no alternatives for me and using a web-interface in a native application had severe drawbacks.
I made some comparisons and Free Pascal was the clear winner. It was object oriented, open source and had an exceptional good way of handling the user interface. I knew the language from previous experiences, though that was some 15 years ago.
So I happily started coding. At first everything went well but as the application grew I experienced some stumble-blocks. The editor, with the beautiful name Lazarus, was good but it paled in comparison to intelliJ, the Java editor I was used to. Unit testing was possible but it missed some essential techniques, like mocking and calculating the test-coverage. And the way the source was handled, in units, files with mancy classes, was cumbersome. OK, I could have created small units but then I would have had problems defining the imports. I expect to be using at least 1000 classes after some further development, so this became a problem.
I found myself coding less and less because it was not so much fun anymore.
At the end of december 2019 the first version of Enigma was almost ready. It could calculate and draw a chart, work with configurations and used a database to store the essential information.
But I strongly felt the need for an alternative.
So I made a new comparison. Then I found that JavaFX was not dead. This was a big surprise for me. I expected it to slowly die after Oracle pulled the plug, but the open source community decided differently. JavaFX is alive and kicking and the support by Gluon works very well. Several new releases have been published while I was working with Free Pascal.
So I decided to return to Java. I was delighted with the efficiency of intelliJ and started coding. About 11 weeks later I almost completely rebuilt the codebase as writtin in Free Pascal. I am sure that future development will be fast as I’m using the perfect tools ànd coding is again fun for me.
I expect to have a first (beta) version, which will be 2020.1, available in May this year.
A new sourceset will then be posted at GitHub.

Some progress…

I knew that Free Pascal (FP) differed from the Java environment I used to work in before my recent retirement. But it still took me some efforts to adapt. The main problem I had was using automated testing. FP has excellent tools for unit testing, like FPC which I use. However, unit testing requires the testing of only one component and not any related components. To do so in a Java world, you would use mocks or fakes. FP has no viable solution for mocks, so I used fakes. That did not work out. Fakes require the use of interfaces (object interfaces, not just the unit interfaces). And good solutions use Dependency Injection (DI), which is not available in FP but you can mimic it using the Factory pattern. I ended up with too many components, interfaces and fakes, to be maintainable. So I skipped Fakes, I skipped object interfaces (at least as a default approach), I skipped factories, and I ended up with nice clean objects. In Java you would call it a POJO: Plain Old Java Object, in Pascal that would probably be a POPO 🙂  )
That means I cannot always use unit testing in the strict sense. And obviously, I need to test as much as possible to get early feedback on any error I make and to prevent bugs. I used Integration tests for all back-end functionality. I use FPC to implement these tests, so technically they start as a unit test but the functionality is different. The integration tests work with a greenfield for the database which is populated before a range of tests start. This approach appears to be useful.
Finishing release 0.6 will still take a few months but I hope to have it available, including documentation, user manual and all tests at the start of 2020.

Version 0.5 published (only source)

Version 0.5 of Enigma contains the handling of glyphs and a graphical chart drawing. I just uploaded the source to GitLab, you can check it at https://gitlab.com/jkampherbeek/enigma.git

This version is only for programmers. Starting with version 0.6 Enigma will be available as a compiled package for the interested public at large.

Please check the documentation for some specific requirements for your development environment.

Source for version 0.4 (database access) available

The new Engima release 0.4 is about databases. It creates a new SQLite database and populates it. This is currently only supported from unit tests, but several preparations have been made to access the data in the application itself.  You can download it from https://gitlab.com/jkampherbeek/enigma.git .

Additionally, several tests are now based on Fakes. The number of tests is now about 200.

An updated version of the technical documentation is also available.

 

Source code available

Release 0.3 of Enigma is available as source from GitLab. You can download it from https://gitlab.com/jkampherbeek/enigma.git . The current version handles the calculation of the most important celestial objects and of Placidus houses. Much more to do, but it is a start.

I did not implement the tests based on fakes as I described in my previous post. It added too much boilerplate code. But I do need a decent test coverage. Possibly I will use integration tests for the more complex objects. In the current version, you already find 70 unit tests for the more basic tests. A first version of the technical documentation is available for download

Automated testing

Release 0.2 is finished and I started working on release 0.3. I will push the resulting code to GitLab so it will be available to anyone interested.
Release 0.3 will focus on refactoring the current application. Part of the refactoring will be the use of interfaces. Not the interface-parts of the units but interfaces for the objects. These interfaces will help in making the objects more loosely-coupled but also be a great help in automatically testing the code.
Free Pascal supports unit testing but it does not support mocking objects. There is a mock-tool but it is pretty old and not supported anymore. As an alternative, I will use Fake objects; in short, ‘Fakes’. A Fake implements the same interface as the original object but gives hardcoded answers instead of the real thing. If you write a unit test for an object that uses the results from another object, which again will have its own dependencies, you might end up testing a whole range of objects instead of the single object. That is where Fakes come in. They replace the objects that are not tested in the current unit test and make it possible to test just one class per unit test.

After I finished the code of release 0.3 you will be able to check the code, including the Fakes, yourself.

Free Pascal vs Delphi

Shortly after I started working on Enigma using Free Pascal, a free version of Delphi came available. Embarcadero introduced a community edition of Delphi. You can use this edition if your yearly profit does not exceed $ 5000. For the Engima project that is an easy condition as there will be no profit whatsoever. The community edition is a welcome addition to the paid version that will cost you several thousands of dollars.
It is a nice opportunity but I decided to stick to Free Pascal. Why? I do not believe the official Delphi version has essential advantages compared to Free Pascal. The only advantage I can see is Firemonkey, visual components for Android, that are currently not available in Free Pascal. But as I will focus on a Windows version, for now, this is not an important advantage. Free Pascal, however, does have advantages compared to Delphi, mainly its support for Linux. And more importantly: you can rest assured that Free Pascal will be available for some time and will remain free. There is no guarantee that Embarcadero will continue the community edition forever. I still remember the end days of Borland, when a free version of Delphi was discontinued.
So I will place my bets on Fee Pascal and Lazarus.