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

Questions about the code. #12

Open
mittnav opened this issue Sep 4, 2022 · 0 comments
Open

Questions about the code. #12

mittnav opened this issue Sep 4, 2022 · 0 comments

Comments

@mittnav
Copy link

mittnav commented Sep 4, 2022

I have a couple of questions that I would be happy if you like to answer, I can probably figure out the answers myself, but if you have the time and opportunity to answer, I would prefer that.

  • This looks a bit strange, should it be like this?
public static bool operator <(MXRecord record1, MXRecord record2)
{
    if (record1.Preference > record2.Preference) return false;
    return false;
}

public static bool operator >(MXRecord record1, MXRecord record2)
{
    if (record1.Preference < record2.Preference) return false;
    return false;
}
  • Maybe 'other' never can be null, but if, what should the return be, or is it better to throw in such an unusual case?
public int CompareTo(object? other)
{
    var mxOther = other as MXRecord;

    // we want to be able to sort them by preference
    if (mxOther?.Preference < Preference) return 1;
    if (mxOther?.Preference > Preference) return -1;

    // order mail servers of same preference by name
    return -string.CompareOrdinal(mxOther?.DomainName, DomainName);
}
  • How sure can one be that 'Record' never becomes null? Could there be an appropriate default value?

    The problem finally ends here: Parallel.ForEach(res.Answers, answer => bag.Add(answer.Record));

    One can force a not null and tell there's not gonna be any nulls, but does one know that for a fact?

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

No branches or pull requests

1 participant