-2

I am separating one of my method extension classes (i.e., StringExtensions) into regions, as has become confusing and it's difficult to see the wood for the trees. I have grouped the methods into four regions, as follows:

Identification: Usually associated with the verb to be, e.g., Is, Has, etc., and returns a Boolean. These are mainly used in validation.

Selection: Filters from a collection passed in or replaces what is passed in with empty or null, with no other manipulation

Conversion: Different type is returned to the one entered, without any manipulation or calculation.

Substitution: Returns a manipulation or calculation of what is passed, where the manipulation involves more than replacing with an empty string or null.

I've looked around and found little on the subject. So, I was wondering if there is an already existing concept of grouping methods, as these work for most cases but aren't mutually exclusive. Please could you suggest mutually exclusive groups for String Extension methods?

EDIT: I don't want to subdivide separate namespaces or classes as this extension method class is already used by many applications and would introduce breaking changes.

Phil Helix
  • 1,966

1 Answers1

3

I am separating one of my method extension classes (i.e., StringExtensions) into regions...

Please don't do that. If your class has got so big that you need to consider using regions, then break up the class instead.

You have already identified good names for those classes:

StringIdentificationExtensions
StringSelectionExtensions
StringConversionExtensions
StringSubstitutionExtensions

Those names and descriptions make sense and there is no established standard that "overrules" you, so go with these classes as a starting point at least.

David Arno
  • 39,599
  • 9
  • 94
  • 129