A common practice for generating readable text in code is the use of format strings, which allow for the formatting of data directly within the string. This approach is preferred over concatenation because it avoids the need for separate variable assignments and makes the code more readable. However, there is a slight drawback: the readability of the code can be compromised when using format strings, especially when dealing with complex formatting requirements.
Key points
A common practice for generating readable text in code is the use of format strings, whic…: A common practice for generating readable text in code is the use of format strings, which allow for the formatting of data directly within the string.
This approach is preferred over concatenation because it avoids the need for separate var…: This approach is preferred over concatenation because it avoids the need for separate variable assignments and makes the code more readable.
However, there is a slight drawback: the readability of the code can be compromised when…: However, there is a slight drawback: the readability of the code can be compromised when using format strings, especially when dealing with complex formatting requirements.
Sources checked by our analysis pipeline: 1
We all love format strings for generating human readable text. Certainly, they're a better choice than string concatenation. Even if I have a blind spot that keeps me from remembering the printf
format tokens, I still prefer to use format strings.
Jasmine has a co-worker that does use format strings, but they also miss using string concatenation. So they've found a way to combine them, and avoid the perils of making readable code that describes the format of their text.
myField.DataFormatString = "{0:#,##0." + new string('0', 2) + ";(#,##0." + new string('0', 2) + ")}";
Now, in their defense, I can see how this code started its life. At some point, they wanted to make the number of decimal places a parameter. And sure, this is an easy way to do that and retain the intent, though this whole thing could be cleaned up with just a simple decimalPlaces = new string('0', 2)
, which would make the concatenation less confusing to read.
Related, while I was checking the documentation on the .NET formatting strings, I learned that they have a per-mille format specifier which requires writing a unicode sigil on most keyboards.
### Briefing We improved Eon, the Slack agent used across Tiger Data, by building three agentic memory systems: a list of user-scoped facts, a general knowledge graph, and a tree-based system. As we watched agents use them, we learned that a more expressive system was not necessarily more effective. Other teams began using our tree-based system for applications beyond agent memory, extracting the reusable search infrastructure into searchgres.js, an open-source TypeScript library for hybrid search with composable…
Cloudflare has successfully obtained South Korea's Information Security Management System (ISMS) certification under the ISMS-P framework, aligning with the country's law, language, and expectations. This certification is not just a compliance checkbox but a demonstration of Cloudflare's security and privacy program's alignment with Korean standards. The most notable change is the customized sign-up page for Korean users, which presents four separate consent items in Korean, linked to their full text and requiring…
Tech investors at the 2023 TechCrunch Disrupt conference shared advice on raising a Series A, with one investor warning of a 2027 correction. Founders must convince top firms of their special status in a dysfunctional market, moving toward vertical integration with capital flowing into defense, robotics, and AI infrastructure. Metrics are less defined, and AI is expected to be a substitute for other types of software. Founders must be intellectually honest in presenting their data and build a company that is intel…