Thursday, November 23, 2017

Software Molestations

Software Molestations (no - this is not about web radio transmissions of deep-under-cover agents)

There's this guy,  Martin Fowler, who dislikes some software patterns.   Saying:  "I don't like this stuff"  doesn't make much of an impression in the code-slinger biz, so he created the term "Code Smells".

Most folks don't want to seem "smelly" - so he has waged an effective campaign to make people code as he prefers.

Things that "smell", according to Martin, are:

  • Duplicated code
  • Objects that do to much
  • Objects that do to little
  • Right-side-up control (He prefers inversion) 
  • A class that uses some other class too much
  • A class that "knows too much" about another class
  • Too many parameters to a method
  • A method that is too big
  • Very long names
  • Very short names
  • Methods that return more than its callers care about
  • And, most likely, jokes in the comments, identifiers beginning with vowels, code written with vi or emacs

Taking a page from Fowler's book,  but pushing the technique a little further, we come up with "Code Molestations".  No one wants to admit to molestations.

Some Code Molestations are:
  • Using a too-powerful IDE to create programs that can ONLY be maintained in an an IDE
  • Spraying the disk (or repo, or cloud) with thousands of tiny files that exist only to impart a NAME to some existing Type.  (e.g. Create a "Title" class that does nothing but rename "String")
  • Over use of Objects. State, etc. where it is totally unnecessary.
  • Under use of Plain Old Functions.
  • "Map" concepts that dont really map anything (just screwed-up syntax on top of Iterators) - Maps in functional language RETURN SOME COLLECTIVE RESULT!  And they don't make you COLLECT something at the end!
  • CamelCaseNazisWhoCantResistMolestingAcronyms (aka CCNWCRMA)
  • UpcaseNazisWhoCantResistMolestingConstants
  • functionsDeclarationsThat(inMentionSomeParamrters,inOutMentionOthers,outOnlyLieAboutOthers)
  • bigLongConstantNamesForIteratorsWhoShouldBeCalled "i" or (j,k,l...x,y,z,a,b,c)
  • 10 Functions that only return only one thing (with all the added documentation, tests, etc) where one function that returns a (logically related) COMBINATION of things would be superior (think Matlab, or Scheme, or Perl)
  • Guys that use group-think stunts to promote their coding preferences, because they lack logical arguments to support them.

 



No comments:

Post a Comment