views:

104

answers:

5

First of all, this is not really a programming question. It's more a question of "how do I satisfy McConnels naming conventions?"

I have this Delphi-application that manipulates word-documents. One of the things I need to do is run through all the bookmarks in the document and delete some of them based upon a simple rule: If I currently work on a quote I will delete all bookmarks where the name begins with "cw_orderspecific". If I work on an order confirmation I will remove all bookmarks with names beginning with "cw_quotespecific".

The method is in place, and everything works perfectly, but I have a tiny problem. What should I call my method? The current name ("DeleteBookmarksNotAllowedForCurrentDocumentType") is too long.

Any suggestions?

+2  A: 

DeleteNonRelevantBookmarks ?

djna
DeleteIrreverentBookmarks *chuckle*
pst
Accepted, but I actually went with "DeleteIrrelevantBookmarks". Close enough :-)
Svein Bringsli
A: 

Use acronyms? Define in comments that CDT is "Current Document Type", and you'll get DeleteBookmarks_NotAllowedForCDT. Short enough.

Pavel Shved
+3  A: 

Change the function to take the prefix to delete, and call it DeleteBookmarksWithPrefix:

DeleteBookmarksWithPrefix("cw_quotespecific")

or

DeleteBookmarksWithPrefix(otherWorkTypePrefix)

That makes the code very readable, and it makes the function reusable in other circumstances, rather than only ever being useful for one very specific task.

Note that if you'll ever have a third work type, you might want to reverse the sense of it:

DeleteBookmarksWithoutPrefix(currentWorkTypePrefix)
RichieHindle
+1 for being a very "correct" answer. But I won't accept it. This method will *NEVER EVER* be modified. Well, unless the customer comes up with another request.
Svein Bringsli
A strategy that depends upon the customer *not* coming up with another request is either very pessimistic (Succesful systems tend to lead to new requirements) or has built in fossilization, in which case who cares about naming conventions. I would go for flexibility as defined in this answer.
djna
The customer ALWAYS comes up with another request. ;)
Carlos
I realize I should have included the irony-tags...
Svein Bringsli
+2  A: 

How short you want it to be? My first instinct is to drop some words that don't seem that important. Like DeleteBookmarksNotAllowedForDocumentType, DeleteBookmarksNotAllowedForDocument, or simply DeleteBookmarksNotAllowed. Though I'd probably prefer something like DeleteInvalidBookmarks. Of course this works only if there are no other methods that delete bookmarks by different rules.
Or if you're willing to change the way you method functions, I'd make it more generic by giving the prefix as a parameter, then the naming would be simpler.

Carlos
A: 

How about DelBookmarksStartingWith? It's pretty clear and expresses intent.

Geo