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

Refactoring and enhancements for codebase excellence #97

Merged
merged 37 commits into from
Feb 2, 2024

Conversation

mitsuki31
Copy link
Owner

@mitsuki31 mitsuki31 commented Feb 1, 2024

Overview

This pull request incorporates a comprehensive set of refactoring, optimization, and enhancement initiatives designed to elevate the codebase in terms of clarity, maintainability, testing resilience, documentation, and overall performance.

Changes Made

  • Structural Refactoring for Enhanced Logic and Efficiency:

    • A comprehensive reorganization of internal packages and classes has been meticulously undertaken to establish a more intuitive and logical structure, fostering code comprehension and navigation.
    • New internal classes, specifically tailored for setup properties parsing and command-line argument handling, have been strategically introduced to promote better modularity and a clear separation of concerns.
    • Code refactoring has been diligently applied to optimize efficiency, eliminate redundancy, and streamline functionality, ensuring a more streamlined and performant codebase.
    • Error handling mechanisms have been fortified to gracefully address potential issues and provide a more robust user experience.
    • The setup properties initialization process has been carefully refined to deliver greater reliability and consistency.
  • Comprehensive Testing and Cross-Platform Compatibility:

    • The test workflow has been meticulously reactivated and expanded to encompass multiple platforms, including Ubuntu, Windows, and macOS, ensuring broader compatibility and seamless functionality across diverse environments.
    • Previously identified issues with CI tests have been diligently resolved to maintain a seamless and reliable testing process, fostering confidence in code quality.
  • Robust Documentation for Clarity and Guidance:

    • Javadocs have been thoughtfully added to previously undocumented classes and members, providing clear explanations and guidance for developers, fostering understanding and knowledge sharing.
    • Informative help messages and output have been enhanced to offer more user-friendly and contextual guidance, empowering both developers and end users.
  • Streamlined Development with Upgraded Builder:

    • The project builder has been strategically upgraded to JMBuilder, leveraging the efficiency and versatility of Python to facilitate a smoother development experience and accelerate development cycles.
  • Performance Optimization for Enhanced Responsiveness:

    • An imports checker has been thoughtfully integrated into the Makefile, optimizing performance by only importing necessary modules when required, reducing unnecessary overhead and resource consumption.
  • Improved Argument Parsing for Flexibility and Ease of Use:

    • The command-line argument parsing process has been meticulously refactored to offer enhanced flexibility, clarity, and ease of use, ensuring a more intuitive and user-friendly interface.

Additional Refinements for Code Integrity and Maintainability

  • Absolute paths have been strategically replaced with relative paths in Makefiles imports, promoting more efficient imports and reducing potential module conflicts, ensuring smooth code execution and collaboration.

  • Warnings due to unspecified encoding have been proactively addressed to ensure code consistency and maintainability, adhering to best practices and preventing future issues.

  • Setup properties have been consolidated into a single, centralized file (setup.properties) for better organization and clarity, fostering easier configuration and management.

Changelogs

Each commit within this pull request addresses a specific aspect of the aforementioned changes. Please refer to the accompanying changelog for detailed commit descriptions.

Changelogs: cb7e47f...2a2f7ad

Summary

This pull request signifies a significant step forward in codebase quality and maintainability. The implemented enhancements ensure a more logical structure, robust testing, improved performance, clear documentation, and a streamlined development experience.

* Deleted all properties files
* Initial new property file called `setup.properties`
* Now all setup properties will be in `setup.properties` file
  and no longer used the XML file
* Deleted the `OSUtils.java` (this class are no longer used)
* Moved all internal classes to directory (package) called `internal`
* Renamed the `Options` class to `JMatrixUtils`, improving clarity
* Changed the main class to `MainClass.java`
* Introduced a new final class called `ArgumentsParser` in main class
* Added several new methods to `ArgumentsParser` class, including:
  - `contains`
  - `get`
  - `getArguments`
  - `iterator` (from `Iterable` interface)
This class provides methods to parse the properties file with ease.
Please note, do not use constructor to create an instance of this class,
use the `load(String)` (static) method instead and use the `getProperties`
method (after created the instance class) to get the instance of
Properties (including all properties data) from this instance.

For example:
    PropertiesParser propsParser = PropertiesParser.load("config.properties");
    Properties configProps = propsParser.getProperties();
This class provides access to get the database from the setup properties file.
This class is designed to be synchronized and thread-safe. Its access modifier is "package"
and will only be visible to the package it is stored in.

The setup properties are retrieved from the file statically using the `static` block,
which means that when the program starts it will immediately retrieve the
properties from the file. So this class only provides access to the property data.

Example usage:
    Properties setupProps = SetupProperties.getSetupProperties();
* Added javadocs for all classes in `PropertiesParser.java`
* Added and updated some javadoc in `MainClass.java`
* Removed test code in `main` method
Decativated due to maintaining the internal code.
This CI will also be improved to support with future changes.
The errors is occurred due to missing some variables, error imports, and etc.
Removed several checks from checking the setup properties file
This will only occurs error because the `File` class checks the file
from the current directory. Replaced by checking the `InputStream`
whether it is null, null is indicates that InputStream cannot found
the specified file inside JAR's directory tree.
The setup properties parser has improved in several factors, one of which is checking the existence of the file.
* Added new method called `getFirstArgument` that gets the first known argument.
  The known arguments in this changes (the arguments are not different with the previous ones):
    "-V", "--version", "ver", "version" : Display the JMatrix version
    "-cr", "--copyright", "copyright"   : Display the copyright and license

* Added several necessary private members
* Added documentations for undocumented members
* Bump version for classes that has been modified
  For `ArgumentsParser` class, it has been modified but forgot to bump the version. See 3415b74
Deleted `build.resources` (default) and replaced to use the Maven
Resources Plugin for reliability and ensure the properties encoding
are specified with `propertiesEncoding` configuration. Additionally,
all necessary files also would be copied during validation using
of goal `copy-resources`.
We resolved this by adding a new file to separate SetupProperties
class from the public one, its name the same as its contained class.
Now it uses the SetupProperties class to get the program name instead.
In addition, we also added the Javadoc for undocumented variables.
* Added a new variable to holds several help arguments
* Included the `helpArgs` to all known arguments in
  `getFirstArgument` method
* Introduced a new private function to print the help message
* If no arguments specified, print the help message then return
* Implemented the help arguments checker
* Added a capability to print the version only by specifying
  "--version-only" as first argument
* Removed old Python files and replaced with the new builder
* Now the builder will not inside 'src/main/python', instead
  it moved to 'tools' directory, which more concise directory name.
* Removed the 'requirements.txt' in the root directory, replaced
  with the JMBuilder's one (within its root directory)

Repo: https://github.com/mitsuki31/JMBuilder.git

Pages: https://mitsuki31.github.io/JMBuilder
Several changes and overrides configuration has been made which from
.pylintrc of JMBuilder package
This module includes functions to calculate MD5 hashes, verify hashes,
set up and retrieve information from a parsed POM file, and handle
the main execution of the script to retrieve and print values
based on user input.

Syntax:

    $ python scripts/retriever.py <KEY>

Example:

    $ python scripts/retriever.py project.name
    JMatrix
* The properties setup now utilizes the 'scripts/retriever.py' Python
  script to retrieve necessary project information
* Replaced the `$(shell pwd)` code to get the current directory with
  CURDIR variable instead
* Initialization of required files, e.g. MANIFEST.MF, has been
  added and its utilizes the JMBuilder to initiate and fix that files
* Further improvements and refactors also has been made to make
  the Makefiles compatible with the new builder and works as expected
Added imports checker when importing the Setup.mk, this way the
module will be imported only when the user only when the user
specifies targets, excluding 'help', or when specified nothing.
This approach optimizes performance.

In addition with this commit, refactored the 'help' rule, added
'Makefile' to .PHONY target, and also added license information
on the header message.
Introduced two method to convert ISO formatted date to local date:

  * dateISOToLocal(String, String)
  * dateISOToLocal(String)
* Updated the copyright year
* Added the built time on version information
* Updated and improved several info message for clarity
* Refactored all custom flags to use ";" instead of "@:" to define
  empty rule
* Now the 'clean' target will use all cleaners, this to make the
  output directory of generated HTML docs is also completely deleted
  during cleaning the project
mitsuki31 and others added 6 commits January 10, 2024 20:26
Replaced the "com.mitsuki.jmatrix.util" with "com.mitsuki.jmatrix.internal".
And also changed the assignment operator for all internal options.
We also updated the excluded packages to "com.mitsuki.jmatrix.internal".
* Now both tests (Maven and Make) will runs on 3 platforms, they are
  Ubuntu, Windows, and MacOS.
* Refactored and improved jobs setup
* Updated several dependencies to the latest major version
* Several changes and improvements
The implemented code inside Makefiles are intended to run only in
UNIX systems, as we got some errors on Windows system. For across
platform, you can take the Maven to build the project.
@mitsuki31 mitsuki31 self-assigned this Feb 1, 2024
@mitsuki31 mitsuki31 marked this pull request as draft February 1, 2024 14:05
@mitsuki31 mitsuki31 added documentation Improvements or additions to documentation enhancement Enhancing existing features lang:java Some changes on Java code lang:python Some changes on Python code minor Minor update feature Add new features to improve the project labels Feb 1, 2024
@github-actions github-actions bot added the chore Maintenance updates (e.g Github Actions) label Feb 1, 2024
@mitsuki31 mitsuki31 marked this pull request as ready for review February 1, 2024 15:31
@mitsuki31 mitsuki31 merged commit c9a2d52 into master Feb 2, 2024
24 checks passed
@mitsuki31 mitsuki31 deleted the refactor/refactor-internal-code branch February 2, 2024 02:44
@mitsuki31 mitsuki31 removed chore Maintenance updates (e.g Github Actions) documentation Improvements or additions to documentation labels Feb 2, 2024
@mitsuki31 mitsuki31 added this to the v1.5.0 milestone May 31, 2024
@mitsuki31
Copy link
Owner Author

The JMBuilder submodule has been migrated from "tools/" to "vendor/" directory in #137 (Sep 15, 2024). This change was also made the JMBuilder as git submodule for better project maintain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancing existing features feature Add new features to improve the project lang:java Some changes on Java code lang:python Some changes on Python code minor Minor update
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant