Skip to content

Медведев Фома#267

Open
Kpokoko wants to merge 5 commits intokontur-courses:masterfrom
Kpokoko:master
Open

Медведев Фома#267
Kpokoko wants to merge 5 commits intokontur-courses:masterfrom
Kpokoko:master

Conversation

@Kpokoko
Copy link

@Kpokoko Kpokoko commented Nov 26, 2025


public static class Program
{
public static void Main()

Choose a reason for hiding this comment

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

Вся эта логика построения в идеале, конечно, не в Main должна лежать. Вынеси в какой-нибудь класс (или группу классов) и вызывай из Main

public IEnumerable<Point> GetNextPoint()
{
yield return _start;
while (true)

Choose a reason for hiding this comment

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

while (true) потенциально может быть опасен. Давай зададим какое-нибудь большое, но разумное ограничение

[assembly: InternalsVisibleTo("TagsCloudVisualizationTests")]
namespace TagsCloudVisualization;

public class CircularCloudLayouter

Choose a reason for hiding this comment

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

Добавь интерфейс

private readonly IPointGenerator _pointGenerator;
private const int Density = 1;
private Point _center;
private bool isEnumerating;

Choose a reason for hiding this comment

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

Мотивация понятна, но решение использовать логику с isEnumerating для меня выглядит избыточным. Даже если бы Rectangle был ссылочным типом, метод GetLayout() всё равно возвращает элементы через yield, а значит перечисление заморожено на момент старта и yield не замечает возможных последующих изменений соурса - _prevRectangles. Плюс Rectangle - struct, так что возвращаются копии объектов. В многопоточном коде такая защита бы не помогла (ибо сама коллекция-источник не блокируется), а в однопоточном всё итак нормально, поэтому я бы логику эту выпилил

isEnumerating = false;
}

public Rectangle PutNextRectangle(Size rectangleSize)

Choose a reason for hiding this comment

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

Методы PutNextRectangle и PressRectangleToCenter имеют похожие участки кода, посмотри, может получится что-то вынести в отдельные методы, чтобы не нарушать принцип DRY

public static void Main()
{
// Раскладка фиксированных прямоугольников
var center = new Point(400, 400);

Choose a reason for hiding this comment

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

Напишу здесь, но относится ко всему проекту: многие параметры (вроде координат или настроек размера) можно вынести в константы, сделай это

.Sum(x => x.Size.Width * x.Size.Height);
var areaRatio = rectanglesArea / potentialCircleArea;

// В среднем сейчас точность около 75%, как повысить (и надо ли, или уже норм) - вопрос хороший, хотелось бы на этот счёт посоветоваться

Choose a reason for hiding this comment

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

Приемлемо, можно оставить

// Этот тест перестал работать из-за уменьшения шага в генераторе спирали, так что теперь точки ближе => прямоугольники
// не влезают так, как раньше
[Test]
public void ArchimedeanSpiralGenerator_ShouldGeneratePoints_ByArchimedeanSpiral()

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.

Хорошо, оставлю его для демонстрации того, что 3 пункт задачи работает (это тот, в котором говорится о генерации изображения раскладки на упавшем тесте)

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