Conversation
Buskervil
left a comment
There was a problem hiding this comment.
В целом, молодец, довольно аккуратно получилось)
Еще пожелание. Когда выкладываешь PR, думай о том, как его будут ревьюить. В данном случае, у тебя изменения по текущей задаче и код прошлой задачи лежат в одном коммите. Нет никакой возможности посмотреть diff именно по текущей задаче - это неудобно.
|
|
||
| internal class Program | ||
| { | ||
| private static ParserResult<CliOptions>? _parseResult; |
There was a problem hiding this comment.
Через параметры передавать было бы аккуратнее
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}")); |
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.
При записи могут исключения возникнуть
| { | ||
| var layouter = _layouterFactory.Create(); | ||
| return _textProcessor.ProcessText(data) | ||
| .Then(layouter.Value.LayoutTags) |
There was a problem hiding this comment.
надо проверить что layouter создался успешно)
| } while (_rectangles.Any(r => r.IntersectsWith(rectangle.Value))); | ||
|
|
||
| return rectangle; | ||
| }) |
There was a problem hiding this comment.
жирновастая функция. Лучше заименовать, вынести
There was a problem hiding this comment.
А вообще можно было написать как-то так. Если не стремиться фанатично сделать все на 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.