Skip to content

Kochenkov - 3 tasks#25

Open
KochenkovSA wants to merge 5 commits intodemologin:mainfrom
KochenkovSA:main
Open

Kochenkov - 3 tasks#25
KochenkovSA wants to merge 5 commits intodemologin:mainfrom
KochenkovSA:main

Conversation

@KochenkovSA
Copy link

No description provided.

- main menu call created;
- symbol map created;
- interface with constants created.
- created an encryption method;
- created a method (HashMap (key/value)) for working with the alphabet;
- adjusted the work in the main menu.
- created decryption method;
- updated constants
- created bruteforce;
- created constants;
- created keywords;
- created CipherProcessor
Copy link
Owner

@demologin demologin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Очень даже неплохо. Есть замечания, их много но они мелкие и легкопоправимые. Оценка B

import com.javarush.kochenkov.consts.Constants;
import com.javarush.kochenkov.consts.Keywords;

import java.io.*;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Fix: см. соглашение о коде (пример Google https://google.github.io/styleguide/javaguide.html )



public BruteForceProcessor(SymbolMapper symbolMapper) {
this.symbolMapper = symbolMapper;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

странно что маппер инжектится (это верно) а остальное хардкодится (особенно scanner странно, клавиатура же одна, значит и сканер должен быть один)

}

public void execute() {
System.out.println(Constants.BF);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот класс команда. О не должен заниматься выводом

try {
int shift = findShift(inputFile);
if (shift == -1) {
System.out.println(Constants.UNABLE_TO_DETERMINE_SHIFT);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Design: System.out - жесткие зависимости с консолью. Используйте специализированные бины (например, Printer)

public int findShift(String filePath) {
String sample = readStartOfFile(filePath, Constants.MAX_CHARS);
if (sample.isEmpty()) {
return -1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Fix: Extract constant - и имя нужно ей понятное.
-1 - это неясно что.

protected final Encrypt cipher;

public CipherProcessor(SymbolMapper symbolMapper) {
this.scanner = new Scanner(System.in);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Опять новый сканнер. На каждый CipherProcessor. Это неверно. Он один должен быть на весь жизненный цикл приложения

import java.util.Arrays;
import java.util.List;

public interface Keywords {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ок

import java.util.Scanner;

public class MainMenu {
Scanner scanner = new Scanner(System.in);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И снова

}

private void encrypt() {
CipherProcessor processor = new CipherProcessor(new SymbolMapper());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

processor - это компонент приложения. Он только раз должен быть рожден


public class Runner {
public static void main(String[] args) {
MainMenu ep = new MainMenu();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут нужно было создать все части программы и собрать из них приложение

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