I have a class which checks for differences. I could call this

class ViolationDiffer
    public IEnumerable<ViolationChange> Diff(
        IEnumerable<Violation> old,
        IEnumerable<Violation> new


class ViolationDifferentiator
    public IEnumerable<ViolationChange> Differentiate(
        IEnumerable<Violation> old,
        IEnumerable<Violation> new

To diff two text files, is so common place, that I would guess that almost everybody would understand what this did.

In the spirit of being explicit, Differentiate is just that. Is there a rule for when a term is appropriate to shorten, as in, the shortened version is verbally used maybe?

  • 6
    I think most developers will know that Diff is looking for differences between two files - on the other hand Differentiation is a mathematics term... – HorusKol Sep 21 '17 at 8:25
  • That's a good point. – Chris Wohlert Sep 21 '17 at 8:32
  • 1
    What you trying to achieve by shorter name. differentiate is pretty clear name. Modern IDE with IntelliSense will provide completion and you don't need to type full word – Fabio Sep 21 '17 at 8:36
  • If both terms are understood equally quick, then Diff requires less effort to read than Differentiate. I don't know of any such rule though, but would love if someone else did. – Chris Wohlert Sep 21 '17 at 8:38
  • 1
    To me differentiate is to determine the rate of change with respect to time* so 3.7 letters of change per second. Not what is the difference between 2 things. Is diff even short for differentiate as opposed to difference? – Richard Tingle Sep 21 '17 at 17:47

Use Diff and Differ, not Differentiate and Differentiator. The former have effectively become technical terms in programming, not abbreviations.

To me, Differentiate is much less clear than Diff, and I couldn't even say for certain that this is what "diff" originally stood for.

  • nitpick: Diffor over Differ, to avoid bool differs and IEnumerable<Differ> differs colliding – Caleth Sep 21 '17 at 10:31
  • 2
    Most importantly: Add some documentation on top of it, so a developer can verify their interpretation of the name based on intuition with a clear-cut description of what the class is actually doing! – Frank Hopkins Sep 21 '17 at 10:39
  • @Caleth I think the confusion of what looks to me like a typo outweighs the advantage of not having those names collide. I can always name the boolean different. – Sebastian Redl Sep 21 '17 at 11:03
  • 1
    ss64.com/bash/diff.html would indicate that 'diff' stood for 'difference' – Pete Kirkham Sep 21 '17 at 13:00
  • 1
    Diff is certainly used as a verb though. "Just diff the text files". – Chris Wohlert Sep 21 '17 at 13:29

my suggestion would be

class ViolationDifferences
    public IEnumerable<ViolationChange> FindBetween(
        IEnumerable<Violation> old,
        IEnumerable<Violation> new

which reads out in your code as

 IEnumerable<ViolationChange> differences =
       new ViolationDifferences().FindBetween(old, new);

A (mathematical) alternative could be Delta.

I think there is no strict rule when to shorten and when not. It depends on who has to read (and use) your code (your audience). If you assume that an abbreviation is well accepted then it is appropriate to use it.

Another factor is how often this method is used. The more commonly it is used the more appropriate is it to abbreviate.

  • "think there is no strict rule when to shorten and when not." I argue! The (strict) rule is: when in doubt do not abbreviate... – Timothy Truckle Sep 21 '17 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.