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

Азанов Андрей #225

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

Conversation

Azkraft
Copy link

@Azkraft Azkraft commented Dec 5, 2023

@the_homeless_god

}

[Test]
public void DensityTest()

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.

Одно из требований — высокая плотность размещения прямоугольников. Может быть так и назвать?

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17

Choose a reason for hiding this comment

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

Как считаешь какую версию IDE стоит использовать и почему?

Copy link
Author

Choose a reason for hiding this comment

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

Последнюю стабильную версию, как и с большинством другого ПО. У меня нет причин выбирать предыдущие версии. У 2019-ой студии вроде как поддержка в 2024-ом заканчивается, для редакции Community уж наверняка. Не очень перспективно выходит

Comment on lines 1 to 15
using System.Drawing;
using TagsCloudVisualization;

var rnd = new Random();
var sizes = new Size[500];
for (var i = 0; i < sizes.Length; i++)
{
sizes[i] = new(10 + rnd.Next(40), 1 + rnd.Next(40));
}
var tagCloudLayouter = new CircularCloudLayouter(new(500, 500));
foreach (var size in sizes)
{
tagCloudLayouter.PutNextRectangle(size);
}
TagCloudSaver.Save(tagCloudLayouter.TagCloud, "image.png");

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.

Не нужно. Использовалось для проверки визуализации

{
DrawRectangle(rect, bitmap);
}
bitmap.Save(fileName);

Choose a reason for hiding this comment

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

Что делать если будет IO ошибка?

Copy link
Author

Choose a reason for hiding this comment

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

Ну, неуправляемые ресурсы должны освободиться благодаря using, а проблемы из-за которых произошла ошибка, наверное, должна решать вызывающая сторона


public static void Save(List<Rectangle> rectangles, string fileName)
{
using var bitmap = new Bitmap(1000, 1000);

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.

Нужно вычислить габариты облака и сделать расчёт параметров изображения

private static void DrawRectangle(Rectangle rectangle, Bitmap bitmap)
{
var color = Color.FromKnownColor((KnownColor)(1 + random.Next(175)));
for (var i = rectangle.Left; i <= rectangle.Right; i++)

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.

Такое может случиться, если rectangle.Right == int.MaxValue

Comment on lines 24 to 25
bitmap.SetPixel(i, rectangle.Top, color);
bitmap.SetPixel(i, rectangle.Bottom, color);

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.

Да. Можно воспользоваться встроенным методом Graphics.DrawRectangles и не мучиться. Или можно было вложить один цикл в другой, добавить условий и оставить один SetPixel

Comment on lines 30 to 31
bitmap.SetPixel(rectangle.Left, i, color);
bitmap.SetPixel(rectangle.Right, i, color);

Choose a reason for hiding this comment

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

Есть идеи что делать с дублированием кода?


namespace TagsCloudTest
{
public class Tests

Choose a reason for hiding this comment

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

Как считаешь название файла должно быть таким же как имя класса?

И имя класса Tests не слишком ли обширно?

Copy link
Author

Choose a reason for hiding this comment

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

Имя типа должно совпадать с именем класса. Я хотел все тесты разместить в классе Tests. Есть ли смысл его в таком случае переименовывать?

{
sizes.Add(new(10 + rnd.Next(40), 1 + rnd.Next(40)));
}
circularLayouter = new CircularCloudLayouter(new(500, 500));

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.

Да. Можно было бы отловить зацикливание

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