-
Notifications
You must be signed in to change notification settings - Fork 201
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
base: master
Are you sure you want to change the base?
Конина Анастасия #181
Conversation
TagCloud/CloudDrawer.cs
Outdated
return Result.Of(() => | ||
{ | ||
var bitmap = new Bitmap(pictureSize.Width, pictureSize.Height); | ||
var gr = Graphics.FromImage(bitmap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Graphic
- IDisposable
объект - надо освобождать после использования.
TagCloud/CloudDrawer.cs
Outdated
public Result<Bitmap> DrawCloud(Result<IEnumerable<WordForCloud>> wordsForCloud) | ||
{ | ||
if (!wordsForCloud.IsSuccess) | ||
return wordsForCloud.Then(x => new Bitmap(0, 0)); |
There was a problem hiding this comment.
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
. При использовании таких значений, лучше руководствоваться здравывм смыслом - скорее всего они не приведут к валидному результату.
if (tagCloudSettings.Value == null) | ||
return; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Судя по названию метода имелось в виду заменять текст ошибки, если он пустой?
TagCloud/WordsForCloudGenerator.cs
Outdated
.OrderBy(x => x.Value) | ||
.Reverse() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Есть метод OrderByDescending
.
TagCloud/WordsForCloudGenerator.cs
Outdated
colorGenerator.GetNextColor(), | ||
x.Key, | ||
x.Value, | ||
maxFrequency: frequency.FirstOrDefault().Value))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут, вместо вычисления (выборки) максимума каждый раз можно вычислить один раз, на еще одном промежуточном шаге Then
.
return !boringWords.IsSuccess | ||
? Result.Fail<List<string>>(boringWords.Error) | ||
: wordsResult |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Может тут можно просто boringWords.Then
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А фактически, метод NormalizeWords
не нуждается в Results на входе и выходе, тут в самом методе нечему падать.
TagCloud/CloudDrawer.cs
Outdated
this.pictureSize = pictureSize; | ||
} | ||
|
||
public Result<Bitmap> DrawCloud(Result<IEnumerable<WordForCloud>> wordsForCloud) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут можно ведь принять на вход просто IEnumerable<WordForCloud>
?
Зачем проверять IsSuccess
внутри метода, если можно "проверить" снаружи и просто не вызывать данный метод?
TagCloud/TagCloudCreator.cs
Outdated
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут можно чере .Then
связать.
No description provided.