Skip to content

Костромин - 3 tasks#27

Open
crabik-dk wants to merge 4 commits intodemologin:mainfrom
crabik-dk:main
Open

Костромин - 3 tasks#27
crabik-dk wants to merge 4 commits intodemologin:mainfrom
crabik-dk:main

Conversation

@crabik-dk
Copy link

No description provided.

Copy link

@Khmelov Khmelov left a comment

Choose a reason for hiding this comment

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

Приложение написано аккуратно и с небольшими замечаниями, поставил оценку б


public class ConsoleRunner {
public static void main(String[] args) {
new ConsoleApplication().run();
Copy link

Choose a reason for hiding this comment

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

Обычно при сборке приложения через конструктор передают все необходимые зависимости

public abstract class BaseCipher {

protected String processText(String text, int shift) {
StringBuilder result = new StringBuilder();
Copy link

Choose a reason for hiding this comment

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

При таком способе кодирования объем шифруемого файла ограничен размерами памяти, если бы это было на уровне потоков ввода и вывода то такого ограничения не было бы

import java.util.List;

public class BruteForceMethod {
private static final List<String> COMMON_WORDS = Arrays.asList(
Copy link

Choose a reason for hiding this comment

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

Довольно неплохой способ но жёстко привязан к русскому языку. Анализ на уровне статистики опорного текста был бы в целом лучше, но наверное он для четвёртого способа будет наиболее полезен

@@ -0,0 +1,7 @@
package com.javarush.kostromin.constant;

public class Alphabet {
Copy link

Choose a reason for hiding this comment

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

Можно сделать интерфейсом, а если оставлять класс то тут полезен будет приватный конструктор

import java.io.File;

public class Constants {
public static final String TXT_FOLDER = System.getProperty("user.dir") +
Copy link

Choose a reason for hiding this comment

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

То же самое

bruteForceFile(args[0], args[1]);
break;
default:
System.out.println("Unknown command: " + command);
Copy link

Choose a reason for hiding this comment

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

Ввод и вывод лучше всего выполнять на уровне взаимодействия с пользователем а не логических конструкциях приложения, это позволяет легко менять тип приложения

EncryptMethodCaesar encryptor = new EncryptMethodCaesar();
String encryptedContent = encryptor.encrypt(contentText, key);
Files.write(Paths.get(destFile), encryptedContent.getBytes());
System.out.println("File encrypted successfully with key: " + key);
Copy link

Choose a reason for hiding this comment

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

Тоже самое, тут лучше не выводить явно на консоль а вернуть в виде какого-то результата

import static com.javarush.kostromin.constant.Constants.TXT_FOLDER;

public class ConsoleApplication {
private final MainController controller = new MainController();
Copy link

Choose a reason for hiding this comment

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

Контроллер и сканер лучше создать и передать через конструктор



private void executeEncryptCommand(Scanner scanner) {
System.out.println("Enter input file [Push 'Enter' for default: text/text.txt]:");
Copy link

Choose a reason for hiding this comment

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

Да именно на этом уровне ввод вывод наиболее уместен

}
}

private void printMenu() {
Copy link

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