Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major refactoring plus minor bugfixes #57

Open
wants to merge 55 commits into
base: master
Choose a base branch
from

Conversation

lemtom
Copy link
Contributor

@lemtom lemtom commented May 2, 2020

This is a massive refactoring, mostly as an exercise, trying to stick to the modern Java conventions and best practices (up to Java 8). I've followed Refactoring Guru and the automatic advice given by SonarLint.

It's by no means a complete and perfect refactoring, but I hope it's at least a good start.

I'm not sure if the Java part of the Ponomar project is still under development, given that it doesn't seem to have been touched for years. So it may have been a bit of a waste of time, but at least I still got some valuable experience out of it.

What I did

  • I've tried to logically group classes, reduce duplicate code, extract methods to add clarity. Taking advantage of updates to the Java platform, I've replaced the old data structures that are pretty much deprecated (Vector, Hashtable) and replaced them with the alternatives offered by the Java Collections framework (ArrayList, Hashmap). The OrderedHashtable class has been removed in favour of LinkedHashmap, another new data structure from the built-in Collections framework which offers the same intended functionality.

  • I've changed the folder structure to be closer to the folder structures I commonly see in Java projects. This has also allowed me to test to what degree resources are hardcoded and adjust accordingly.

  • I've added Javadoc documentation to some classes and methods.

  • I've left in most code that's commented out, as I did not always know if it was experimental code or old code.

  • I've added the correct attribution for the QDParser class and DocHandler interface.

  • I haven't touched the Perl API as I have zero experience with the language.

What has changed

Functionally, except for some minor bugfixes, everything is the same. It should hopefully be easier to develop for in the future.

Bugfixes

To fix some bugs I encountered, I added a toString() method to JDate. Along with some other minor changes, this leads to a smoother experience when saving text. I also removed some number signs from the Brenton translation, added the missing text for Malachi, and caught and handled the NullPointerExceptions and FileNotFoundExceptions you get when switching from a New Testament book in any other translation to the Brenton translation.

@typiconman typiconman requested a review from mamyt June 13, 2020 06:10
@mamyt
Copy link
Collaborator

mamyt commented Oct 26, 2020 via email

@lemtom
Copy link
Contributor Author

lemtom commented Oct 26, 2020

While I personally like to have a separation of source files and resulting binaries, I am able to generate the binaries within the source folder using

javac -cp src src/net/ponomar/Main.java

And then running with

java -cp src net.ponomar.Main

I have no Windows to test this with, but I assume this should also work in a Windows command prompt.

For the formatting issues in the Bible Reader, does this only apply to my refactored version? And do you remember a specific example I can quickly look at?

@mamyt
Copy link
Collaborator

mamyt commented Oct 27, 2020 via email

@lemtom
Copy link
Contributor Author

lemtom commented Oct 27, 2020

The attachments do not show up for me (does Github scrub attachments from e-mail replies?)

I am unable to reproduce the errors you describe.

The Arabic seems to render identically to on my end:
bible

I do not find any bold text in the English, French and Latin translations either.

I have compiled with a more recent Java version to check if that was the issue, but it wasn't. Very curious.

Have you compiled both versions anew, or was the original version compiled in the past? Google gives me some bug reports of Swing text rendering regressions in some Java versions on Windows, and even on Linux I note small differences in aliasing if I compile with other Java versions.

@mamyt
Copy link
Collaborator

mamyt commented Oct 27, 2020 via email

@typiconman
Copy link
Owner

@mamyt Your images don't show up. Can you try posting them through the GitHub web interface?

@typiconman
Copy link
Owner

FYI, the refactored version compiles and runs ok on Linux. I haven't tested extensively, but the Church Slavonic does not load for the Bible.

@mamyt
Copy link
Collaborator

mamyt commented Oct 30, 2020

Adding the missing images (and sorry about the delay).

Comparison of the Original and Refactored Version.pdf

@typiconman
Copy link
Owner

Adding the missing images (and sorry about the delay).

Comparison of the Original and Refactored Version.pdf

The Arabic text is LTR instead of RTL and the letters are not attaching. A font issue? What OS and version of Java are you using?

@mamyt
Copy link
Collaborator

mamyt commented Oct 30, 2020 via email

@lemtom
Copy link
Contributor Author

lemtom commented Dec 23, 2020

With the holidays, I've been able to access a Windows machine, and have partly reproduced the bug. I get the bold font, but not the wrong Arabic text direction.

On my Linux machine, this gets me the nonsensical "Dialog.bold" font. On the Windows machine, it gives "Times New Roman Vet" (vet being bold in my language). This is rendered in bold in the Java application, but not when I save the HTML file and open it in Firefox.

In the old version, both on Linux and Windows it's correctly set as Times New Roman. So this is indeed a regression, one that I didn't catch because I don't have Times New Roman in my Linux fonts folder, which made both the correct and the incorrect fonts fall back to the same default. Now that I have installed Times New Roman, the regression is clear on Linux as well (which should make further debugging easier).

I'll try to figure out why this is happening so I can fix this.

@lemtom
Copy link
Contributor Author

lemtom commented Dec 24, 2020

The bold typeface is fixed on my end. I hope that the font issue is also what caused the issues with Arabic, but I wasn't able to reproduce that.

@mamyt
Copy link
Collaborator

mamyt commented Dec 28, 2020 via email

@lemtom
Copy link
Contributor Author

lemtom commented Dec 28, 2020

How have you been running the makefile on Windows? Given that make is a GNU thing, I'm not sure why it doesn't support the cp command. There are apparently several ways to use it on Windows, I'm not sure why it doesn't run the copy command. If you can direct me to the tool you use, I can find out what syntax it supports.

What things do you need to do other than the following to make the software work?

javac -cp src src/net/ponomar/Main.java
java -cp src net.ponomar.Main

I can add these as options to the makefile as well, which your tool hopefully supports since it solely involves the java commands.

@mamyt
Copy link
Collaborator

mamyt commented Dec 30, 2020 via email

@lemtom
Copy link
Contributor Author

lemtom commented Dec 30, 2020

Alright, I've added these working commands as the default make install (or make) and make run commands. The ones with the separate directory are a secondary option now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants