Skip to content

Changes from clean code first part#6

Open
adamtnagy wants to merge 40 commits into
jfree:masterfrom
adamtnagy:changes-from-clean-code-first-part
Open

Changes from clean code first part#6
adamtnagy wants to merge 40 commits into
jfree:masterfrom
adamtnagy:changes-from-clean-code-first-part

Conversation

@adamtnagy
Copy link
Copy Markdown

Dear David,

I was studying the book Clean Code and it has a section where the class SerialDate in Jcommon library is refactored. It is horrible to follow a refactoring process in a book format and I could not find those changes online so I decided to do them myself. I think it is worthwile to have these changes in this repository.

It took quite some time to make the commits as small and obvious as possible, but I am finished with SerialDateTest completely and fixed some issues in the SerialDate class. It should be straightforward from the commit messages where I diverged from the book and followed conventions of the existing code or my taste.

I saw that this Jcommon library is to be retired that is why I selected this as a playground.

I would say that I am one third finished with the whole I have in mind. I plan to finish the refactoring of the SerialDate class following the book as close as possible. (Then Make It Right section, page 270.) Then maybe I have my own ideas both to the class and its tests. I have doubts though that those are relevant in the sense to be able to follow the book's ideas. Hmmm.


Anyway, here is a pull request with the changes so far.

If you find these useful I would be happy to help migrating these to the development branch of JFreeChart - Future State Edition.


I am not sure how the copyrights work in your country and in this particular case, but if you are willing to merge this, then I would suggest to contact the author/publisher for a permit. It would collide with the boyscouting rule not to allow these changes in so it must go smooth. ;-) I also added Robert C. Martin as a contributor to the class and I mention the book in the commit messages too. He is also quite active on Github, probably easy to find. (In case of course if you don't already know each other.)


Finally I would like to mention that I made these changes for educational purposes so it is possible to follow the book. I am sure few people bother to look the source up online, and most of those did turned away when they started to compare it with a book format.

Although It has a nostalgic feeling to keep 4-6 fingers simultaneously between the pages in the book and turn pages like crazy sometimes pressing unwanted keys on the keyboard with the book, but... well it is not efficient in the 21st century anymore. :-)

I hope I can help/inspire other developers in their studies with these changes.

Best regards,
Ádám T. Nagy

In later commits move methods to the SerialDateTest class one by one. This will make it easier to track the progress.
- I am going to use curly brackets for one liners because the codebase is written in this manner and I won't leave this road.
- Also there were some line ending issues which I could not resolve
- Update with curly brackets
…nd testCreateInstanceFromJavaDate

- All tests are added to SerialDateTest from BobsSerialDateTest so it is removed
- Test adding two months which increments year by one as well
- I am not sure what the mentioned bug was so I kept the test
- It seems redundant though, maybe remove later
- This is the only place where the isOn() method is used
…source format and paying attention to some details
…ing tests, then refactor stringToWeekdayCode so it becomes case insensitive - Find an error in the book ;-)
…ook leaves these tests commented out too. That indicates pretty much the same.
- Uncomment failing tests, then update stringToMonthCode so it becomes case insensitive and correctly returns -1
- Source format: add whitespaces after commas
… 3 then it is a special case, if it is less than -3 it is another special case
@adamtnagy
Copy link
Copy Markdown
Author

Bump.

@frle10
Copy link
Copy Markdown

frle10 commented Sep 23, 2023

I think this is great! Why has this not been checked out by anyone? :D

@adamtnagy
Copy link
Copy Markdown
Author

6 years... Time flies, I still remember the Saturday mornings dealing with this, haha.

Maybe I wasn't pushy enough. Probably the owner did not see the mail from this pull request or he has better things to do.

Or he simply hates that book and the author. ;-)

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.

2 participants