Conversation
- created an encryption method; - created a method (HashMap (key/value)) for working with the alphabet; - adjusted the work in the main menu.
demologin
left a comment
There was a problem hiding this comment.
Очень даже неплохо. Есть замечания, их много но они мелкие и легкопоправимые. Оценка B
| import com.javarush.kochenkov.consts.Constants; | ||
| import com.javarush.kochenkov.consts.Keywords; | ||
|
|
||
| import java.io.*; |
There was a problem hiding this comment.
// Fix: см. соглашение о коде (пример Google https://google.github.io/styleguide/javaguide.html )
|
|
||
|
|
||
| public BruteForceProcessor(SymbolMapper symbolMapper) { | ||
| this.symbolMapper = symbolMapper; |
There was a problem hiding this comment.
странно что маппер инжектится (это верно) а остальное хардкодится (особенно scanner странно, клавиатура же одна, значит и сканер должен быть один)
| } | ||
|
|
||
| public void execute() { | ||
| System.out.println(Constants.BF); |
There was a problem hiding this comment.
Этот класс команда. О не должен заниматься выводом
| try { | ||
| int shift = findShift(inputFile); | ||
| if (shift == -1) { | ||
| System.out.println(Constants.UNABLE_TO_DETERMINE_SHIFT); |
There was a problem hiding this comment.
// Design: System.out - жесткие зависимости с консолью. Используйте специализированные бины (например, Printer)
| public int findShift(String filePath) { | ||
| String sample = readStartOfFile(filePath, Constants.MAX_CHARS); | ||
| if (sample.isEmpty()) { | ||
| return -1; |
There was a problem hiding this comment.
// Fix: Extract constant - и имя нужно ей понятное.
-1 - это неясно что.
| protected final Encrypt cipher; | ||
|
|
||
| public CipherProcessor(SymbolMapper symbolMapper) { | ||
| this.scanner = new Scanner(System.in); |
There was a problem hiding this comment.
Опять новый сканнер. На каждый CipherProcessor. Это неверно. Он один должен быть на весь жизненный цикл приложения
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
||
| public interface Keywords { |
| import java.util.Scanner; | ||
|
|
||
| public class MainMenu { | ||
| Scanner scanner = new Scanner(System.in); |
| } | ||
|
|
||
| private void encrypt() { | ||
| CipherProcessor processor = new CipherProcessor(new SymbolMapper()); |
There was a problem hiding this comment.
processor - это компонент приложения. Он только раз должен быть рожден
|
|
||
| public class Runner { | ||
| public static void main(String[] args) { | ||
| MainMenu ep = new MainMenu(); |
There was a problem hiding this comment.
Тут нужно было создать все части программы и собрать из них приложение
No description provided.