Coding 101 46 (Transcript)

Father Robert Ballecer: On this episode of Coding 101 we’re finishing up Santa’s little helper.

Netcasts you love, from people you trust. This is TWIT. Bandwidth for Coding 101 Is provided by CacheFly. At Hi, this is Leo Laporte, and if you’d like to help us design our new website, I invite you to visit We’ve got 8 quick questions we’d like to ask you that will help to make the navigation easier to use. Thanks a lot. This episode of Coding 101 is brought to you by FreshBooks. The simple cloud accounting systems that helps entrepreneurs and small business owners save time building, and get paid faster. Join over 5 million users running their business with ease. Try it free at And by Mandrill. Mandrill is a scalable reliable and secure email infrastructure service trusted by more than 300,000 customers. Sign up at promo code TWIT and you’ll receive 50,000 free email sends per month, for your first 6 months of service.

Fr. Robert: Welcome to Coding 101, it’s the TWIT show where we let you into the wonderful world of the code monkey. I’m father Robert Ballecer, the digital Jesuit, and joining me today, my code warrior, my good friend, Mister Lou Maresca. Senior software engineer at Microsoft. Lou, thank you so much for coming back.

Lou Maresca: Thanks for having me. Hopefully I won’t scare you with the cold voice that I have today.

Fr. Robert: You’re having all sorts of issues. Your body has some sort of virus, your computer has issues and you just crashed our Skype.

Lou: Yeah, remotely somehow I crashed it. I have talent.

Fr. Robert: Go figure before we get into Santa’s Little Helper, let’s go ahead and take a look at an item that I thought programmers around the world probably should take a closer look at. This one comes to us from a blog by Kevin Williams, called the 10 Things that Annoy Programmers the Worst. It’s funny, whenever we get one of these top 10 lists, there is always going to be people that have different opinions, but these 10 are really good. Number 10 was comments that say nothing. Lou, both of us know this. We tell people comment, comment, comment, but there’s a difference between a comment that helps and a comment that just leaves you going “okay, now what?”

Lou: It’s a holy war with comments in code. A lot of people like to over comment and sometimes I like over commenting more than I like vague commenting. Because if you don’t comment and then- the ones that do the best write a design document that talks about and puts little links into the code so you can go look at the code comments too, that’s even better. But code commenting is super important so you know exactly what a piece of code is doing and what its meant to do and what its purpose is to do. And then if it’s breaking or not doing what it’s supposed to, then at least you know the original intent.

Fr. Robert: I had to work on a project a year ago and all the comments were, this is a loop. This is a counter. This resets the counter. I’m like yeah, but why is it there? That’s what that’s all about. #9 is being interrupted by coding. I kind of thought this was just petty. But then I thought about it and it’s true. Programmers usually get into a zone. It takes a while to get into the zone, you know this, you might be staring at your screen for the longest time thinking about how you’re going to do something and then you start feeling it and pumping out code and it’s all good and then someone comes in and they bother you and its normally something that’s just lame, it’s stupid, they’re wandering around asking a dumb question. And yeah, I think this applies. Are like that?

Lou: So I don’t hate it, right now I have locked my office door and there is a sign that says do not disturb, but sometimes I have to do that, because if I don’t do that, I’m doing something, I have written notes about it to keep contacts and so then someone interrupts and I’m like okay, I’ve got to answer to be nice. I talk to them and come back and I’m like what the heck was I doing? And so I think that happens all the time. I haven’t seen a tool today that can fix it. Whether it’s a link or skype or whatever that I can put that I’m busy on there. Unless I lock the door, pull my shades and turn the lights out, I’m pretty much open for business.

Fr. Robert: This next one, #8, this is near and dear to my heart. Scope creep or mission creep. And we all know this, this is that idea that as the project progresses, they’re just going to start adding on requirements. Features that they like or they see something in another app and go, you know what, and our program should do that too, with no regard for the fact that that might completely change what you were doing with the code. Of course, you’ve never run into anything like that right?

Lou: No, never. We don’t have that problem every day that I work here at all either. But one of the biggest things that you’ll see is, there’s an acronym called MVP, most viable product. And that’s one of the things that startups push very hard to do is ship a very simple thing up front, let users complain and ask for things. And then add to it. But companies, whether it’s Microsoft, Apple, Google, they never do that. And so there is always scope creep that come in and force the release dates out.

Fr. Robert: My favorite is the scope or the feature creep that happens and then they expect you not to change the release date because, we’re just asking you to add 3D features right. That’s like 2-3 lines of code, what? And then the next thing, I think this gets a little bit whiny, because this happens for everyone. This is not just coders. But having a project manager who does not code and who doesn’t understand or care about understanding about what programmers actually do. This still does exist. You won’t find this a lot at companies that are well run, but having a programming manager who cannot program is torturous. Lou, have you experienced that?

Lou: SO there is different levels of programming. Here at Microsoft we have what we call the domain experts, and then the technical leads. And so the domain experts are the ones that, for instance, I work in financial software, or business software, so ones that understand sales, financials, ledgers and accounting, those are actually still fairly good PMs that could understand the domain expertise around calculations, but they might not necessarily understand how I’m coding it or the technology behind it. So there’s a little bit of a crutch there. but they’re still fairly good PMs and so it all depends on if you’re a domain expert, if you’re a technological expert and what your project requires, and sometimes it requires both and so they’re at kind of a loss at that point.

Fr. Robert: #6 and #5 are interesting. Because they’re kind of the same thing but not. #6 was listed as being asked to document our own code, and #5 is working on code that is not documented. And I think this is absolutely a truism. I hate documenting my code. I know I have to do it, and I end up doing it because I’ve felt the pain of not having it. But I don’t want to do it. And sometimes people have to ask me to do it. And yet, if I find code that’s not documented to my liking, I think that programmer is the worst thing ever.

Lou: Yeah. Microsoft requires what we call a white paper. So when you do a project you have to do a white paper about it too. And you kind of remember the old English engineering classes I had to take in college and thinking man, I could have used a little bit more of those because I literally have to write a document that customers have to read about my code. And it’s sometimes difficult to do.

Fr. Robert: #4 is an interesting one, because I’m more of a hardware guy, but hardware generated faults. Specifically errors that are generated because we’re running code. Especially like beta code, on janky hardware, is a pet peeve. I’ve actually seen this a lot where we’re running on prerelease hardware and we get change logs back saying well, it doesn’t work on XXY that’s going to be released next year. I’m thinking, is that a finished version? Then why do I care? If you can’t show me something that they say is stable, why am I going to change my code to accommodate them? #3, vagueness. You know this one. In fact, anyone in IT knows this one. You don’t have to be a programmer. That idea of its broken. What’s wrong with it? It just doesn’t work right. Okay, can you tell me what happened? It didn’t do what I wanted it to do. That’s- yeah, you see that a lot I think. #2, other people. I think programmers, as a rule of thumb, we don’t like other programmers. We may understand that other programmers are necessary, but Lou, again, I’m going to throw you on the tracks here, do you sometimes feel as if the world would be better if everyone just programmed like you?

Lou: Honestly, I only stay on teams if I have someone who is better than I am. That’s the truth. It makes me better anyways. If I’m not on a team where I can learn from somebody, then I normally jump off that team. That’s the rule I follow. But I do agree, sometimes you work with programmers that just don’t have the skill, maybe they’re just getting started and they cause some issues, some delays. And it does cause some problems with our code too. So it’s kind of a balancing act.

Fr. Robert: And the #1 from this posting and yeah, this is true, my code. 6 months later, I think every programmer has had this moment where they’ll look back at a project they started and go what was I thinking? This is not elegant, this is not good, and I should rewrite all of this. Of course this happens a lot, but never at the corporate level, right Lou?

Lou: Honestly, I’ve had emails from people, I’ve been here 11 years, I’ve had emails from people, they’ll be like, you wrote this, and can you help us fix this? And it’s like 11 year old code. So I have that all the time, don’t worry about that.

Fr. Robert: Now other potentials that weren’t listed in the blog, actually my #4 was that exactly. Answering questions about my code, especially if its code I can’t remember. I almost feel shame whenever someone says “your code is breaking this and we don’t know why, you wrote this, you can tell us what it does?” And I normally don’t have an answer. I also hate old repositories with really bad revision keeping. That tend to want us to – projects. That’s been a pet peeve of mine. One other thing is, and I’ve seen this in the valley recently, star programmers who are brought into a project, who don’t seem to ever want to program. They do all the high level thinking and then they leave it to the peons to turn that into code. What pet peeves do you have Lou?

Lou: I think that is one of them. Where they’ll come up with a really complex design, they never communicate with the team, and then they go and say “here’s the design, go and code it”, and then you really have no idea where to even start. And the second one is if I go to a developer and they wrote the code but there is no comments, there’s no tests, it doesn’t even necessarily compile sometimes. And you ask them what they were even thinking and they have no idea. And so there are those 2 things that can cause some huge blips in a project you could say.

Fr. Robert: Well Lou, we’re going to try to stay away from all of those errors when we get back into Santa’s Little Helper. Today we’re going to be finishing up the project, people have received all the code and all the code snippets they need to be able to access those APIs from Best Buy and New Egg, do a little bit of screen scraping if you will. But today you’re going to show them how to wrap all of that in a nice UI. Am I right?

Lou: That’s right. And we’re also going to go and show you how to use what we call a local database to save the data so that when you open the app every time you don’t always have to go and get the data and it can kind of show historical data as well.

Fr. Robert: Fantastic. But before we get to that, let’s take a break for our first sponsor. If you run a small business, if you run a SMB, if you run it out of your home or if you are an upstart who is looking for a little bit of help, but you still like that pioneering spirit, there is nothing like a helping hand with finances. That’s why we’re happy to welcome FreshBooks to Coding 101. What is FreshBooks? FreshBooks is the cloud accounting software designed from the ground up for entrepreneurs and small businesses. I’ve actually used this at a couple of our organizations around the country whenever they need billing. Now billing is troublesome and normally requires an accountant and you’ve always got errors when you’re entering numbers. Not with FreshBooks. What FreshBooks allows you to do is to generate professional looking invoices. To automatically bill customers and automatically enter in numbers into your accounting software. In other words, it’s like having an accounting department in the cloud. FreshBooks is built for a growing business and on average FreshBooks customers double their revenue in the first 24 months and get paid an average of 5 days faster. Figure that. 5 days extra with the cash that you deserve. Are you still using Word or Excel or Google Docs to create invoices? I’ll admit, I was doing that for the longest time. FreshBooks is the easiest way to create professional looking invoices in minutes so you don’t get an invoice that looks like it was scribbled on the back of a piece of a paper. Now you get to avoid those awquard emails and phone calls to your late paying clients. Because FreshBooks does it for you. They have automated late payment reminders that let you set a way to get paid on time. Worry free. Now you can set up recurring profiles so you can put your billing on autopilot and FreshBooks customers spend less time on paperwork. Freeing up to 2 days per month to focus on the work that they love instead of the numbers that they detest. Now do you still keep your receipts stuffed in your wallet to keep track of expenses? Do you snap photos of your receipts right after your phone and instantly capture expenses? That’s what FreshBooks is for. It lets you record billable hours and track your time with multiple rates. FreshBooks integrates with your apps like Google Apps, PayPal, Stripe, Mail Chimp, Fun Box, and Zen Payroll. FreshBooks even has an open API so developers can integrate with the FreshBooks platform and make everything nice and neat. If you ever need help you’ll talk to a real person every time. FreshBooks’ award winning support is ready to help and software is free forever. Now Amber McArthur of BNN’s App Central says “FreshBooks mobile allows me to quickly send invoices and check in on my business no matter where I am.” There’s no reason for you to not try it. Here is what we want you to do. We want you to try FreshBooks free for 30 days with no obligation and see if maybe it helps change the way that you do business. Go to and enter coding 101 in the how did you hear about us section when signing up. Start your 30 day free trial today. Go to and don’t forget to enter coding 101 in the how did you hear about us section to throw some support to coding 101. We thank FreshBooks for their support of this episode of Coding 101. Lou, let’s go ahead and get into the nitty gritty. Now we have given all of our audience the code so they can access the APIs of these different vendors and look for particular product. But that’s just the start. That just gives us the back end. It gets the information into our software but as we’ve learned from previous modules, we still need a way to present that view to the user that is useable. Where do we start?

Lou: So I think we should start from a bottom up approach, so we basically talked about the providers that we were able to go get the data. In the projects you have several providers. I give you Amazon, New Egg, Best Buy, Sam’s Club, Target, Walmart provider. By the way, there was a bug in the Walmart provider and I’m sorry about that, I did fix it and we’ll give you the latest code to get that fixed. But basically these all just get the data, they’ll return it back and then you just get this big blob of data. So I think that in the project we gave you a console app that basically allowed you to copy and paste a URL in there and you’d run it and it’d go and get the data and it would output for all the different providers, whatever. The whole idea for this app is for you to be able to track prices, maybe even cross retailers. So the way to do that is you want to be able to save this data, whether it’s on a flat file, on your hard disk, or within what we call a relational database that allows me to query the data out of it. And do there is a really cool embeddable relational database called Sequel Light. Which you can actually get if you go to your famous nugget packages and you can actually type in and it will allow you to actually embed a Sequel Light database. So it will save it in your local app data so you notice this is my local app data folder. There should be a TWIT folder that it’ll create. And if I jump in here, Santa’s Little Helper version 1, you’ll see an actual product sequal.lightDB file. And so this is actually real tiny. Its only 3 kilobits, it’s got maybe 100 items in it right now. But it’ll basically create an embeddable database for you and all you have to do is add this project to it.

Fr. Robert: Also, I’d like to say, if you want to know more about nugget, I believe you can check out episode 39 and 40 of Coding 101. It’s the last C Sharp module. It’s a fantastic tool that allows you to bring in things like this new repository. Also, remember that the code that we’re showing you gets that blob. Remember that JSON blob that we were talking about? And you have a utility link in the last episode of Coding 101 that will let you turn that JSON blob into unique fields which will then be put into this database that Lou is now showing you how to set up.

Lou: Exactly right. So let’s go ahead and do that. I’ll go ahead and put a break point here. Let’s do like another New Egg one really fast. So stick one right here and I do like kind of stepping through things. So I’ll go ahead and hit go. And here it hits the New Egg provider because I copied and pasted a New Egg URL. And if I step into that it’ll actually step in and say give me the price and so it’ll go in and retrieve the price internally. And then the blob that you’re going to get is the last thing that gets back here. So we get all the way to the bottom and make the call here. And the response should come back and the response was successful. And if we look inside here there is this big blob of JSON that comes back.

Fr. Robert: We can parse that. Exactly. So this is the blob. The JSON blob. We parse this so we can pull out the individual fields so that we can compare data against other JSON blobs.

Lou: That’s right. So what I normally do is I use what we call the JSON serializer and what it can do is it can create what we call strongly typed objects. And that would mean create an object and then I can pull the information off of it without having to go and do any additional work on it. And so you notice in here I have this new object called search result and if I can look inside I see that it has a bunch of properties. And this might be a little small for everybody, but what you can see is I can get product details and keep drilling down until I finally find the price. And so this way I don’t have to sift through that entire string and use a bunch of regular expressions or whatever to kind of sift through the data, I can just use .net and it’s object providers to basically get the data off of it. So now what we want to do is save this data. So I’m going to return this back. I’m going to pop back out to the provider code that I had here and-

Fr. Robert: Actually, before you do that, do you have a way to bring up the JSON file after its been parsed? Because that’s always a nice before and after. So they see the blob-

Lou: To be honest with you, the serializer, what it does, it does it at a binary level. So there’s not much I can actually pull up.

Fr. Robert: There is, it just wouldn’t look like anything.


Lou: It wouldn’t look like anything, right. So it’ll just match, it’ll do a bunch of hash set matchings and it’ll basically convert that into an object rather than just show you a big blob. That’s basically what it’s doing.

Fr. Robert: Nice.

Lou: Basically what I did was, then I returned this retail product object. It’s something that I created a while ago and it has a bunch of properties on it like title and price and image. And that’s common amongst all the retailers. So I created this so this way I can kind of bind that later. So that’s what I’m returning in all of the different provider codes, this Newegg one is going to return this price object. If I look inside you’ll notice that it has the 4k television that I asked for, New Egg’s ID, of course it came from New Egg, and then the price that they have for it right now. So I’m going to pop back out, this is what we call my item search view model and so when you’re writing a UI- we talked about this in one of the past episodes, the MVVM concept. Where you have a model, the view model, and so this is what we call our item search view model. This is how I’m going to get the data from the provider, which is my model. And then I’m going to present it to the user UI somehow.

Fr. Robert: Right. And of course that’s only possible because you’ve already worked with the JSON file to turn it into useable data. Because you can’t present the blob, it won’t look like anything. But now that we’ve serialized it, you can pull specific fields that are actually useable. Like name of product and price and vendor.

Lou: And honestly that’s the bulk of the work. I’m not going to pretend to be the best UI person, UIs take me months to get it correct, but the bulk of the logic, the complexity of the logic is really in getting that data from these providers. And so once you have that, which we do, now we need to know how I’m going to present that usefully to a user. And how am I going to save that so when I later open the app, how can I see the historical if I’ve already saved that item once before? So that’s what we’ve got to go into next is how we want to save that data so we can look it at, what we have from once before.

Fr. Robert: Exactly. Because you can’t expect to pull all this data every single time you make a query. You want some way to store it all locally in a fashion that makes sense, so of course, you’re going to store it in….

Lou: Right. So we’re storing in a database. So we create a wrapper class, I like to call retail product storage. What it does is if you look inside here, the first thing it’s going to do is call load database. And it’s got some coding here, but luckily has really good documentation. But all you’re really doing is creating a connection to the database, I’m using my local storage path. That was that path that I showed you here that’s within my, this is my user name and then my app data local. And this is just something if you’re on a Windows machine, it will be available for all users who log in. it’s the app local data storage. And its only available to you as the user, nobody else can access that, unless you’re an admin. And so I’m just using that path and then I’m just calling this, this is the name of the sequel database. And then I create a connection. And once I create the connection, boom, the database gets created. And then I have to create this table. And so this is the hard part because if you’re not really familiar with databases it might be difficult to create tables. But there is a work around. There is always tools for everything. And there is a really cool tool called a sequel light toolbox. And it’s this really neat UI that allows you to basically build a table just by using a UI. It’s like building an Excel spreadsheet, and you can build a table and like I have ID, I could put retail ID, I could put title, and this could be text. And I could basically build up a table here and then I can hit save or script and it will generate a script for me. And then once I hit the script button it’ll generate a script and this is the script that it’ll actually generate for you is this create table script. And you notice inside here I have the retail unique ID, the ID of the item, the retailer, the image of the item, product URL, when it was created and when it was modified.

Fr. Robert: Wait, is that part of the plug in or part of the visual environment itself?

Lou: That’s part of the plug in. so the plug in will allow you to basically create the script, and then you just copy and paste the script from the tool into your code. Really simple. It’ll actually create the tool for you. This is a connect to the sequel database here, and you notice I actually have retail products table here. And then of course here are all the different columns in that table. And I can actually right click and go select, and now I can query that table, execute this. You notice now I have a result of that New Egg item that got put in there. So fairly simple and there’s tools to do it so you don’t have to actually know how to write sequel code or Tsequel code or whatever to do it. And it will create the table for you.

Fr. Robert: Okay, so this is creating the table based on what we’re receiving from the JSON blobs after they’ve been serialized, but how do we then push the data into the tables that we’ve just created?

Lou: Good question. So now we’re going to use the same tool, and I’m going to go right click on it and go select script as an insert. And so what it’s going to do here is generate a script for me. You notice it has insert statement here that then has a bunch of values. And so here’s the key here. You need to basically erase this and we’re going to put in these place holders. For you put in place holders. So p1 is the parameter for the unique ID, p2 would be the ID and so on and so forth. And you just keep replacing it with a bunch of place holders for the parameters. And then you copy and paste this back over here and we’ll go up to my retail product storage. And I put in a save product method and then here is my insert. This is what I copied and pasted over and you’ll notice that I just replaced those parameters with a bunch of place holders.

Fr. Robert: Now we’ve got a couple people in the chatroom who are freaking out. Like wait a minute, we haven’t covered databases yet. We know, we’re not doing a through tutorial on database management just yet, just take the code as it is. At the end of every module we want to leave you a little challenge, this is the challenge. You’re going to have it working. The code will actually work and then you can play around so you can figure out exactly how the database functions work. This is just simply a place to put the data that we’ve been pulling from the websites in that JSON blob, serializing and then storing so that we can compare them against other values. That’s all we’re doing. Just think of it as that and think of the code as sort of a black box at the moment.

Lou: Basically all we’re doing then thereafter is we’re taking these place holders, what we call tokenizers, tokens, and we’re basically using this special command object that you get with, it’s called sequellight.command and it allows you to put in the script that you want to insert with, and then it allows you to use what they call a command builder and you basically bind the parameter to the data. So you notice here that my property that I’m sending in here to this method is called product. And again, it’s my retail product that has all the different properties of retail product, and then I’m just binding the data that gets sent in to the parameters. Fairly straight forward once you get the hang of it. And then the last thing I’m doing is executing the query and committing it to the database. And that’s all you have to do to save it off and make sure that you have it for later.

Fr. Robert: And of course the reason why we’re doing it this way, because I can already hear the wheels turning of people saying well, if it’s just a bunch of values why don’t I just set up a bunch of variables to store the values? We want to make it easier. We want to make the functionality easier as we go into the view part of the programming. Because remember, just presenting the data is useless. We want to be able to compare and databases are fantastic at comparing.

Lou: Also if you save everything in memory, after you shut the app down it’s gone. And another thing is a lot of people say why you don’t save it in a flat file like a text file or something. Just think, over a year, how many products do you look at? Do you track a lot of products? It could be thousands of products and that means that now you have to parse this text file for all thousand products every time you load the app up and when you parse text files sometimes you have to do it in memory and so now you have a memory problem. It just gets to be old. The better thing to do is save it in some kind of data storage mechanism where you can stream from it and that’s where the database comes in.

Fr. Robert: Right. The way we look at it, yes, it’s more complicated, but you can either cludge together a way to store the data, or you can store it into a framework that’s designed to store data. And one is clearly better than the other, even though it does take more effort.

Lou: That’s right. So now I guess once we store it off we can basically decide on whether we want to store it and how we want to present it to the user. So the next thing I want to do is determine how I want to present it to the user. So what I started to do was I built what we call a product search control. And what this is, is just- think of a list box with a whole bunch of products in it and this is just a placeholder image right now. But it’ll actually have different components to it. It’ll have a placeholder image, and then the price over here, and then the minimum price of the item, the title and what retailer it came from. And so this’ll be a big list and it’ll have an image of the item and it’ll basically be able to tell me what the price has been, what it is now and what it’s been. So I basically just built a very simple XAML control that can do that. If I actually minimize all this you can see, the XAML code is only maybe 15 lines long. So I’ve basically created a line item that will have an image of the item and then all the information for it.

Fr. Robert: If any of you are freaking out with this, take a look at Coding 101 modules 1 and 4 because we actually look at this design. Essentially we’ve already written all the code. We’ve got all the features baked into the bottom, we’re just going to copy and paste, we’re going to drop it out a little item so that they can trigger actions.

Lou: Right. so there is also a lot of code backing this too, so for instance I have a product search view model that has the image, the minimum price, and these are all properties that again, I think we talked about this in one of the later episodes that talked about the identify property change event, which means that anything that changes in the view model, it will basically go and fire an event to the UI to go get the new data. And then it’ll go and update that data. So the UI is now bound to this special view model that I created. Again, it has these properties in here.

Fr. Robert: We’re heading into the home stretch here. We’re going to start talking about how we’re going to create the binding so that we have nice two way, bi directional control of the data that we’re presenting to the user, but before we do that, let’s go ahead and take a break to talk about the second sponsor of this episode of Coding 101 and its Mandrill. What is Mandrill? If you are in a small to medium business, if you’re in an enterprise, you want an infrastructure service that’s trusted by the industry. That’s what Mandrill is. It’s an easy to integrate, scalable, reliable, and secure, email infrastructure service that’s trusted by more than 300,000 customers. You get to integrate, deliver, track and analyze your emails as they move through your system. And Mandrill gives you detailed delivery reports, advanced analytics and a friendly interface that means your entire team from developers to marketers can monitor and evaluate your email performance. With servers all over the world, Mandrill can deliver your email in seconds. Not only that, but they’ve got multiple ways to deliver your messages so that you’re always making sure that your messages get out in a timely manner. You don’t have a lot of stuff that gets queued up and sent out hours, days, even weeks later. But Mandrill will make sure that your message gets out when you intend it to. Mandrill started as an idea back in 2010. They’re growing fast and integrating faster, Mandrill is now the largest email as a survive platform on the market. You can use Mandrill to send automated one to one emails like password resets and welcome messages, as well as marketing emails and customized newsletters. Mandrill made it for developers, and developers love documentation. And Mandrill definitely gives those developers that documentation that they need for easy integration, for high delivery rates and all the web hooks they need to make sure that it’s going to work with your existing software. It comes with a beautiful interface, flexible template options, custom tagging and advanced tracking and reports. Mandrill is the only email infrastructure service with a mobile app that lets you monitor delivery and troubleshoot from wherever you are. It’s powerful and saleable and affordable. And we know this because we’ve actually used Mandrill. But you don’t have to take our word for it. Right now Mandrill is offering the TWIT audience a special deal. Sign up at, promo code TWIT, and you’ll receive 50,000 free email sends per month for your first 6 months of service. That’s promo code TWIT. promo code TWIT. And we thank Mandrill for their support of Coding 101. Lou, take us home. We’ve got the data. We’ve got it in a database. How is it going to look?

Lou: Let’s show it. Let’s show the user data. The first thing we have to do is bind the data that we got to the UI. So what you have to do, you have to set up a Windows resources to do that. By setting up a view model mechanism. So the view model mechanism, is you just use a Windows resource and again, there is some documentation on this online, but all you do is set up a data source or a static source for it. And then what I can do down here then Is I can look at every time I want to bind, let’s say I want to bind the text box, or I want to bind the actual text box content to my URL. And so if you look over here, the binding says the text of the text box binds to my URL text property. If I pop over here to the view model. I have a URL text property, there it is. And I basically bind that view model to it. And so I bind it and I do it in a two way, meaning if something changes in code, it will update in the UI. And if something changes in the UI, it will update in the code. And so that’s kind of the key, basically all I’m doing is setting up the binding. The coolest thing behind this though, look at the code behind for this file. That’s it.

Fr. Robert: Ha, ha, ha. We love this, this is your super advanced program, this is what it would look like and everything is basically just includes.

Lou: Missing, exactly right. So this is what we call declarative programming, this means that we declare everything in the UI, bind it to the view model and it’s kind of a disconnected environment. So let’s see what we can see here. This might be a little small because I can’t zoom. So you’ve got a little URL box here and I can basically paste in the URL and if we go- I’ll put a little break point in here so we can see what’s going on under the covers. I’ll go to the IM search, there’s a break point there already. Pop back over, I’m going to hit the search button and boom. So now you notice that the URL text right now is the URL that I put in the text box. And now it says okay go find – so I’m using the current code that I have to go and search. And boom, I get the provider, retailer, boom, calls out to the service, returns in a second. There it is. Then is it going to save it to the database first? Yes, it’ll save to the database. Now it’s saved. And then we should see a line item in the UL. Oh, we don’t. But it could be the binding problem that I have. This is one of the later releases that I had. Basically what you should see is you’ll see this search control right here with the image and then the title and the actual description of the item. That’s what normally will happen. But at least we can go look at the database real quick just to see if it showed up in there.

Fr. Robert: This is the simple part, making the items in the database appear in the view. And it’s just not bound properly at the moment.

Lou: It’s just not bound properly. Instead of playing with it we can just show you where the data is right here. So just to make sure it works –there it is. There’s the 2nd line, Samsung 40in television, boom it’s in there. So it’s storing the data. So now if I were to shut the app down, close the app and then restart it, I can basically just pull the data directly from the database rather than having to go and call the New Egg service again and then get in trouble for calling on them too much.

Fr. Robert: That’s absolutely fantastic. And as you go, you can build up the database of the items and prices and descriptions inside your Santa’s Little Helper database. And this is the whole idea. Over time you will gradually work up the inventory of products that you would like to keep an eye on.

Lou: Right. and we talk about scope creep, I guess the idea that I had was I would show you this really neat line graph of the trending of that item and there could be a whole bunch of things I could do for you but again, I wanted to give you a framework on the basic concepts of how to bind the things and how to set up the UI and do list items, how to do sequel light database, how to call the complex services, and then you can always add features after that on top of it.

Fr. Robert: Right. Well Lou, how about this. The code is done. This will work as it is, as we just have to bind it. What if we were to bring you back for one more episode and let’s just take what we’ve got and make it pretty?

Lou: Yeah, let’s do it. I’ll have to pull in a designer to help me though.

Fr. Robert: Yeah, I’m horrible at UI design. I’m fine with a couple of boxes, and someone else will come in and say no, no, you have to have this bigger and this should be a different color, and then it does get beautiful. Lou Maresca, Senior Software Engineer at Microsoft, thank you so very much. Your example will be available, people can click on the link and download the assets. So again, if you don’t understand what we were talking about, get the asset file and scroll through it. Be with us as Lou is taking us through the program because then it makes a lot more sense. Also, if you do understand what we’re doing and you understand that this is just a binding problem, why not give us examples of what you do with Santa’s Little Helper and make sure that it ends up on our G+ page. Lou, could you tell the folks at home where they can find you, your work and where they can find Lou Maresca in the real world?

Lou: You bet. So of course @LouMM on twitter, Lou MM on About Me and of course all my work that I’ve been working on tirelessly, which is why I was late today, is on, check it out.

Fr. Robert: Fantastic. Lou Maresca, it is always a pleasure, thank you for being part of Coding 101. You are a master. A code warrior.

Lou: Thank you for having me Padre, appreciate it. Love it.

Fr. Robert: Don’t forget that you can always get the notes for all of our episodes at our show page. Go to Not only will you be able to find all of our episodes, and this is important if you want to get the references from the earlier modules, but you’ll also find a way to get all of our episodes automatically onto your device of choice. Also, you need to join our G+ group, it’s where you’re going to get your questions answered. Go to There you’ll be able to join the community, answer questions if you’re an expert and make sure everything works just fine. Find me on twitter, That’s @padresj. If you follow me you’ll find out what we’re doing in every episode as well as what I do when I’m not here on the TWIT TV network or when I’m doing the other shows I do on the TWIT TV network. We do our show live every Thursday at 1:30pm pacific time. You can find us at and you can join our chatroom at And ill answer your questions from the chatroom as the show goes on. I want to thank everyone here at the brick house who makes this show possible. Leo, Lisa, to my super-duper fantastic TD, Mister Bryan Burnett.

Bryan Burnett: Yeah, what a toss. Find me doing Know How earlier with you on Thursdays 11am Pacific Time. And quad copters. My new baby. Check out Know How and follow me on twitter, @Cranky_Hippo.

Fr. Robert: Thank you so much for watching. I’m father Robert Ballecer, the digital Jesuit. End of line!

All Transcripts posts