1
$\begingroup$

StringReplacePart["StringReplacePart","At",{14,17}] ... Surely you can't be serious? ...


Naming Matters: I think what and how we call things is underestimated since not only does it immediately impact on codes` readability (or decipherability?), recallability and autocompletability but on deeper and growing connections between natural language and literate programming.

It has long puzzled me why, for example, ReplacePart was not named ReplaceAt. Three ovearching principles relevant to finding a good name - Expressibility, Brevity and Consistency, often represent competing tensions but for mine, ReplaceAt has got ReplacePart covered on all three criteria. Of course, there may be some semantic sense, or logic I have overlooked but even the process of considering the principles behind System naming can, I think, improve one's own programming and efficiency. This question delves into the principles behind System names (with a focus on linguistic senses) while this answer gives some tips on user-defined names (in the broader context of what pitfalls to avoid) but I'm interested in further criteria that combine both.

While acknowledging the personal preference and potentially discursive nature of this question, my sense is that it would nonetheless be useful to posit a considered naming convention that while not absolute could still be usefully followed in the main. I'm looking for (<9) principles/rules/guidelines/tips for naming variables/functions (and which might encompass factors such as comparison/distinction with System functions, use of "palette symbols", linguistic/grammar sensibilities, length, capitalizations, context, user-experience, frequency etc). Naturally, answers themselves exhibiting Expressability, Brevity and Consistency will be preferred.


... Well yes I am (and don't call me Shirley ... with apologies to Dr. Rumack)

$\endgroup$
9
  • 4
    $\begingroup$ Have you been playing with the package Experimental`MindAlteringDrugs` ? What is the question here? $\endgroup$
    – ciao
    Aug 13, 2015 at 0:08
  • 1
    $\begingroup$ @ciao has a point. Anyway, this has been discussed before. A good suggestion then was: "... That which we call a rose / By any other name would smell as sweet." $\endgroup$
    – MarcoB
    Aug 13, 2015 at 0:14
  • $\begingroup$ @ciao Possibly, but yes suspect a closure is on the cards. Think there is a useful question lurking in there but oh well $\endgroup$ Aug 13, 2015 at 0:16
  • $\begingroup$ A classier name for StringReplacePart would be StringYoureFired. Regards, D. Trump. $\endgroup$
    – Jens
    Aug 13, 2015 at 1:16
  • 1
    $\begingroup$ I can't quite figure out where you're going with this so I'll just comment on the one concrete example I see. I would expect ReplaceAt to perform a Replace operation "at" a particular position, whereas I would expect ReplacePart to directly replace a particular part of of an expression. So at least at first blush your simplification would add confusion, IMHO. A complicated issue to be sure but I'm not sure it can properly addressed on this site. $\endgroup$
    – Mr.Wizard
    Aug 13, 2015 at 3:49

0