The Evil within the Comparison Functions
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: The Evil within the Comparison Functions

  1. #1
    Join Date
    Mar 2016
    Posts
    26

    The Evil within the Comparison Functions

    Programmers are very attentive people. The specifics of their work is that even one typo can break the logic of the whole program. Such errors can be detected by specialized code analysis tools. But still, it would be very interesting to see if there are any error patterns: what errors appear in functions most often? Well, one C/C++ developer, a Microsoft MVP, decided to find an answer for this question.

    As it turned out, one of the most frequent errors occurs in simple comparison functions: IsEqual, Equals, Compare, AreEqual and so on, ot in overloaded operators, such as ==, !=. At first glance it may seem that the comparison functions are so simple and trivial, that they don’t need any unit tests or checks by additional code analysis tools, but perhaps, developers just underestimate them, thinking that they are too banal. You may see this phenomenon in the article “The Evil within the Comparison Functions”.

  2. #2
    Join Date
    Feb 2017
    Posts
    146

    Re: The Evil within the Comparison Functions

    Quote Originally Posted by El_programmer View Post
    As it turned out, one of the most frequent errors occurs in simple comparison functions: IsEqual, Equals, Compare, AreEqual and so on,
    Well, boiled down to Turing completeness, programming consists of just two activities namely comparing things and putting things in sequence. Intuitively, comparing things takes more brainpower than doing things in the right order so I would not be surprised if it were found to be the most error-prone of the two.
    Last edited by wolle; June 18th, 2017 at 02:13 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)