Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 May 2020 07:42:45 +1000
From:      andrew clarke <mail@ozzmosis.com>
To:        Tim Daneliuk <tundra@tundraware.com>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: Multi-line text output via printf() et al.
Message-ID:  <20200514214245.tn36ajhtppielugg@ozzmosis.com>
In-Reply-To: <c9d3f4cd-a405-c404-8f82-cf2de5a0c9db@tundraware.com>
References:  <20200514220904.7a4c1e28.freebsd@edvax.de> <c9d3f4cd-a405-c404-8f82-cf2de5a0c9db@tundraware.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On 2020-05-14 15:44:18, Tim Daneliuk (tundra@tundraware.com) wrote:

> Warning - Pet Peeve follows, ignore me if you think it's stupid ...
> 
> However you decide to do it, can we _please_ stop embedding literal strings
> in printf(), python print(), and so forth?  Strings should be pulled out
> as variables into one centrally maintained location in the code.  Why?
> Because, someday, you may actually want to have your code run with output
> in something other than your native language.  Because strings are often
> reused in several places in the code.  Because you may someday actually
> want to use unicode characters.

Fundamentally I agree but doing this opens a can of worms that I suspect
many coders would prefer not to deal with, especially for hobby projects
that form the basis of many open source programs.

And rightly or wrongly, literal strings do act as documentation.

Also for modern languages like Python and C# 6.0 there's the problem of
refactoring expressions written into string literals. It's not ideal to have
these strings strongly decoupled from the code they're associated with.

> You haven't lived until you've had to scour thousands of lines of code
> looking for literal strings or having those strings embedded symbolically,
> deep down in the guts of the code.

There should be tools that can help with this.



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20200514214245.tn36ajhtppielugg>