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

Горбатов Александр #212

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

Conversation

SilversShade
Copy link

Comment on lines 22 to 35
do
{
var x = center.X + radius * Math.Cos(angle);
var y = center.Y + radius * Math.Sin(angle);
rectangle.Location = new Point((int) x, (int) y);

angle += angleIncrement;

if (!(angle >= 2 * Math.PI))
continue;

angle = 0;
radius += radiusIncrement;
} while (IntersectsWithAny(rectangle));

Choose a reason for hiding this comment

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

Давай вынесем алгоритм по построению спирали в отдельный класс
Допустим чтобы можно было его удобно протестировать и посмотреть твой код при разных условиях

Comment on lines 56 to 66
public Rectangle GetCloudBorders()
{
var left = PlacedRectangles.Min(r => r.Left);
var right = PlacedRectangles.Max(r => r.Right);
var top = PlacedRectangles.Min(r => r.Top);
var bottom = PlacedRectangles.Max(r => r.Bottom);

var width = right - left;
var height = bottom - top;
return new Rectangle(left, top, width, height);
}

Choose a reason for hiding this comment

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

Тоже более общий кажется его можно унести в другой класс

Comment on lines 23 to 33
var bitmap = new Bitmap(borders.Width * scale, borders.Height * scale);
var graphics = Graphics.FromImage(bitmap);

var rectanglesWithShift = layouter.PlacedRectangles
.Select(r =>
new Rectangle(
(r.X - borders.X) * scale,
(r.Y - borders.Y) * scale,
r.Width * scale,
r.Height * scale));

Choose a reason for hiding this comment

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

Давай тоже вынесем в отдельный класс

Comment on lines 33 to 34
[TestCase(true)]
[TestCase(false)]

Choose a reason for hiding this comment

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

Посмотри на [Values], с ним намного проще будут выглядеть

Choose a reason for hiding this comment

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

Остальные тесты можно на него тоже переделать

Copy link

@Pasha0666 Pasha0666 left a comment

Choose a reason for hiding this comment

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

Тесты в этот раз особо не глядел, следующий раз посмотрю

Comment on lines 21 to 23
{
Assert.Throws<ArgumentException>(() => drawer.DrawRectangles(null!, new Rectangle(1,1,1,1)));
}

Choose a reason for hiding this comment

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

пробелы потерялись

Comment on lines 10 to 23
Rectangle GetCloudBorders()
{
if (PlacedRectangles is null || PlacedRectangles.Count == 0)
throw new InvalidOperationException("The list of placed rectangles cannot be null or empty");

var left = PlacedRectangles.Min(r => r.Left);
var right = PlacedRectangles.Max(r => r.Right);
var top = PlacedRectangles.Min(r => r.Top);
var bottom = PlacedRectangles.Max(r => r.Bottom);

var width = right - left;
var height = bottom - top;
return new Rectangle(left, top, width, height);
}

Choose a reason for hiding this comment

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

Выносить метод в интерфейс, не очень хороший подход. Я бы это лучше в отдельный класс вынес

Comment on lines 41 to 56
var radius = 0d;
var angle = 0d;

do
{
var x = Center.X + radius * Math.Cos(angle);
var y = Center.Y + radius * Math.Sin(angle);
rectangle.Location = new Point((int) x, (int) y);

angle += AngleIncrement;

if (!(angle >= 2 * Math.PI))
continue;

angle = 0;
radius += RadiusIncrement;

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.

Плюс ты вынес вот этот отдельный клас, но допустим мы захотим рисовать по кругам, то нам все еще придется написать довольно много кода заново

Copy link
Author

Choose a reason for hiding this comment

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

Кажется ты каждый раз начинаешь считать от центра

Да, но если это изменить, облако получается чуть менее плотным и менее красивым

Comment on lines 36 to 37
public void GetCloudBorders_ThrowsInvalidOperationException_WhenListOfRectanglesIsNullOrEmpty(
[Values(false, true)] bool isNull)
Copy link

@Pasha0666 Pasha0666 Dec 5, 2023

Choose a reason for hiding this comment

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

можно просто [Values] bool isNull

Comment on lines 6 to 9
public class TagsCloudDrawer
{
private readonly ICloudLayouter layouter;
private readonly IRectangleDrawer drawer;

Choose a reason for hiding this comment

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

глобальный вопрос а чем сейчас занимается этот класс?

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