Skip to content

Conversation

@stupidnessplusplus
Copy link


public class Md : IStringProcessor
{
private readonly ITagPairsFinder _tagPairsFinder;

Choose a reason for hiding this comment

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

В шарпе не принято именовать приватные переменные с _


private Dictionary<IMdTag, List<SubstringReplacement>> GetTagsIndices(string mdString, IEnumerable<IMdTag> tags)
{
var tagsIndices = tags.ToDictionary(tag => tag, tag => new List<SubstringReplacement>());

Choose a reason for hiding this comment

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

Здесь можно сделать так:

tags.ToDictionary(tag => tag, _ => new List<SubstringReplacement>());

Всё равно не используешь tag в функции задающей value

.ToDictionary(kv => kv.Key, kv => _tagPairsFinder.PairTags(mdString, kv.Value).ToList());
var tagPairs = _pairTagsIntersectionHandler
.RemoveIntersections(pairedTags)
.ToDictionary(kv => (IHtmlTagsPair)kv.Key, KeyValuePair => KeyValuePair.Value.AsEnumerable());

Choose a reason for hiding this comment

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

Странноватое именование KeyValuePair следовало бы назвать keyValuePair

Copy link
Author

Choose a reason for hiding this comment

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

В остальных случаях везде kv писал, тут случайно так назвал

{
for (var (i, j) = (0, 0); i < tagPositions.Length; i++)
{
for (; lineBreakIndices[j] < tagPositions[i].EndIndex; j++) ;

Choose a reason for hiding this comment

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

Сложновато для восприятия выглядят такие циклы.
Лучше наверное использовать что-то вроде:

while(lineBreakIndices[j] < tagPositions[i].EndIndex) j++;

{
private const string MdTag = "!";

private readonly LinkMdTag _linkMdTag = new();

Choose a reason for hiding this comment

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

Снова именование переменных


public static bool IsNumber(string str, int startIndex, out int length)
{
for (length = 0; startIndex + length < str.Length && char.IsDigit(str[startIndex + length]); length++) ;

Choose a reason for hiding this comment

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

Ну опять-таки нет никакого смысла описывать подобную логику через for - это очень неудобно читать. Используй while

internal class Benchmark
{
public long MeasureMilliseconds(
Action f,

Choose a reason for hiding this comment

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

f?


public class MdTests
{
private Md _md;

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.

Ну и про именование не забывай

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