Skip to content

Conversation

Hujh23
Copy link

@Hujh23 Hujh23 commented Aug 12, 2024

作业1

@asdawej asdawej added revision needed This PR need further revision checked This PR is checked as pass labels Aug 13, 2024
public override async Task Update()
{
await Task.WhenAll(exprA.GetValAsync(), exprB.GetValAsync());
val = await exprA.GetValAsync() + await exprB.GetValAsync();
Copy link
Owner

Choose a reason for hiding this comment

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

这个地方可以将前一句等待得到的结果直接拿来用。

@asdawej asdawej removed the revision needed This PR need further revision label Aug 13, 2024
@asdawej
Copy link
Owner

asdawej commented Aug 13, 2024

整体上没有问题。采用了比较独特的思路,使用 GetValAsync 的异步方法替代了原来的 Val 属性;采用 isDirty 控制 AddExpr 的首次更新,这比在 Register 中更新能更好地避免了重复调用;使用 List<Expr> parents 而非 Expr? parent,为复数父结点提供可能 (这是有意义的,如果有多个表达式存在共用部分,就可以减少运算量)。

不过,还是有几个值得注意的点(代码方面,当然,这些是和个人习惯有关的):

  • 文件开头有许多的 using,但是它们没有一个是必要的,因此应当删去。
  • 可以使用文件范围的命名空间,减少缩进:
namespace A
{
    ...
}
// 等价于
namespace A;
  • 使用 new() 初始化,减少打字数:
    image
  • 使用 [] 初始化空集合变量:
    image
  • 使用主构造函数减少代码量 (话说我本来就用的是主构造函数):
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checked This PR is checked as pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants