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

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

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

Conversation

Kexogg
Copy link

@Kexogg Kexogg commented Jan 22, 2025

No description provided.

Copy link

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

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

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))

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)

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

Choose a reason for hiding this comment

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

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

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