-
Notifications
You must be signed in to change notification settings - Fork 229
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
Мажирин Александр #205
base: master
Are you sure you want to change the base?
Мажирин Александр #205
Conversation
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.
В целом, молодец, довольно аккуратно получилось)
Еще пожелание. Когда выкладываешь PR, думай о том, как его будут ревьюить. В данном случае, у тебя изменения по текущей задаче и код прошлой задачи лежат в одном коммите. Нет никакой возможности посмотреть diff именно по текущей задаче - это неудобно.
|
||
internal class Program | ||
{ | ||
private static ParserResult<CliOptions>? _parseResult; |
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.
Через параметры передавать было бы аккуратнее
TagsCloudContainerCLI/Demo.cs
Outdated
.UseImageEncoder<PngEncoder>()) | ||
.Then(r => r.FromString(GenerateRandomString(count))) | ||
.Then(imageBytes => File.WriteAllBytes($"results/random_cloud_{count}.png", imageBytes)) | ||
.OnFail(error => Console.WriteLine($"Failed to generate cloud with {count} words: {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.
У тебя же логгер есть
TagsCloudContainerCLI/Demo.cs
Outdated
) | ||
.UseImageEncoder<PngEncoder>()) | ||
.Then(r => r.FromString(GenerateRandomString(count))) | ||
.Then(imageBytes => File.WriteAllBytes($"results/random_cloud_{count}.png", imageBytes)) |
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.
При записи могут исключения возникнуть
{ | ||
var layouter = _layouterFactory.Create(); | ||
return _textProcessor.ProcessText(data) | ||
.Then(layouter.Value.LayoutTags) |
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.
надо проверить что layouter создался успешно)
} while (_rectangles.Any(r => r.IntersectsWith(rectangle.Value))); | ||
|
||
return rectangle; | ||
}) |
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.
жирновастая функция. Лучше заименовать, вынести
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.
А вообще можно было написать как-то так. Если не стремиться фанатично сделать все на Result
private Result<Tag> PutNextTag(KeyValuePair<string, double> word, float adjustedFontSize)
{
var measureResult = _fontManager.MeasureString(word.Key, adjustedFontSize);
if (measureResult.IsSuccess == false)
{
return Result.Fail<Tag>(measureResult.Error);
}
var rectangleSize = measureResult.Value;
if (rectangleSize.Width <= 0 || rectangleSize.Height <= 0)
{
return Result.Fail<Tag>("Invalid rectangle size");
}
var rectangle = PutRectangle(rectangleSize);
_rectangles.Add(rectangle);
return new Tag
{
Text = word.Key,
FontSize = adjustedFontSize,
BBox = rectangle
};
}
No description provided.