Skip to content

Мажирин Александр#205

Open
Kexogg wants to merge 4 commits intokontur-courses:masterfrom
Kexogg:homework
Open

Мажирин Александр#205
Kexogg wants to merge 4 commits intokontur-courses:masterfrom
Kexogg:homework

Conversation

@Kexogg
Copy link
Copy Markdown

@Kexogg Kexogg commented Jan 22, 2025

No description provided.

Copy link
Copy Markdown

@Buskervil Buskervil left a 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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Через параметры передавать было бы аккуратнее

.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}"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

У тебя же логгер есть

)
.UseImageEncoder<PngEncoder>())
.Then(r => r.FromString(GenerateRandomString(count)))
.Then(imageBytes => File.WriteAllBytes($"results/random_cloud_{count}.png", imageBytes))
Copy link
Copy Markdown

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)
Copy link
Copy Markdown

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;
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

жирновастая функция. Лучше заименовать, вынести

Copy link
Copy Markdown

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
    };
}

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