-
Notifications
You must be signed in to change notification settings - Fork 276
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
Овечкин Илья #220
base: master
Are you sure you want to change the base?
Овечкин Илья #220
Conversation
{ | ||
public class CircularCloudLayouter | ||
{ | ||
private List<Rectangle> rectangles; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше ICollection
, если возможно. Это позволит при необходимости поменять реализацию не опасаясь потери обратной совместимости
public class CircularCloudLayouter | ||
{ | ||
private List<Rectangle> rectangles; | ||
private Point center; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Никогда не присваивается, мб и не нужно
private List<Rectangle> rectangles; | ||
private Point center; | ||
private Spiral spiral; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Всё это readonly
return nextRengtanle; | ||
} | ||
|
||
public List<Rectangle> Rectangles => rectangles; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше IReadonlyCollection
. Это защитить от опасности редактирования листа кем-нибудь снаружи
cs/TagsCloudVisualization/Spiral.cs
Outdated
|
||
namespace TagsCloudVisualization | ||
{ | ||
public class Spiral |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне нравится идея выделения логики генерации прямоугольников от места их хранения, но немного смущает название класса. Хорошо бы как-то более точно отобразить его роль в названии
(тут же маленькая опциональная рекомендация - делать все свои классы sealed
, если не требуется обратное - такой код работает чуточку быстрее + дважды заставит задуматься, а стоит ли наследоваться от данного класса)
cs/TagsCloudVisualization/Spiral.cs
Outdated
|
||
while (true) | ||
{ | ||
Point point = new Point( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Везде где возможно, var
graphics = Graphics.FromImage(image); | ||
} | ||
|
||
public void drawCloud() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут конвенция именования пошла куда-то не туда. Должен быть PascalCase
public void drawCloud() | ||
{ | ||
graphics.Clear(Color.White); | ||
foreach (var rect in layouter.Rectangles) | ||
{ | ||
graphics.FillRectangle(Brushes.Red, rect); | ||
graphics.DrawRectangle(Pens.Black, rect); | ||
} | ||
graphics.Save(); | ||
|
||
} | ||
|
||
public void saveImage(string fileName) | ||
{ | ||
image.Save(fileName); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Есть ли необходимость разделять эти две функции, если они всегда вызываются в паре
private Bitmap image; | ||
private Graphics graphics; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кажется, не должно быть в полях класса
SaveIncorrectResultsToJpg(); | ||
} | ||
|
||
public static IEnumerable TestCasesForWrongCenterPoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нет необходимости превращать в перечисление. Можно сделать обычным массивом
@a_zhelonkin