Search code examples
naming

Better name for "afterOrEqualDate" method


Our code has a method whereContractEndIsAfterOrEqualDate(), and I do not really like the "AfterOrEqualDate" part because it is so long.

Is there a better name for such methods?


The Laravel PHP framework has validators that have the same name: https://laravel.com/docs/5.5/validation#rule-after-or-equal


Solution

  • I would prefer something more logical/semantic way that expresses the real behavior of this control like isContractDateExpired() if this is a boolean method.

    By this approach you are fixing the method's name to reveal it's intention from the objects context itself. From the upper level perspective accessing and calling this object it may not be important to declare how to check the date if it is before and equal to a date or not. This approach allows our objects to be more domain-driven and more autonomous.