Transcripts

Coding 101 33 (Transcript)

Shannon Morse: Today on Coding 101, don’t be scurred, because we got your classes, right here.

Netcasts you love, From people you trust. This is TWiT! Bandwidth for Coding 101 is provided by Cachefly; at C-A-C-H-E-F-L-Y dot com.

Fr. Robert Ballecer, SJ: Welcome to Coding 101, it’s the Twit show where we bring you into the wonderful world of the code monkey; I’m Father Robert Ballecer.

Shannon: And I’m Shannon Morse and for the next thirty minutes we’re going to get you all learned-ed up on everything you need to know to be a C# code warrior.

Fr. Robert: Wooot! I prefer code monkey, but you know, some people could be code warriors.

Shannon: I’m going to make these people warriors!

Fr. Robert: Warriors! That’s right.

Shannon: I’m going to have an army of coders.

Fr. Robert: That’s actually kind of scary. I’m not really big on that. Now Shannon, people have been getting a little freaked out. We’ve seen this in the feedback, we’ve seen this in the group, there are some people who are like, “I still don’t understand why we’re doing this, why do we have to go into classes, why do we have to talk about abstract classes?”

Shannon: I don’t blame them.

Fr. Robert: And I don’t blame them, because it can be a little scurry, but we’re going to bring you all through some basic examples, we’re going to bring you back to module one of C#, and explain why this isn’t really any different than what you have been doing.

Shannon: I’ll be honest, when I was writing my code for this episode I was like, “Why am I doing the abstract classes?”

Fr. Robert: Yup.

Shannon: But I still did it, and I understand the functionality of it, it’s just very hard for me to figure out why I would use it. But I think that’s part of the problem solving part of programming is finding out why you would actually use certain things like abstract classes.

Fr. Robert: Precisely, and that’s why we want to sort of slam on the breaks here, back up, slow down, show you a couple more examples, and then explain, “This is why this is important.” I think one of the problems we are running into is classes, abstract classes and interfaces really become useful when you start running, creating much larger programs.

Shannon: Yes.

Fr. Robert: We’re writing very basic programs, which makes it difficult to see where it would come into play, but I’m betting that we’re going to show you this week why this is the way you want to program.

Shannon: Yea! Well before we get started, can I do a little bit of Snubs Compiles?

Fr. Robert: I think so. Let’s go compile some Snubs.

Shannon: Alright, well hopefully you got my computer. I forgot to check beforehand. Oh, that’s not my computer; that’s it! Yea! So on my computer over here I created a new program. Under here you’ll just see a little bit of code, and then over here, I had created a new class. So if you remember previously, creating a class, you right click on “Snubs episode three,” or whatever your program is called, go down to “add new,” and then go down to “class.” And then you add whatever, however many classes you want. So this is the class I created, and you’ll notice right here I made it public, so I can use it throughout the program.

Fr. Robert: Correct.

Shannon: Abstract, so that I know that it is basically a drawing, an idea for my entire code.

Fr. Robert: Right, and actually-

Shannon: That’s how I explain it, it’s an idea.

Fr. Robert: It’s an idea. That’s actually a very good thing, because remember, a class is like a blueprint, but a blueprint spells out exactly what you are going to build.

Shannon: Yes.

Fr. Robert: An abstract, her perfect analogy is just an idea. It’s like saying, “Well, I kind of know I want the building to look like this.”

Shannon: Yeah.

Fr. Robert: “I have no idea what is going to go in there, but I want to make sure it has floors, it has windows, it has ceilings,” That’s it, right? And then you have to fill in the blanks later on.

Shannon: Exactly. So back on my code, I created to just make an abstract class called “food.” Well what is derived from “food?” you have veggies, you have fruits, you have meats, you have dairy products, so then under it I created a public called “virtual string type of food.” And this is the one that’s going to be get and setted, that’s how I like to explain that part, and then I also had an abstract one called “enter you food,” so this is where if I was creating something were a person had to enter the type of food that they were buying, they could put in, “okay, I’m buying a pumpkin,” or whatever.

Fr. Robert: Right.

Shannon: And then under that I also had one that posts a message so this is similar to what Lou had showed us last week, where he did a social network one, and depending on if you have Twitter, or Facebook, or whatever, it could post some certain kind of message if you needed it to pop out a message to the public, to all the consumers, or what have you. So in mine I just left that the same and then under that I had one that would return the type of food that a person actually bought. So this is very abstract, obviously.

Fr. Robert: Right.

Shannon: It’s just an idea of the many things I could do; I could create this into a point of sale system, so that every time someone enters a barcode, for example, it pops out whatever kind of discount you get for that certain kind of food.

Fr. Robert:  But it’s still vital because remember, when we start teaching programming, we really don’t care about the code. The code is just syntax. What we are trying to do is teach concepts. And the concept here is break down the problem into little chunks that you can actually solve.

Shannon: Yes.

Fr. Robert: And in your case, you created an abstract class, so there’s; go back to her screen. If you look, in these methods, there is no nothing.

Shannon: There is nothing there, just a whole bunch of comments.

Fr. Robert: Right. So I know that I’m going to have those four methods. They are going to be part of my class. They are going to have to be what’s called instantiated. They are going to have to be fully developed before they can be instantiated. This allows me to solve this tiny little chunk.

Shannon: Exactly.

Fr. Robert: What’s the problem here? The problem is I need to have something that tells me the type of food, the name of the food,

Shannon: Yes.

Fr. Robert: What I do with the food, and…

Shannon: There you go. You could change this to like, recipes, and it will pop out a bunch of different recipes that I want to use, or the cost of it, or whatever. And then down here I created a “Type of Food” called “Veggie.” And this one is a public class so this is not abstract so I had to add in some kind of code down here to actually do something.

Fr. Robert: Right. Because remember, the abstract did not include what was actually in these methods. So what you’ve done now, by overriding, you’ve said, “Okay, you know that thing that you gave me before? This is what actually goes inside of it.”

Shannon: And it doesn’t necessarily have to have all the other different ones in here, because it’s an abstract class that I started with. So I can just include the override bool one, so I override that and tell it to return he type of food or whatever. So it could do whatever I wanted it to. And then over here in program, you go over here and go “class program,” and then after that I have “food, number one, new veggie.” So I could make a whole bunch of different ones under here, all for new vegetables, or I could create a new class under my class under here and make it “fruits,” and then I could put a whole bunch of different fruits in my program, etcetera, etcetera, etcetera. It could go on and on.

Fr. Robert: This is actually important; remember this form lesson one of this module; this is how you create and instance, an object of the class, so “food,” which was the name of the abstract class, “Num1.” “Num1” is going to be the pointer. It says, “This is where it is going to exist.” So I’m calling it “Num1,” is equal to “new,” which is a keyword, it means a “new instance, new object” based on “veggie,” which you created from “food.”

Shannon: Exactly. And from here I could have them enter a kind of food, and I could have it pop out a return console right line when it says something back to me because this is a console application, I could have it do pretty much whatever I wanted it to in here, as long as it’s working off of this abstract class that I started with, this idea.

Fr. Robert: Yeah.

Shannon: Pretty cool.

Fr. Robert: But the nice thing is the coding. So the coding for the class happens in a different screen.

Shannon: Yeah. So it’s very organized.

Fr. Robert: Its super organized, right? Now folks, this is where it gets really, really cool, and that is…

Shannon: And confusing.

Fr. Robert: And confusing. If I’m solving a problem; let’s say I wanted to make a calculator. I need one class that solves for division. I need one class that solves for multiplication. I need one class that does subtraction and addition. May be I start building some classes based on some of the more advance mathematical concepts. Now that I’ve got those built, I can us them in my main program without having to rewrite those methods. I just pull it in, and say, “Okay, I’m going to use it in this way, I’m going to inherit these things, and this is going to be my object.

Shannon: So cool.

Fr. Robert: Very cool. Are you going to show us what it does?

Shannon: Oh well, it doesn’t really do anything. I didn’t set it up to actually do anything.

Fr. Robert: Right, right, you just built it.

Shannon: When I ran it, I built it, it didn’t have any errors, so I know it was written correctly, but after this I could make it do whatever I wanted it to.

Fr. Robert: As (Unintelligible) says, “The human class inherits from the monkey class.” Yeah, okay sure, that works.

Shannon: So true. Okay so I also had an example brought in from our Google Plus Community, and this is from Nathan. Nathan decided to write something that will give you answers to a Fibonacci sequence. So, pretty cool. So he was talking, he was the one who was talking about you need to understand problem solving to be a good programmer. This doesn’t necessarily have any class infrastructure in it, other than the main one that is included when you first create a program in C#. So if I built this, and then I hit “start,” you’ll notice that it starts with a small number and then it goes up and up to a certain number at the end. Now I’ll show you the problem that he shows us online, he actually linked to an example; not the right one, there we go. So he says, “Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with one and two, the first ten terms will be as such.” So, the question in here is: “By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even valued terms.” So that’s the whole problem solving thing that we are getting into.

Fr. Robert: Right.

Shannon: So that’s a really good example, then he also adds at the very bottom; ha that’s my friend Jeff. Break all the things! Yeah! So down at the bottom, here we go, okay, he says he has a challenge for newcomers. This is a good one for you guys, if you can figure it out. Below is a link to the code on GitHub, which is what I just showed you, edit the program so that it will generate and add the even values of the sequence all the way up to four billion.  I’ll give you a hint: it’s easy, but not as easy as changing the upper limit variable. You might notice int will stop at a certain value. Hmmm, interesting. So good luck with that, guys, and you can also find that over in the Google Plus Community if you want to give it a try. And the last thing I want to share with you today for the Snubs Compiled segment is another thing linked by Mister Nathan and he said, “Check this out. I was up all night coding so I’ll just leave this here here, tonight I feel like all these language weapons are pointed at me.” So if programming languages were weapons; so let’s find one that we have done. Here’s Perl. “It was probably useful once, but few people use it now.”

Fr. Robert: Perl, it spreads out and causes a lot of damage.

Shannon: And then we have...java script is pretty funny. Is a sword without a hilt.

Fr. Robert: Yeah, you could cut yourself. I can deal with that.

Shannon: Let’s see. “Python: double barrel shotgun only one barrel will shoot at a time. And you never end up shooting the recommended one.”

Fr. Robert: Also, you’ll never actually hit the target.

Shannon:  And we also have C# in here. Here we go, so I like this one: “C# is a powerful laser rifle strapped to a donkey. When taken off the donkey, the laser doesn’t seem to work as well.”

Fr. Robert: Yeah, okay, I’ll buy that.

Shannon: All in jest, of course, but very hilarious.

Fr. Robert: Well it’s important for programmers to have humor.

Shannon: Oh yes, I so agree. This was very cute, so thank you, Nathan, for sharing everything. You are one of my favorite code warriors of the week, from our Google Plus Community, and if you guys want to join, you can go over to bit dot LY slash TWiT coding one zero one, and feel free to join over there we have over fourteen hundred members now. Yea!

Fr. Robert: Now we need to get into the ivory tower, but in a slightly different ivory tower. I don’t want to spend a lot of time because I want to give as much time as possible to our code warrior, to Lou Maresca. But I do wan tot recap some of the things that we talked about, because people have been freaking out. We’ve been receiving emails from people saying, “We don’t understand why you are making us learn this.” Or, “Is this the right time to learn this?” Well okay. We know that a class is a blueprint, we’ve talked about this, in fact we just did. The blueprint spells out what you are going to create. Now remember a class doesn’t actually exist until something instantiates it, turns it into an object, and we just showed you how to do that, the new keyword. Now an abstract class is going to be like a blueprint, but it misses all the interior details. You are just trying to show the structure of the thing.

Shannon: Right.

Fr. Robert: An interface goes one step further and it is just the outline, there are no methods, no nothing. In other words, it absolutely cannot be instantiated unless you write the entire program.

Shannon: And Lou showed us an interface last week, at the very end of the episode, but he did show us an example.

Fr. Robert: Right, right. And the important thing to remember about this is, people are saying, “Well it’s because you want to reuse code.” Yes, yes that’s it, you do want to reuse code, but there is more to a class than just that. When you do proper uses of classes, abstract classes and interfaces, what you can do is to enforce a hierarchy, a signature of the way that you are going to program. This is important because even if it’s a small program, even if it’s just you programming on a particular project, when you need to go back later and figure out what you did, if you don’t use the proper structure, if you don’t have some sort of hierarchy that you’ve enforced, you’ll find out you have created a Frankenstein.  You have seen this, right?

Shannon: I have seen Frankensteins, yes.

Fr. Robert: Yeah, where the code just goes on and on and on and way, way down at the bottom someone says, “Oh, there was a problem at the beginning, I’m going to fix it here.” It’s difficult to…

Shannon: It could end up breaking the entire program that way too.

Fr. Robert: Precisely.

Shannon: If you have it all on one page like that.

Fr. Robert: Whereas if you have a class; if you have a segment that you say, “This class solves X.” Then you know that if you have a problem with solving X, you know exactly where the problem is, it’s in the class. It’s probably going to be in the methods that you have included in the class, it’s probably not in the instantiation of it.

Shannon: I kind of just ran into a thing like this on a radio program called GNU Radio Companion, which is written in Python but it gives you a nice little Gooey and you have to have different variables for different sample reads and frequencies, and things like that. So as soon as you change that one variable, all your other little pieces of code, your boxes for your Gooey, they all change automatically. So you’re not going to be breaking something in the process because it is all separated and they are just pulling from that one piece of code every time they need to change it.

Fr. Robert: Right, right, and it’s just a better way to code.

Shannon: Yeah.

Fr. Robert: It’s a better way to organize your thoughts, it’s a better way to organize your code, and that’s why we are teaching it. And that’s why we’re okay with freaking people out, because we know that in the end it going to make them better code monkeys.

Shannon: Yea!

Fr. Robert: Alright, now let me show you a little something-something. Do you remember back in module, I think it was module one, and I think it was episode one or two, episode two, we did a problem where we had to convert a decimal into binary.

Shannon: Oh yeah, I remember that.

Fr. Robert: Right, right?

Shannon: I don’t remember exactly how to do it.

Fr. Robert: Yeah what we did was we came up with a process, we said look, it was easy to convert a binary to decimal because you just had to know the powers of the position, and right? But if you want to convert decimal to binary, it’s basically division. You start with a number. So you start with seven.

Shannon: Okay.

Fr. Robert: You divide that number by two. If you can’t divide it by two, then that becomes a one, it’s an on position.

Shannon: Oh, right.

Fr. Robert: And you move onto the next one. Then you write the dividend below the original quotient and you write the remainder of the division next to the new quotient.

Shannon: Okay. I remember that.

Fr. Robert: Right, right and you do that, it’s a very easy process, but you have to do it over and over and over again.

Shannon: Right.

Fr. Robert: Well what we did is we coded it and if you go ahead and go to my computer, Brain, you’ll see that we wrote the code for that program. Very, very simple. And notice this: we were writing classes way, way back in module one.

Shannon: We just didn’t know we were doing it.

Fr. Robert: We didn’t know we were doing it, and we didn’t tell people they were doing it because we didn’t think it was important. We thought programs were going to be so short, they were going to be so simple that it wasn’t something we wanted to burden them with. You may remember we told you just don’t worry about this part. Well now what we’re doing is we are telling you this is why we didn’t want you to worry about it, because people are freaking out. However, if you did module one, if you did these examples, if you did code these problems, then you have used classes. The only thing is you didn’t know you were using classes.

Shannon: Surprise!

Fr. Robert: Surprise. Now what we are asking you to do is look at all the code form module one because it really will open your eyes to as to how crucial it is to use classes, and how easy it is. There is nothing that is different between writing a class and what you did way back when. The only difference really is going to be that you are going to be able to get more organized. So for example, in this example, all we did is we solved for a problem. The problem was that it needed to solve for the simple mathematical question of: how do I convert this decimal number back into a binary number? It ran through the process, which is coded down here, there we go, and then we got ourselves an answer. So I want you to go back through the code from module one, turn it into classes and here’s the cool thing: once you have them in classes, you will be able to access them throughout your programming inventory.

Shannon: Love it! It makes it so much more sense now.

Fr. Robert: It really does. Now, to make it make even more sense, this is the part of the show where we are going to bring in our code warrior. Ladies and gentlemen, Mister Lou Maresca. Lou, thank you for coming back. I believe you have got one of ours with you. Is this some kind of hostage exchange?

Shannon: Who is that?

Lou Maresca: What are you reading back there? Oh, a cookbook, The Ultimate C# Cookbook.

Shannon: Fantastic.

Fr. Robert: Now Lou, you’ve been listening in on the conversation. You know that we have had people freaking out. So what we asked you to do for this week of Coding 101 is to make the code warrior segment as simple as possible. Show them how we are making classes, where we are using them and where it is advantageous to use them. Were you able to come up with something for that?

Lou: Sure. Yeah, so the example I’m going to give is a little more exaggerated than normal because we wanted to kind of prove a point that if you break it, you separate your concerns and your applications, using classes, like Snubs and you have said, it’s always easier to maintain it after the fact. And so that’s the example. And the example that I’m going to show, too, I’m going to kind of give you practical sense. I think what we chose was doing exchange conversions, so if you’re going from Euros to US Dollars, something like that. We’re going to show a way to build that, and then maybe we’ll build upon it later to give people more information for live exchange rates and stuff like that, later on down the road. But this is just a primer to that. So if you want to show my screen I can give you the beginning part of that.

Shannon: Let’s do it!

Lou: Right, let’s do it! So the first part is, this is just the main program, I have basically collapsed everything so that we can see what’s going on here. So I built a class over here to the right, called “currency,” it’s a very simple class, let me zoom I n here for you guys.

Shannon: There is a bunch of classes in there.

Lou: Yeah, I’ve built a bunch of classes, and like I said, I’ve kind of over exaggerated a little bit because I kind of wanted to prove a point. So this specific one, called “currency;” and it has a currency code, and the currency code is just another class, basically it’s just a list of codes. So you would have “D” for Dollar and “EUR” for Euro, so this is just a property saying, “A currency object is going to have a code with it.” And it is also going to have a symbol. So for instance, an example would be like, Dollar sign is an example. So that would be currency symbol and I also have this other little thing down here, it’s an array of currency rate pairs. “Rate” is another class that I’ll show you, all it is, is a rate to another currency. So for instance, for every Euro it’s a Dollar twenty nine. So you would be able to put in here, you know, if this was the Euro currency, you’d be able to put inhere “Dollar twenty nine,” and then the US Dollar as a pair, and then they would be able to convert it. That’s the simple class for currency.

Fr. Robert: So each of these is going to do something specific. In this particular case, we want to know what kind of currency it is, we want to know what the symbol of that currency is, and then you have an array that will allow us to easily change any currency to any other currency.

Lou: That’s right. So each currency, think of it like this: if I’m a currency, let’s say, I can actually know how to convert myself to another currency. So basically, each currency itself is aware of another currency and its rate. That’s’ what that currency pair is, to say if I’m a Euro, I have a list of other currencies, like the US Dollar or the Canadian Dollar, and how to convert that. So it’s making that class aware of how to do other things.

Fr. Robert: Okay, so I can imagine out audience saying, “But Lou, why don’t I put all of that in one class, like I did when I was writing the programs for module one? Why do I need separate classes for currency, and for currency rate pairs, why go through all that trouble; why not put it in one lump program and know where everything is?”

Lou: This specific example is a more simple example, but just think of it like this: currency is not just three properties. It’s more than this; I just used three properties to kind of describe what it is. But there are more things in here, like what culture codes it belongs to, potentially what countries use this currency, you know, other things you can add to this specific class that are not in here. And sometimes it just gets way too complex, and it’s really hard to kind of maintain that. For instance, if I wanted to maintain a big list of countries and their currency types, I don’t necessarily want to put it inside a currency, it doesn’t make any sense. That’s why breaking it apart is really important, because it’s really what they call “separation of concerns.” That’s just saying, “I’m only concerned with three things, and that’s it.” And that’s how I want to kind of build m y objects.

Fr. Robert: And if you could actually go back to your program, this is something that I think people need to see. This is his program.

Shannon: It’s so tiny!

Fr. Robert: It’s so tiny; if you write it correctly, and if you separate out the concerns, you have all your classes doing individual things. Your program is not actually coding, your program is saying, “I need to calculate this problem, and then I need to calculate this problem, I need to calculate this problem.” And that’s what you get if you use classes, if you use a right at the correct hierarchy.

Lou: I kind of cheated a little bit because it looks tiny because I used what they call “regions,” to be able to kind of collapse it.

Shannon: But it’s still tiny.

Lou: It’s still tiny; I think it’s only a total of sixty lines, because of all the console stuff I put in here, to basically allow the user to enter the currency. But let me just show you real quick: the reason why; I have a base type currency, that’s these three properties; but then, this is even tinier; so I have an example of a US Dollar currency. And you’ll notice something:  it’s real tiny, there is nothing in it. And that’s because, like we showed before last week is, everything that I need is really in that currency type. So what I could have done in here is, we don’t want to get into this now but, there’s things called constructors and I can add everything into that constructor and set all the properties and that would also go in here. But I did that, instead, inside the program, and we’ll show you that, what that looks like later. And it’s basically to initialize everything. But then we have a Euro version; again, nothing in there, other than being inherited from currency. And then again, I could put a whole bunch of stuff in here, if I really wanted to, but I decided not to do that just to kind of prove a point. And then we have these currency rate pairs and again all it is is a currency pair meaning you know what currency is this and what’s the rate. So the currency is USD and the rate is Dollar twenty nine. So that’s just the currency rate pair class.

Fr. Robert: And if you could go back to one of the currencies, the cool thing here is he’s using inheritance, though he’s making a brand new class for each type of currency. You’ve got the Euro currency, you’ve got Dollar currency, you could have, you know, Brazilian currency. But because you are inheriting from the currency class, you get the advantages of everything he has already written for that class.

Shannon: You don’t have to rewrite it, it’s already done for you. You know it’s not going to break because it’s already there.

Fr. Robert: Exactly. And as he said, he kind of, he made this very small so that he could give a better example. But he could have included so many methods and pieces of data for the currency, he could have had, hat’s the current inflation rate, he could have, well, what is its current stability, just look up the currency market on Yahoo Finance, and find all the different bits of data that you can get about any individual currency, that could all go in here. And then when you inherit it to make a particular class for the Dollar or the Euro or the Rihal, it will inherit all that information it knows. Oh, I need to use this to make it available for the program.

Shannon: Makes sense.

Lou: So I built that, and then I also built this other little class, real simple class that will basically convert the exchange rate for you. Now like I said, you could probably, some of your users are probably saying, “Ah, I could do that ten different ways, probably even make it simpler than this.” True, again I just wanted to kind of prove a point. This just added a method in here that takes the amount and the rate and then returns the amount times the rate. And that’s it. So if we go back to the program, here’s an example of creating an instance of that class, so we create a class, we “new” it up, “new US Dollar currency,” we initialize by setting the currency code and the symbol, and that’s it. We have a US Dollar one, we are ready to go. And then I also want to do that for Euro, too. So I set the Euro, and I set the Euro symbol properties, and then I want to be able to convert form Euro to US Dollars, and so I create this pair, “new” that up, and say, okay, what I actually want to go to is Dollars, and so I’m going to set that as a property value, and this is the rate. So really simple, just setting properties, very simple code, nothing, no calculations or anything. And then, this is the code down here, I spin up a new instance of the provider, or the rate converter, and then in the code, this is all the console code, very simple code that we had all the way back to like episode one or two, but then again all we do is say, okay, does it use the number of Eros you want, write it out, and then we try to read that in, and if we read it in successfully, we calculate it and then we write out the values. So very simple, so if we run this…

Shannon: This is so handy. I’m so going to steal your code and use it for my trip to Tahiti.

Lou: Okay, so if I put in that twenty Euros is twenty five dollars and eight cents in US Dollars, it puts the symbol in there and it puts the code for it too. So fairly simple code and very useful, like you said. And like I said, these are all static, so it’s probably a little different now, if you go to Yahoo Finance right now it’s probably a dollar twenty nine and a half, or something, you know? It changes all the time.

Fr. Robert: But you could have constructed the class to actually reach out to an open API for currency information, and pulled some real time currency information.

Lou: That’s right. This is what this is for. So I didn’t put any code in here but, now I put this as code for another day, but basically we could go out and get all the exchange rates for a specific currency type, and then we could return that as a pair, as an array, and then store that store that, let’s say, inside the Euro. We could store that inside the Euro collection of rates. So very simple and again, it seems simpler because we have broken it apart, now if you, if I could have done this in one long program, yeah, we could have done it just like all the other programs we showed you all the way up to episode eight, but, would it have been cleaner, this easy to follow? Probably not. So that’s the key, is this going to make it any easier? And as you go on and get more advanced, programs like this actually get easier to test, too. So that’s one thing that we’re not doing right now but it actually gets easier to test.

 Fr. Robert: And that’s one of the things that I’ve always know, with object orientated groups programming, it is rather than procedural programming, you can test individual pieces. So rather than saying, “Oh, the program doesn’t work,” it could tell you, “I’m not getting the right returns from module Dollar currency or Euro translation, whatever you’ve created. And it makes it a lot easier to trouble shoot. It’s one of those things that if you are writing a tiny little program, you may not notice. But even with something like this, which as deliberately been made small, you should be able to see the advantages of having everything in modules. As Lou said, I think the challenge that we could give to the audience would be to take these modules and expand upon them. He has included three or four different pieces of data; why not see how many more you could include in them? And then I bet you will see the usefulness of using a class.

Shannon: I love it. This makes it so much easier to understand when you actually see it broken up like that.  It’s so organized and it’s so clean, and I think that’s the biggest point of it.

Fr. Robert: And we’re all about problem solving, that’s what we want, and this is how you problem solve. You don’t look at the entire picture and say, “xyz,” you say, “Alright, lets break it down into these little, easy to digest pieces, and then we can code them.”

Shannon: Love it!

Fr. Robert: Now Lou, let me ask you this: would it be useful to our audience to take something like this? Because towards the end of module one, we did start looking at more advanced interfaces than just the console window. To take this programming, to take these classes, and to show them how to actually turn it into some sort of app, do you think we are far enough along that we could actually show that?

Lou: Yeah, definitely. You know, like I said, the reason why you are breaking it up into smaller pieces is so that you can go plug it in anywhere. Like you said, I have it plugged into a console app, but I could go plug it into any type of user interface I want. In fact, this specific code is so simple that we could compile it down and even use it on (Unintelligible) Studio on Android or on iOS device, or something like that. I mean, it’s so simple that we could plug it into any of those UIs.

Fr. Robert: Right, right. And actually Dallas in the chat room wants to know if we have a real program that we could share these ideas, use these ideas. This actually is a real program. We are going to make this code available; the question is, will you take the code that we give you and expand upon it? That’s the open invitation. We’ve given you some very simple classes; we’ve given you some very simple code that uses those classes, so expand. As we’ve said, we made it very small on purpose so that people can understand what’s going on. It’s your job to figure out how much more functionality you can get out of that code. Lou, thank you very, very much. Can you give any parting wisdom to someone who may still be having a mini freak out on using classes, abstract classes, and interfaces?

Lou: It’s one of those things, when you build a class, the whole idea is, kinda like you said, you’re problem solving, you’re breaking it down to its basic components, and then you’re constructing it back up again. It’s kind of like building Legos. You know, you select the correct blocks to build the entire whole. So those blocks are made up of all different shapes and sizes. To me those are all different types of objects that you’re building up to another bigger, more sophisticated object. And the reason why they do that is because they have molds for each block and specific size and that’s exactly what a class is, is a mold  for a specific thing, and then it can construct and build other things. And so when you are thinking about objects and building classes, that’s really what it should be, is basically how to construct and build bigger things out of smaller things. And then it’s not so daunting when you think about it like that.

Fr. Robert: There you go, folks, straight from…

Shannon: Classes make it easier to make everything awesome.

Fr. Robert: They make everything awesome and they make everything moldy, evidently. Lou Maresca, thank you so much for being out code warrior again. I can’ wait for next week because we are going to take this one step further. We have heard your criticism and we have heard your critique, but we want to make this easy for you to understand, but remember, it is feeling kind of abstract right now because this is a Coding 102 module. You’ve already covered C# and the basics; we’re now trying to give you something a bit more to become a better programmer. Lou, can you tell the folks where they can find you when you are not here on Coding 101?

Lou: Sure, Lou MM on Twitter, and you can find out about me, Lou MM, and also all my work is on CRM dot dynamics dot com.

 Fr. Robert: Fantastic.

Shannon: Thank you!

Fr. Robert: Lou Maresca, our code warrior, we salute you.

Shannon: So module one to me feels so much more like, this is the syntax, this is how you write code, and module two is so much more theory, and idea.

Fr. Robert: And that’s what it should be.

Shannon: It’s design.

Fr. Robert: It’s design, right. We’re talking about design, now. Because remember when we did module one, there was so much of it that we had to say, “Just leave this here. Trust us, it has to be here and concentrate on the code.  We were getting them to understand the basic constructs of the computer code. This is what a loop looks like, this is what a variable looks like, this is what a function or a method looks like. Now we’re saying, forget that. You obviously have a grasp on what those pieces are, this si how the pieces come together into something that actually becomes useful.

Shannon: Yea! I’m enjoying it.

Fr. Robert: It’s different, but it’s good.

Shannon: It’s confusing.

Fr. Robert: Now folks, we know that this was a lot of information, we’re going to give you all the code. Shannon’s code, Lou’s code, will all be on GitHub. Where can they find the GitHub?

Shannon: TWiT dot TV slash code.

Fr. Robert: Exactly. Go there; you’re going to find the show notes, which will give you the direct link to the GitHub, which will also give you the direct link to all the different modules. Now I know some people were complaining that we only had module one that just means that you have clicked on the wrong module. All four modules are in there. So you have to click on module four to get to the right code examples. You can also find us on our Coding 101 Google Plus group. It’s a good place to be, because it is filled with experts and beginners. In other words, if you have a question, if you have answers, if you have a way to help people who are learning how to code, please, please join our Google Plus group. And they can find us at where?

Shannon: Bit dot LY slash coding one zero one.

 Fr. Robert: Woot! Now it’s not just Google Plus, we are also on the Twitters.

Shannon: Yes, we are. So any time you want to get a hold of us, if you are on Twitter, I’m at Snubs. Right there.

Fr. Robert: And I’m at Padre SJ. Twitter dot com slash Padre SJ. Follow us and you’re going to find out what we do when we are not here on Coding 101 extreme. It’s a lot of fun and we would really enjoy a conversation with you. Don’t forget we are live, like right now. Every Thursday, one PM Pacific time, you’re going to find us live dot TWiT dot TV. If you join us, you’ll get to see the preshow, the post show and all the bloopers in between, it’s kind of a nice way to integrate yourself to the TWiT army. And as long as they are watching live…

Shannon: Live dot TWiT dot TV and we also have the chat room, which is where we pull questions during the live show. So if you jump in there and you have a big question about something, just say, “Hey Snubs, Father Robert, what does this do?” And we will hopefully get to it during the live show. That IRC chat room is IRC dot TWiT dot TV.

Fr. Robert: Woot. Until next time, I’m Father Robert Ballecer.

Shannon: I‘m Snubs! Shannon Morse.

Fr. Robert: End of line!

All Transcripts posts