User:Average/ClotheYourData

From HackerspaceWiki
Jump to: navigation, search

ClothingYourData is about containing your data in a struct or other named data structure for which you have a useful categorization (so others can use it). And, then, maximizing these contextual groupings by finding rules which consistently represent and support the unseen relationships of data objects. Your programming language`s keywords are already an application of this rule. This rule could also be seen as a type of "data hiding". By clothing it, you put less noise in the programmer`s way but more knowledge and more semantics. A good trade, eh? Leave the rest to the programmer (language designer) to order meaning.

In Assembly, putting mneumonics on your binary instructions is an example of this -- in fact the design of the instruction set itself is already an application of this ideal (along with SeparabilityOfDomains). In C, specifying type declarations for variables is an example of clothing-your-data. It's a type of over-coat, since it's clothing over your clothing. But, hey, it gets cold out there in the land of pure logic.

Naming an index variable "i", or if just a regular integer, not related to an index, then "n", but if a float value, then "f". Simple, direct, informative. If it's a variable that holds more meaning than readily apparent, then obviously you can name it "VideoPointer", or some such.

Another example, is naming your constants -- instead of putting magical values all over your code giving very little information about what they're doing there. The convention suggested (under CRUCIBLE 2?) is to use underscores for constants: _CAPS_ when those constants are stringent and _lowercase_ when they're for public modification or arbitrary. Also, if you know your data should be within the range of 0-255 (because you've designed it that way), you don't use a long "just to be safe". That's a kind of baggy clothing style. Are you living on the street? Use an u8 or "unsigned short" and you'll be a "well-tailored" program.


Imagine this: you have only strings of 0s and 1s of, say, 1024 digits. Now, what force do you have to make meaning out of data? Well, you have the CPU which may separate it into 8-bit words. That's layer 1. Then you have the force of the text terminal or your assembler, which turns them into ASCII or mneumonics + hex codes. That could be considered a nice level 2 "clothing of your data". And then you might organize that into lines and make a text file with an EOF marker, level 3. Save.

You could conceivably use this rule to make templates which match and architect that data into greater meaning (a "namespace"). But never forget it's basis: straight (likely CPU words) streams of binary data without any meaning.

All this is to get you to think about how to structure objects that manipulate data in sophisticated ways, working from their native language. ...to make a UnifiedDataModel and DataEcosystem.


This rule is balanced with a counteracting rule: if you don't have a category that represents your data or processing concept, LeaveItNaked.

Personal tools