Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve SRP by decomposing Utils.java and CSVImporter.java#913

Open
Amirh-Ctrl wants to merge 1 commit intoknowm:develop from
Amirh-Ctrl:develop
Open

Improve SRP by decomposing Utils.java and CSVImporter.java #913
Amirh-Ctrl wants to merge 1 commit intoknowm:develop from
Amirh-Ctrl:develop

Conversation

@Amirh-Ctrl
Copy link

@Amirh-Ctrl Amirh-Ctrl commented Nov 12, 2025

Hi!

I performed this refactoring as part of a small university homework assignment (HW) focusing on software design principles. The goal was to improve the code's cohesion and maintainability.

The changes address clear violations of the Single Responsibility Principle (SRP) in two utility classes:

  1. Decomposed Utils.java
    The original Utils.java was acting as a general catch-all for math, file, and data conversion logic. I split it into specialized classes:

FileUtils.java (New):

Moved addFileExtension here.

ChartMathUtil.java (New):

Moved getTickStartOffset, pow, getGeneratedDataAsList, and getGeneratedDataAsArray here.

Utils.java (Cleaned):

This class is now focused primarily on data conversion (Array/List conversion).

  1. Refactored CSVImporter.java
    This class was mixing three different responsibilities (chart assembly, file I/O, and string parsing).

FileUtils.java (Used):

Moved both getAllFiles methods here, as they are pure file system utilities.

DataConverter.java (New):

Moved the getAxisData (String to Number parsing) method here.

CSVImporter.java (Cleaned):

This class is now more focused on its main job: CSV reading and chart assembly.

I updated all the method calls in the project to point to the new utility classes and ran the Main demo in the xchart-demo module. All charts continue to work correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /