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

Конина Анастасия #181

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

anastasiakimura
Copy link

No description provided.

return Result.Of(() =>
{
var bitmap = new Bitmap(pictureSize.Width, pictureSize.Height);
var gr = Graphics.FromImage(bitmap);

Choose a reason for hiding this comment

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

Graphic - IDisposable объект - надо освобождать после использования.

public Result<Bitmap> DrawCloud(Result<IEnumerable<WordForCloud>> wordsForCloud)
{
if (!wordsForCloud.IsSuccess)
return wordsForCloud.Then(x => new Bitmap(0, 0));

Choose a reason for hiding this comment

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

new Bitmap(0, 0) упадет с Parameter not valid. При использовании таких значений, лучше руководствоваться здравывм смыслом - скорее всего они не приведут к валидному результату.

Comment on lines +25 to +26
if (tagCloudSettings.Value == null)
return;

Choose a reason for hiding this comment

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

Предполагается, что IsSuccess должно говорить о том, что настройки не null.

this Result<TInput> input,
string error)
{
return input.ReplaceError(err => input.IsSuccess ? error : input.Error);

Choose a reason for hiding this comment

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

Судя по названию метода имелось в виду заменять текст ошибки, если он пустой?

Comment on lines 25 to 26
.OrderBy(x => x.Value)
.Reverse()

Choose a reason for hiding this comment

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

Есть метод OrderByDescending.

colorGenerator.GetNextColor(),
x.Key,
x.Value,
maxFrequency: frequency.FirstOrDefault().Value)));

Choose a reason for hiding this comment

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

Тут, вместо вычисления (выборки) максимума каждый раз можно вычислить один раз, на еще одном промежуточном шаге Then.

Comment on lines +7 to +9
return !boringWords.IsSuccess
? Result.Fail<List<string>>(boringWords.Error)
: wordsResult

Choose a reason for hiding this comment

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

Может тут можно просто boringWords.Then?

Choose a reason for hiding this comment

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

А фактически, метод NormalizeWords не нуждается в Results на входе и выходе, тут в самом методе нечему падать.

this.pictureSize = pictureSize;
}

public Result<Bitmap> DrawCloud(Result<IEnumerable<WordForCloud>> wordsForCloud)

Choose a reason for hiding this comment

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

Тут можно ведь принять на вход просто IEnumerable<WordForCloud>?
Зачем проверять IsSuccess внутри метода, если можно "проверить" снаружи и просто не вызывать данный метод?

Comment on lines 31 to 36
var words = wordsReader.Get(inputFile);
var normalizedWords = wordsNormalizer.NormalizeWords(words,
wordsReader.Get(boringWordsFile)
.Then(boringWords => boringWords.ToHashSet()));
var wordsForCloud = wordsForCloudGenerator.Generate(normalizedWords);
return cloudDrawer.DrawCloud(wordsForCloud);

Choose a reason for hiding this comment

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

Тут можно чере .Then связать.

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