Saturday, August 9, 2014

Learning C#, Lesson 1: Data about data

When you think about metadata, what comes to mind? Perhaps you're thinking of the low level details NSA collects. ex: John Smith's call lasted 17 & a half hours (if you can believe it). Well, that's close but in programming we look at it in a vastly different way (I can personally assure you this lesson doesn't involve spying). Let's give metadata a proper overview, shall we?

In the context of a program, metadata is data about data. Remember that by any means necessary! (even if you have to repeat it until your face turns green.. Ok, don't do that) To illustrate: You want to buy strawberries by the pound but you know they sell by the gram. How would you solve this problem? If you answered "uh, just start writing the dang program?" you'd be wrong and I'll tell you why. No matter how simple this problem looks, it's best to break it down. A good programmer would start by asking themselves "hmm, which units will I be using; ints, floating point..?", "are there any values I shouldn't accept?". This is metadata, data about our data. And we use it to both organise our program and (perhaps more importantly) to write the program in a proper manner. The latter is especially true when writing programs for others.

For the time being, don't let the example bog you down. Just remember that metadata helps us structure programs.

At this point, you may be wondering where the code is. I can assure you that you'll see plenty of it, but I wanted to ease you into the subject by teaching you how to approach programming. Here's another reason thinking about metadata is important: If I take the above example and unconsciously decide to use integers (1, 2, 3, etc; no decimals) as my data type, I may very well pick out one too many strawberries (and then everyone behind you groans because the cashier must call the manager to have your total adjusted). Thinking critically about data is essential to writing good programs.

For now, just be aware of what metadata is. This information will make more sense in the coming lessons. Next, you'll find about simple data types (some of which you've seen here in this post).

No comments:

Post a Comment