This week I have continued refactoring the code in the application translate_german_words. After make smaller functions, I was able to see that there were a lot of parameters in the new functions, so I decided to create new classes. I moved some functionality from the principal script translate_words.rb to some new classes:
- read_words_from_file.rb
- search_words_in_dictionary.rb
- write_words_in_file.rb
I learned: 1 class <-> 1 responsability
Also, I created a config.yml file and with the class load_config.rb, load the configuration into the application.
Also, I removed not needed local variables in the methods, made the readme file more friendly and I got smaller methods.
I only can say that the process is so natural. I mean, you start using meaningful names, making smaller functions, creating classes..., step by step.
At the moment that's all!!
Keine Kommentare:
Kommentar veröffentlichen