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

Use more Java features (OOP / enum), split Rotor class, rename 'ringSettings' #8

Closed
wants to merge 1 commit into from
Closed

Conversation

NinoDLC
Copy link

@NinoDLC NinoDLC commented May 29, 2022

Firstly, I'd like to thank you for your videos and I was delighted to see you abord the infamous Enigma topic. Great topic!

I've tried to improve your code by using some OOP features of Java, as well as enums, while remaining "readable" for a non-Java user and keeping your code style intact.

  • Enums are great to represent different static configurations, so I "extracted" them when I could: RotorType and Reflector for example.
  • RotorState represents the state of the (3) rotors the Enigma is using: the type (created from I to VIII), the ringOffset (created from 0 to 25), and the mutable field rotorPosition (mutating from 0 to 25 during the object lifecycle).
  • I mutualized code in the Plugboard class to compute both the wiring and unpluggedCharacters field at once
  • I improved a bit the printing of the execution time because I was bored while the program was running 😁
  • I renamed variables where I could see fit (coherence with the rest of the code, more detailed, etc)
  • I removed unused imports on files I modified and removed a few dead code
  • I fixed Sorting twice? #5
  • I used private/public and final keywords as much as I could to be explicit about variable visibility and mutability (it personnaly helps me a lot when reading a new code)

@NinoDLC NinoDLC closed this by deleting the head repository Jan 29, 2023
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.

Sorting twice?
1 participant