1

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)

Ronald Monson
  • 6,076
  • 26
  • 46
  • 4
    Have you been playing with the package Experimental`MindAlteringDrugs`? What is the question here? – ciao Aug 13 '15 at 00:08
  • 1
    @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." – MarcoB Aug 13 '15 at 00:14
  • @ciao Possibly, but yes suspect a closure is on the cards. Think there is a useful question lurking in there but oh well – Ronald Monson Aug 13 '15 at 00:16
  • A classier name for StringReplacePart would be StringYoureFired. Regards, D. Trump. – Jens Aug 13 '15 at 01:16
  • @ciao In case you haven't them, the docs are here – Dr. belisarius Aug 13 '15 at 02:38
  • 1
    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. – Mr.Wizard Aug 13 '15 at 03:49
  • Well I suppose the Part in StringPart has different semantics (actual structure) from the Part in ReplacePart (position in structure) which allows their similar form even with different meanings. Of course, as pointed out by @ciao and @Jens no such issue arises while working in an alternative context since the analogous ExperimentalMindalteringDrugsTrumpYoureFiredandExperimentalMindalteringDrugsTrumpStringYoureFired have less conflict. – Ronald Monson Aug 13 '15 at 03:53
  • @Mr.Wizard beat me to this exact point by seconds - yes better to let this one go through to the keeper – Ronald Monson Aug 13 '15 at 03:57

0 Answers0