Anatomy of an example

Sometimes someone asks me a question that leads to an interesting example that I post here. Usually I have to think of something interesting myself. Occasionally that leads to a new idea, which leads to a new idea, and so on.

This time I thought I would write an example that sends a SMS (Short Message Service) text message. I knew that you could do that by sending an email to the appropriate address. That lead to two threads of research: sending an email (which is a bit of a hassle) and finding the format of the necessary email address.

The email address depends on the intended recipient's phone number and carrier so I went online to try to find a list of the carriers' SMS gateway email addresses. Wikipedia has a decent list but it's in the form of a table that would require a lot of manual retyping to use. Eventually I found a much better list at https://github.com/cubiclesoft/email_sms_mms_gateways.

That gateway list is updated reasonably frequently (as I write this, the last update was 25 days ago) so that lead to a new topic: how to download a file whenever a program starts so it can use the latest version of the file.

The gateway file is also stored in JSON (JavaScript object notation) format so that lead to the final topic for this example: JSON. Or actually the final two topics. JSON is a data storage format with a purpose similar to that of XML (eXtensible Markup Language). One of the easier ways to use either XML or JSON is to serialize and deserialize objects. So that's the first topic: how to use JSON to serialize and deserialize objects.

Unfortunately the SMS gateway file contains a fairly long and complicated pile of data and the file's web site doesn't provide a definition for a class into which a program could deserialize the data. That leads to the final (really) topic in the series: how to read JSON data when you don't really understand or care about all of the data.

So from this one idea, to send an SMS message, came the following topics:

So I'll be posting these examples in the next several days.

Meanwhile my latest book is finally available:

MCSD Certification Toolkit (Exam 70-483): Programming in C#
By Tiberiu Covaci, Rod Stephens, Vincent Varallo, and Gerry O'Brien
$59.99, 648 pages, May 2012
ASIN: B00CP2PZB0

The link above is for the paperback edition, but a Kindle edition is also available.

To help get some reviews going, I'll announce a drawing for five free copies of this book in the next few days. Stay tuned...

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.