Coding 101 31 (Transcript)

Shannon
Morse: On today’s episode of Coding 101 we welcoming back one of our
favorite code warriors, and we’re revisiting an old coding language favorite as
well.

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: This episode of Coding 101 is brought
to you by Lynda dot com; learn what you want, when you want, with access to
over twenty seven hundred high quality online courses, all for one low monthly
price. To try it free for seven days, go to Lynda dot com slash C one zero one;
that’s L-Y-N-D-A- dot com slash C one zero one. And by Hover dot com. Hover is
the best way to buy and manage domain names. It’s simple, honest, and easy to
use. For ten percent off your first purchase got to Hover dot command enter
promo code C one zero one eight. Welcome to Coding 101, it’s the Twit show
where we let you in the wonderful world of the code monkey; I’m Father Robert Ballecer.

Shannon: And I’m
Shannon Morse and welcome to this episode of Coding 101 where for the next
thirty minutes we’re going to get you all coded up on everything you need to
know to be an awesome code warrior.

Fr.
Robert: That was very Game of Throne-y. You were getting all kind of dame-ish.

Shannon: Welcome!

Fr.
Robert: Nice. We’re doing something a little different with this module.

Shannon: We are.

Fr.
Robert: This is a little strange.

Shannon: Be
prepared for lots of questions.

Fr.
Robert: Be prepared for lots of questions. But in the groups, in the emails,
people were saying, you know, 101 is cool, I like the whole beginner thing, but
it would be nice of every once in a while we could throw in something a bit
more advanced. Because when we are stuck with the 101 level, we basically have
to go over the same concepts, over and over, in every language.

Shannon: Because
each language is very similar, it’s just how it’s put together that is a little
bit different.

Fr.
Robert: Right, and there is nothing wrong with repetition, there is nothing
wrong with learning about variables over and over and over, because they are
important, or loops over and over and over, because they are very important,
but we thought, why not have a module or two every year where we kind of take a
step back, use a language we already covered, and give you Coding 102.

Shannon: Oh boy. I
hope you are prepared for me to ask you tons of questions, because myself, I feel
like I am still a beginner, so I might get a little confused along the way.

Fr.
Robert: That’s all fine, we’re good. We’re absolutely great for questions.
Now first thing we have to do is we have to tell people we’re going to be using
C#, the very first language we covered here on Coding 101. Now you may remember
when we covered C#, it was all about those basics because it was the fist
module, the first set of episodes for Coding 101, and we never really got past
making functions, or methods.

Shannon: Right.

Fr.
Robert: That was good, but I think we can do better.

Shannon: Okay, I’m
ready. But first, I think we should review how to reinstall Visual Studio. Just
in case people haven’t done that yet.

Fr.
Robert: Yes. This is something that we didn’t do the first time around; we
didn’t give people a decent step by step tutorial on where they get Visual
Studio, which is free, by the way, so they don’t have to pay for it.

Shannon: Right.

Fr.
Robert: And how they get it on their computer. If we could just put that at
rest, so that people know that it really great, easy to download, easy to put
on your, on whatever computer you’re using. Then at least we give them that
head start.

Shannon: Alright,
are you guys ready? So first off you need to download the specific version of
Visual Studio for your computer. So if you run over to my machine here, I’ve
gone to the Visual Studio dot com website; we’ll have this link in the show
notes again, but if you don’t know where this is, it’s also found in episode
two, from our show notes as well. So you got the Express Twenty Thirteen for Windows
Desktop Visual Studio download link, you click right there, and this is
available for Windows server, Windows Seven and Windows Eight. When this pops
up you just simply that your system requirements are correct, and you got to
Install Now. So you click right there, and that will reopen up a new page for
you, and you click on this one, you want the Express Twenty Thirteen for
Windows Desktop version. You basically just run thorough the onscreen
instructions, it will ask you to login with whatever your Microsoft login name is;
if you have an Xbox, you have a Microsoft login. After you run through that it
will automatically install and open up for you. It takes about twenty minutes
or so for the installation to progress, so just wait for it finish, and then
you’ll be able to open it up. Now when you first open up a project, you’re
going to go to File, New Project, and I have a question for you, Padre. Are we
still doing Console applications?

Fr.
Robert: Well that’s what we learned in the first module.

Shannon: We did.

Fr.
Robert: We used nothing but the console. We’re going to be using something
slightly different when we start classes and creating objects, but we’re going
to let Lou show us that.

Shannon: Okay.

Fr.
Robert: If they want to, and I would suggest they do this, if they want to
run through the lessons of module one again, it’s all Console.

Shannon: Yes.

Fr.
Robert: Use the Console, and copy and paste exactly the code that you see
inside of our Get hub for module one and it will work.

Shannon: Yes. And
then you can just simply run it by; I’ll cancel out of that; you can hit Start
or you can go up here to debug to make sure that everything is correct, I’ll
hit Start Debugging, it will go ahead and start for you, and then it will run
your code. I don’t have anything right here yet, because I haven’t written a
code yet to be put in here, I just opened up a brand new one, so it’s not going
to do anything.

Fr.
Robert: This is code that doesn’t do anything.

Shannon: Yeah,
exactly.

Fr.
Robert: So it will run, it will compile. So Irene, in the chartroom, makes a
very good point, which is if you’re a college student, a current college
student, you can get the professional version for free. Microsoft gives it to
you. You do have to go through the verification like you have to do every time
you purchase software.

Shannon: You when
you have a dot EDU email or something.

Fr.
Robert: Right, something like that. But if you are a college student, there
is no reason why you have to use the express version. Something else I should
mention is the express install, which you used, is nice, because it gets you up
and running right away.

Shannon: Yes.

Fr.
Robert: But you’ll notice that if you want to use some of the other languages
that are included in the studio, or if you want to start using some of the
modules that can be included, it has to download more. You can, there is a
selection to download an ISO for Visual Studio Thirteen Express, it’s about
four point seven gigabytes, so it’s big, it’s going to take a while to get, but
once you have it, you can then put it aside, so if you ever need to reinstall,
or install on multiple computers, or if you want all of the components at once
without having to access the internet, that’s a pretty decent option.

Shannon: now, of
course, if you guy are confused about any of this, definitely go back and watch
our first module about C#. We did about eight episodes where they were all
Console applications in Virtual Studio, and I think that will get you up and
running in no time.

Fr.
Robert: Yeah, yeah. Now speaking of up and running, I’m thinking on Know How
with Brian Burnett, with Cranky Hippo, we always talk about filling the
“knowledge hole.” Because there is that hunger people have for more knowledge,
to know things, and Shannon. I’m just wishing that we had something like that
here on Coding 101.

Shannon: I know a
place. I know a really good place to go. You can learn software, you can learn
how to do really good photography, and you can learn how to code, too.

Shannon: So if you
are not familiar with it, Lynda dot com is the place to go to learn everything
you want and keep you up to date on all the new software tutorials, all the new
coding basics, and pretty much everything else you need to know, that you want
to learn as far as computers go, you can learn how to make your own website,
pretty much anything. So they help you learn and keep up to date with your
software, you can pick up brand new skills, and you can explore new hobbies
with their easy to follow visor tutorials. Whether you want to master the
fundamentals of programming, or learn a new programming language like Python,
which we showed here on Coding 101, or you want to design and develop engaging
websites, Lynda dot com offers thousands of courses on a variety of topics.
They recently released a new iPhone and an iPad app for iOS Seven, and they
enhanced their Android app to provide Chrome Cast support, that’s pretty cool.
Their iOS app includes a more visual intuitive interface, and both new apps
offer offline courses and video viewing as well. So they make it really easy
and really convenient to learn, even in environments without internet access.
So if you are commuting, for example, and you have a drop out on your phone
service, you can still watch offline. Lynda dot com users can also move
seamlessly between mobile and desktop applications. So if you are moving from
your computer at home to your mobile phone you can still watch while you are on
the go. They also have a lot of new courses online, such as Android Essential
Training, Creating Mobile Games with Unity, Wordpress Developer Tips, like Enueing Styles and Scripts, and Designing the Web, Pie
charts with CSS. Ooh, that one sounds really fun. So for example, what Brian is
showing online; Android Studio First Look, Android Essential Training. That
would be perfect of you want to create your own apps, you want to learn a
little bit about the background of using Android and how to actually improve
your experience with that kind of software and Smartphones; perfect, absolutely
wonderful if you want to design and develop your own applications. Now there
are over twenty seven hundred courses and more added every single week, and all
Lynda dot com courses are produced at the highest quality. So they are not just
you know, homemade videos that you find on YouTube, for example, with terrible
audio. These people that do these are accomplished professionals at the top of
their field. They are passionate about teaching. And they have courses for all
experience levels, from beginner to intermediate and those really, really
advanced ones for you awesome guys out there, who already know a ton of this
stuff. Now Lynda dot com works with software companies to provide you updated
training the same day that new versions hit the markets, so you will always
have the very latest skills. And you can watch from your computer or tablet, or
your mobile device, whether you have fifteen minutes or fifteen hours, so each
and every course is structured so that you can learn from start to finish. You
can also search the transcripts to find quick answers, just in case you were
watching and not quite paying attention enough, you can just search right down
there in the transcripts. Super, super easy. And Lynda dot com also offers
certificates of completion when you finish a course, which you can publish to
your Linkedin Profile, which is great if you are a
professional in your field. And it’s only twenty five dollars a month for
access to the entire Lynda dot com course library. Or for thirty seven fifty a
month, you can subscribe to the premium plan, and this includes exercise files
that let you follow along with the instructor’s project, using the exact same
project assets they do, and that is so important. And you can try Lynda dot
com, right now with a free seven day trial; visit Lynda dot com slash C one
zero one, to access the entire library. That’s over twenty seven hundred
courses. Do it now, it’s free for seven days. That’s L-Y-N-D-A dot com slash C
one zero one. And of course, we thank Lynda so, so much for their sponsorship
of Coding 101. We love them.

Fr.
Robert: And we are big fans of Lynda.

Shannon: We are!

Fr.
Robert: Because we have said several times on this show, we understand that
what we are giving the audience is just a teaser; it’s a taste on the various
languages that we like to program in. You can actually use something like Lynda
to fill in the gaps.

Shannon: Yes.

Fr.
Robert: Fill in that knowledge hole, and actually move forward from what you
see here on the show.

Shannon: There are
tons that we can’t cover in the thirty minutes that we’re here per week, so go
to Lynda dot com and fill in all those little gaps, with all the extra goodies
for every single programming language. It’s totally worth it.

Fr.
Robert: I’m all about goodies. Thank you, Brian just brought the knowledge
hole up on the screen. Now I thought we should probably get to the ivory tower.

Shannon: Yea!

Fr.
Robert: Let’s talk about it now.

Shannon: I have
missed the ivory tower.

Fr.
Robert: Right, there is something about; I love the wild card weeks, but when
we come back its like, oh, yeah, ivory tower time again, we get to talk about
stuff. When we talk about C#, of course we’re talking about an object
orientated language. Now we talked about this again in the first module, I
think it’s due for a refresher. Before object orientated programming, the way
that you would code is you would code the process, and then you would consider
the data right? So I code something…

Shannon: They were
separate.

Fr.
Robert: They’re separate, right. So we consider them separately. Here’s my
code, there’s the data, and I run the data through the code, and I get
something.

Shannon: Right.

Fr.
Robert: You know, very easy to do, very easy to see, but as the programs get
bigger and bigger and bigger, it’s very difficult to maintain. And it’s not the
best modeling of the world. You can go back to, again, the first module of
Coding 101 and see how object orientated programming helps you not to think of
code, but to think of problem solving.

Shannon: Yeah.

Fr.
Robert: That’s what object oriented programming
really is. It’s: I have a problem. What do I need to solve that problem? Here
are the pieces of data I need to solve the problem, and here are the functions,
the methods, the code I need to solve that problem.
Now that whole problem solving process is an object.

Shannon: This is
why we got the object orientated programming.

Fr.
Robert: Object orientated programming. Now again, before object orientated
programming, you would just code and hopefully your data would flow through it.

Shannon: Right.

Fr.
Robert: But with OOP, it means that you get reusable code. Now you have the
ability to create blue prints of classes and methods and use them over and over
again. So I don’t have to rewrite something that I’m going to use multiple
times instead of the code.

Shannon: It will
just pull it in as soon as it needs it.

Fr.
Robert: It’s going to pull it in when it needs it; it will get rid of it when
it’s done.

Shannon: Cool.

Fr.
Robert: That’s one of the nice things about object orientated programming.
Which is handles all that sort of garbage management in the background. The
other thing that’s really cool about object orientated programming is that it’s
easier to understand. Because of our brains. Think
about how our brains work. If you sat down and looked at thirty thousand lines
of code, from start to finish…

Shannon: I would
fall asleep.

Fr.
Robert: First, you would fall asleep, but it would be ridiculously difficult
to figure out what it does.

Shannon: Yeah.

Fr.
Robert: Right? Object orientated programming breaks that thirty thousand lines down into manageable chunks. So rather than saying, “This
is program,” I say, “This is my menu, this is my user input procedure, this is
my game procedure,” or whatever it’s going to be all the way to the end. So you
break it up into little chunks that the human brain can actually understand. So
it’s easier to maintain, it’s easy to understand, of course it’s easier to
upgrade.

Shannon: Yea!

Fr.
Robert: If you have ever been a programmer who had to deal with someone
else’s code, you’re going to really like that.

Shannon: We all
know what that is like. Make sure you guys comment.

Fr.
Robert: Yeah. Now let’s talk a little bit about classes and objects, because
we didn’t really get there in module one. We talked a little bit about methods
and functions, which, by the way, we use those interchangeably. Now when we
talked about functions, this was a typical function. Go ahead and go to my
computer, Brian. This was just a know nothing function, right? We’ve got a
public function, right, that’s going to give me an integer return, the function
is going to be called answer, and it’s going to accept two variables, two
integer variables.

Shannon: And they
will be named int A and int B.

Fr.
Robert:Int A and int B, right. And then the code
inside the function is going to run based on the variables received. Integer C,
so it’s creating an integer C, is equal to the value of integer A and integer
B, which would be, let’s see if I gave it one and two, it gives me three.

Shannon: Right.

Fr.
Robert: Return C means that the function itself, the method itself, is going
to return the value of three.

Shannon: Okay.

Fr.
Robert: This is super basic function, right.

Shannon: Very, very
simple.

Fr.
Robert: Again, this is just brush up, if you watch module one, you should
understand this. Go ahead and come back. Now when we start dealing with those
functions that is sort of like the rudimentary entryway to classes, because
classes aren’t really that much different.

Shannon: So, what
is a class?

Fr.
Robert: Well a class is; go ahead and go back to my screen. This is what
declaring a class looks like. So Public; so again it looks like the declaration
for that function slash method; it’s going to be a Public Class, and it’s going
to be called C 101. And just like the function slash method, everything that
goes between the two brackets is going to be part of the class. So in this
instance, it doesn’t really look a whole lot different from a function, right?

Shannon: Right,
yeah. It’s the same layout.

Fr.
Robert: It’s the same layout and it’s actually the same idea. But, there is
one big, big difference here. So when I’m talking about a class; go ahead and
come back; when I talk about a class, I’m actually talking not about creating a
construct within the computer’s memory, I’m talking about creating a blueprint.
A class by itself doesn’t actually exist.

Shannon: What?

Fr.
Robert: Yeah, okay so wrap your mind around this: what I’m doing, when I’m
declaring a class; so let’s say I’ve written my class, and it’s got a bunch of
variables, it’s got a bunch of methods, it’s got a bunch of procedures that I
need to follow, right?

Shannon: Right.

Fr.
Robert: That’s just a blueprint. I can’t actually do; It won’t do anything.

Shannon: It’s not
going to do anything, unless it has some kind of input.

Fr.
Robert: Well it can’t even happen because it doesn’t actually exist.

Shannon: That’s
weird.

Fr.
Robert: You’ve got to wrap your mind around this, because this is the
difference between a class and an object. People think classes and objects are
interchangeable. They’re not. A class is the blueprint for an object.

Shannon: That’s
very strange.

Fr.
Robert: Well think about it this way: I am building a building, right?

Shannon: Right.

Fr.
Robert: I have the blueprints for that building.

Shannon: Yeah.

Fr.
Robert: Okay, if I have the blueprints for the building, do I have a
building?

Shannon: No.

Fr.
Robert: Because I haven’t built it yet, right?

Shannon: You just
have an idea.

Fr.
Robert: I have the idea for what the building is going to look like. The same
thing goes for a class. When I am writing a class I am just writing the
blueprint. It’s not until I create an object that that class comes into existence.

Shannon: Oh. Okay,
that makes sense.

Fr.
Robert: Think of it that way, right? But I’m going to drill this over and
over and over again because this is one of the mistakes that people make
mistakes on all the time when they are dealing with objects in programming.

Shannon: It kind of
makes sense because it’s a little confusing.

Fr.
Robert: It is, right?

Shannon: When you
look at the code, you’re like, okay, looks the same as, you know, a method, so
what’s the difference?

Fr. Robert: So what’s the big
difference? Well we want to make a blueprint that we can make multiple
instances of, we can create multiple objects.

Shannon: Yeah.

Fr.
Robert: Now think of it this way: I create an object; I’m creating it from a
class. But if I have a class it’s not necessarily an object.

Shannon: Okay, yeah
that makes sense.

Fr.
Robert: Does that make sense?

Shannon: Yes.

Fr.
Robert: Okay. Now let’s actually talk about what goes in a class. What goes
inside of a class is pretty much anything. I can put anything in it. I can put
variables, I can put methods, I can put procedures, I can put fields, but again
what we’re trying to do with object oriented programming is we’re trying to make it solve a problem. So it’s going to model
something in the real world I want to take care of. And it’s going to combine
both my code and the data that’s necessary to solve that problem, okay?

Shannon: Okay.

Fr.
Robert: And once I I have the blueprint for that
problem solving process, I can make as many “objects” or as many “instances” of
that class as I need.

Shannon: That makes
sense.

Fr.
Robert: Right.

Shannon: Okay, I
got it so far.

Fr.
Robert: You got it so far and really it’s not that different from making a
function, making a method. It’s the same idea; it’s just on a grander scale,
okay?

Shannon: Ooh, this
sounds fun!

Fr.
Robert: Yes, yes. Now so we already showed you how to define a class, let me
show you how you actually create an object.So this is going to look a little weird. This is the keyword right here:
new. C# recognizes “new” as a way to create an object. And in this particular
instance this is what’s happening.I’m
doing C101 so it knows I’m going to be using the class I just created, called
C101, and “object one” gives me a way to reference that new object. Okay?

Shannon: Okay.

Fr.
Robert: And this is the killer: it doesn’t actually create the new object
until I write this part.

Shannon: Oh!

Fr.
Robert: If I wanted to, I could just do this part: C101 object one; and it
will know that object one is reference to an object based on the blueprint of
C101, but there would actually be no object named “object one.”

Shannon: Oh, that’s
weird. Okay. Because you haven’t created…

Fr.
Robert: Because I haven’t created it yet. This is what I created: I used the
keyword “new,” and then I say “C 101” and then open and closed parentheses.
That will go ahead and create a new instance of that object. Now if I wanted
to, I could do this multiple timers. I could go “C101, object two equals new
C101 open closed parentheses close.”

Shannon: So then it
would know that you are creating a second one called, with object two.

Fr.
Robert: Right, with object two. Now its object two, and I can do object
three; and it doesn’t have to be “object,” I can call it anything I want.

Shannon: Okay.

Fr.
Robert: I’m just trying to keep this neat. But this is where the power comes
into play because depending on what I’ve got in that blueprint, I could have
just created a brand new object that does incredible things.

Shannon: All sorts
of things.

Fr.
Robert: All sorts of things. But I could make as many instances of it as necessary.

Shannon: Okay.

Fr.
Robert: Right?

Shannon: And then
it will just go back and call that same code, or whatever that object…

Fr.
Robert: It will create a brand new one. In memory, it actually creates a new
one in memory.

Shannon: It creates
in memory.

Fr.
Robert: So remember, like the blueprint and the building?

Shannon: Yeah.

Fr.
Robert: The building now exists. So when I do that process, when I say “new,”
then “C101,” it’s creating a building.

Shannon: Creating a
building.

Fr.
Robert: Yes. So it takes the blueprints, it goes, oh, okay…

Shannon: So it’s
like The Simms.

Fr.
Robert: Okay, yeah, yeah. Actually it’s very much like The Simms. The whole
idea is: this is what I’m going to create; I’m going to create a copy, boom. Boom. But just remember the blueprint doesn’t actually
exist.

Shannon: Right.

Fr.
Robert: I cannot access anything in the blueprint unless I have actually
created an object from the blueprint.

Shannon: Okay. Very
strange but I get it.

Fr.
Robert: You get it, and you know what, it’s going to get easier. Because as we start to talk about objects, you’re going to see why
we want them.

Shannon: Right.

Fr.
Robert: You’re going to see why it’s really good to create them, rather than
making a jumble of code.

Shannon: So weird.

Fr.
Robert: It is, it is kind of weird. Now this is the
time when we are going to bring in a code warrior.

Shannon: Yea!

Fr.
Robert: Who is actually going to show us how this all works. But before we do
that, I thought we maybe should take some time to talk about the second sponsor
of this episode of Coding 101, what do you think?

Shannon: I think
I’m ready.

Fr.
Robert: I think I’m ready too, because…

Shannon: I like
sponsors.

Fr.
Robert: It’s Hover.

Shannon: Hover is
awesome!

Fr.
Robert: What Hover is all about; Hover is awesome! Hover is all about is
taking all of the burden of registering your domain
name. If you’ve ever had to; what did they say?

Shannon: I get huge
headaches when I have to register domains.

Fr.
Robert: Always, right?

Shannon: Oh my gosh.

Fr.
Robert: Why? It’s because you can never get the name that you want, you can
never get the version, the TLT that you want, dot com, dot org, dot net; in
fact, space on the internet is much like space in the real world, where it’s
all about location, location, location, right? I mean, you could have the
greatest idea ever, but if you’ve got “Snubs dot Shannon Morse dot 12356 dot net,” no one is going to find you.

Shannon: That’s why
nobody is going to my website.

Fr.
Robert: That’s why no one is going to your website. Well Hover takes that
burden away from you and they make it easy for you to get the domain, the great domain, that you want. Now when you have that great
idea and you want to secure a domain for it, I suggest you check out Hover. They
give you what you need to get the job done. You will find the perfect domain
for your idea so that you can get started working on it, rather than worrying
about that internet real estate. Right now Hover is having a sale on all new
domains and extensions through September first. This sale is for new and
existing customers. Summer is the perfect time to start a new project, and
every single domain is deeply discounted, so you can choose whatever you like:
dot com, dot ninja, dot guru, just about anything. People love hover; geeks,
designers, developers and programmers love Hover because they know that they
have the best tools and support. You don’t have to be an expert to get a
domain, because their service is really that simple. They take all the hassle
and friction out of registering a domain. It gives you easy to use, powerful
tools to manage your domain so that you can do it right. You can get the
perfect domain name and start building your web presence right away. All you
have to do is search a few keywords and they will show you the best available
options and suggestions. It’s actually, it’s a fantastic process to see,
because sometimes you have your heart set on a domain and you can’t get it,
you’re disgruntled, you start going through Hover and you will go, “Oh no, no
,no, that one’s better. I like that; let’s do that, let’s do that!” But they
also offer you a valet transfer service to make the transfer process painless.
If you are stuck on a registrar that you hate, Hover will actually take that
away from you, rather than having o deal with call backs, and the pain and the
hassle, they will use their valet transfer service to take care of the whole
process and let you know when your domains are settled in your new Hover
account. And they will transfer all your DNS settings so you don’t have to
worry, even if you have a lot of domain names, it’s no additional cost, it’s no additional muss, no additional fuss. Now my
big thing is that they are honest. They don’t believe in heavy handed up
selling. They don’t promise you a super low price and then sock you with fees.
You get what you paid for, what you agreed on. They include everything you need
so that you can get exactly what you need to get at the time you need to get
it. They also include custom email, and you get a smart control panel, so you
can do what you want with your domain, and they include Who Is privacy for free
on every domain that supports it. If you ever need it they have the best
customer service support around, it’s known for its no hold no wait no transfer
phone service. When you call a real person is ready to help. And now they offer
you volume discounts. They will give you a discount on your domain renewals,
starting at just ten domains, and then going up in value from there. The idea
is, the more domains you have on your account, the less you will have to pay to
renew them. So here is what we want you to do: Visit Hover today to register
name, and for ten percent off your first purchase. Take advantage of their summer
sale now, go to Hover dot com and use out promo code C one zero one eight. We
thank Hover for their support of Coding 101. Boom.

Shannon: I’m ready!

Fr.
Robert: Ready?

Shannon: I’m ready!

Fr.
Robert: Now we welcome back to the show someone who, you know he has a
special place in our heart because he was our first code warrior and it’s so
nice to have him back, teaching C# as he should, ladies and gentlemen; do we
have a drum roll? Mister Lou Maresca! Lou, thank you for coming back to Coding 101. And we have no
audio.

Lou Maresca: Of course, I had to meet myself, right?

Fr.
Robert: There we go! Let’s do it again; drum roll! Lou Maresca,
thank you for coming back to Coding 101.

Lou: thanks for
having me back, guys.

Shannon: Hi!

Fr.
Robert: Lou, we’ve missed you. We’ve had some really good guest here on
Coding 101 but you were out first, and you do have that special place in our
hearts.

Shannon: Just like
I do in my mom’s heart, because I was her first child.

Fr.
Robert: Aww.

Lou: Love being
here. I’m actually excited we get to do some more advanced stuff here, so
that’s great.

Fr.
Robert: Yeah, you were kind of chomping at the bit the last time because you
wanted, you really wanted to get into some of the more advanced stuff, but we
had to cut it because it’s like no, we’re out of the realm of 101. So now we
get to leak over into 102, and of course, 102 had to start with classes. It was
the thing that we didn’t cover last time, the thing that I think I most regret,
because they are important.

Shannon: I’m
Scared! I’m so scared, take it easy on me!

Fr.
Robert: So Lou,

Lou: We’ll go
slowly.

Fr.
Robert: Can you run us thorough the entire process of creating a class?

Lou: Sure.

Fr.
Robert: Because it sounds daunting. We have given them the theory, but now
they need to know how they actually do it.

Lou: You bet.
So one thing we should know, too, maybe take a quick step back, is what a class
is in C#, is a type, and we talked about type a long time ago in the first
couple episodes, is basically just a variable, or a placeholder to store
values. And that’s how C# kind of handles things; it handles it with different
types. And there is what we call classes, and there is what we call structures,
and we will talk about that later, obviously, and there are other things, too,
different types. Like structures are like value types and classes are reference
types, but we’ll talk about all that later as well. But classes are just a
specific type inside of C# and it allows you to kind of do stuff, and store
stuff, and change things, and do things, and that kind of thing, just like
you’ve showed so far. So let me show you my screen, and I’ll show you how easy
it is to create a class in C#. And just got “Quick Project,” just like you
showed before. We will use a Console application, call it something, and create
a route. And so we have this program. So what I would do real quick is normally
they create a class already, which is what we use for our program, it’s just
our base class called “Program.” And inside it has a main function that
actually allows you to kind of put stuff in here. We did this before, we said
console right line, we put a bunch of stuff inside
here.

Fr.
Robert: Right.

Lou: And this
is just, again, what the class will run right out of the box, it will basically
just only run this main function off this class. But we want to add our own
class, let’s say we wanted to add a class called; so what we basically do is
you go over here and you say, “I want to add a new class.” So “add” and you
could do “new item” or you could go down here and actually just choose “class.”
I’m going to do “new item” so you can see what else you can do here.

Shannon: Are these
built in?

Lou: Yes, this
is all built in stuff you can add, there’s obviously lots and lots of extra
stuff that we haven’t talked about yet, but we’re just going to stick with the
class for now, it’s the top one here. It’s actually under, now this is all the
stuff that is under all the other separate things over here, all these other
separate categories. I’m just going to chose “code” so it kind of narrows it
down to just a couple things. And you will see there is a class item there. And
down here it will already give you kind of a class name for it. And I’m just going
to create a class called “animal.” So with this we can kind of understand how
classes work. Hit “add” and now you notice over here the class is added to my
little project file that we have here; my project just has a bunch of stuff in
there, it has my “program” class and now my “animal” class. Pretty
easy. And again, it has some additional stuff on the top up here; we can
kind of ignore this for now. But again, what we are really paying attention to
is the fact that it’s class. And so one thing we should note, too, is classes,
they have this ability to have what they call, whether they are private or
public, and what I’m going to do, I’m going to make this one public for now. So
this way I can kind of see all over my program and be able to use it no matter
where I am at. It’s just as easy as that. So I go back and as Padre showed, he
said if you want to create an object, or a version of that, I can do that. So I
can put “animal equals new animal” and boom now I have an object that is of
that type “animal.” And it’s a class. It’s an object version of that class.

Fr.
Robert: Right. And you could make as many copies of that class as you need,
as many objects based on that class just by going “animal one equals new
animal; animal two equals new animal,” as many as you need to finish your
program.

Lou: Exactly
right. And one of the things with classes, they are pretty unique. They allow
you to do things like, if I wanted to create a type of animal, I could do like,
“duck” and I could say you know, “it’s also an animal.” This is, we’ll get into
what this is later, but this is called an “area” and so this is basically
saying, “I had this thing, it’s a base thing, of all things, it’s a base of all
things, it’s called an animal, and now I have a duck, which is actually a type
of animal.” So I’m going to use that. So now if I go up here, I could do
“duck,” and if I look inside of it; actually I’m going to try something else
really quick. I’m just going t o add a, we’ll talk
about this, too, but this is called a property, so if I put “number of legs;”
oops, I’m typing as fast as I can; and then if I pop over here, if I actually
look at “duck,” now it has number of legs in it. I didn’t put it in “duck,” I
actually put it in “animal.”

Shannon: But
because “duck” is part of class “animal,”

Lou: That’s
right.

Fr.
Robert: So Lou, again, I think this bears repeating. What you have done, is
you used inheritance to essentially make a new class based on the original
animal class…

Lou: Right.

Fr.
Robert: And you have added properties, fields inside of that class, which do you remember?

Shannon: Yeah.

Fr.
Robert: In the first module, how you could start typing something and it
would tell you what your options are, right?

Shannon: Yes. I
remember that very well.

Fr.
Robert: Well if you are using this class, it will give you the options for
all the methods and variables that you have put inside of that class.

Shannon: That’s
really cool. And it would make sense that it would be included in anything that
is also part of that class.

Fr.
Robert: Correct.

Shannon: So you
could put “horse” and “pig” and you would still see “number of legs” in each
one of those because they would still be part of “animal.”

Fr.
Robert: Right. And what Lou is showing us is super, super powerful, because
what it allows us to do is say, “Okay, this class right here, this blueprint,
is going to be the basis for everything I’m going to do, but I’m going to have
to modify it slightly to make it work for my purpose.”

Shannon: It’s kind
of like having a bunch of remodeled homes, and every one is going to be
slightly different.

Fr.
Robert: Everyone is going to be slightly different, slightly different. But
the important thing is you don’t have to do all the work, again, for every
single home, for every single instance. It’s just like, no, no, no, no, this is
that class, it just has one little change.

Shannon: I like
that.

Fr.
Robert: Very powerful. Okay Lou, keep going.

Lou: So one
thing to note too, is I want to talk about too, is the reason why I use “duck”
as an example is its actually important; because C# called a “static,” or a
strongly typed language. And what that means is that when you have a variable
and you give it a type, or basically telling the program, when it complies and
does all it’s magic under the hood, it’s telling it to go and check it, to make
sure that I can only store specific things in that variable. So like for
instance, if you show me that screen again real quick, if I try to say that the
duck has a number of legs, normally I’m going to put a number in there. So if I
put a number, it’s like, oh yeah, that’s right. You put a number in there; it’s
not going to give me an error. But I try to stick in there like a text, like
this, it’s going to say, if I try to build this, it’s going to say no, no, no.
you can’t convert a string, or a bunch of characters to a number, it’s not
going to work out. And the reason is because that’s what they call a “static”
in a strongly typed language like C#, because it’s going to check for those
things. So it’s kind of like security in your coding. Now there are other
languages that are what they call “dynamically typed,” or “duck typing,” they
like to call it, and the reason why they call it that is because if it walks
like a duck, talks like a duck, it’s probably a duck, and that’s because at run
time it figures out what type it actually is. That’s why I want to make this
example here, explicitly telling the compiler, or C#, that this is a duck, and
the duck has some legs, and the legs are a number. And now it can check all
that stuff once it compiles.

Fr.
Robert: You know, it’s kind of refreshing, because the last two modules we
have done have all been very IDE light, they haven’t really had an integrated
developer environment, whereas C# has a very strong IDE. Whereas
with Python or Perl, if we made a mistake, we would just see…

Shannon: We
wouldn’t know where the mistake was.

Fr.
Robert: We wouldn’t know where the mistake was.

Shannon: Because we
have to fix it.

Fr.
Robert: If you’re looking at the IDE for Visual Studio, it will actually tell
you when you have mistakes, it will tell you, “Oh, no, that’s recursive, I
can’t do that.”

Leo: Right.

Fr.
Robert: Or it will tell you, “You’re calling on a property that I don’t have,
so I don’t know what you want me to do.”

Shannon: Yeah, it
makes sense. I wish every one would do that. Although
I guess they could if you put them in the correct type of Gooeys.

Fr.
Robert: Yeah, but remember the other reason we are also doing Visual Studio
is because Visual Studio, once we get the hang of this, now I’m hoping we have
time to get there with Lou, we could use this to say, create a mobile app.
Because the Gooey is going to let you start using classes that are written for
mobile devices, it will let you figure out what things you can play with, what
devices I can access.

Shannon: You mean I
could make my own video game on my Android about cats?

Fr.
Robert: Sure.

Shannon: How many
cats? How many legs does a cat have?

Fr.
Robert: You’ve got to see someone about this cat problem. You really do.
Alright Lou, I’m going to be the people here, and say, “Wait a minute, wait a
minute Lou. When I wrote a function, I got the same thing. When I wrote a
method in C# in module one, it would also tell me, I could call the function
and it would give me the little hints on what properties I could add to this,”
what does a class do that a method doesn’t?

Lou: So a class
kind of encapsulates everything, right? It’s something that describes a thing
that does things. And so the members inside of it are things that describe it.
For instance, the properties are going to give it some properties and
descriptions of that thing as method or functions. And those methods and
functions are going to actually let it do stuff. So let’s say I wanted my
animal to move, right, so I give it a function, or this is a method, in C# we
call it methods.

Fr.
Robert: By the way, let me clarify this, because we had this problem in
module one, functions or methods, I don’t care what you call it, they do the
same thing. In C# we call it a method, but we’ve also call it a function
because in all of programming we know them as functions.

Lou: Sure. So
one thing to notate is let’s say I want to add a variable in here, and this is
the key here, this is the parameter to this function. It’s basically saying I,
“I’m going to move and I’m going to have a specific speed.” But in the duck’s
case, I want to move too, but instead…

Fr.
Robert: Override, I love it.

Lou: Yes, I’m
going to override it and instead I’m going to say, you know what, he actually
flies.

Fr.
Robert: There we go, there we go.

Lou: So
normally the move would do something else, let’s say maybe this would say up
here, he runs, a normal animal might run, but in this case, this animal, he’s
going to fly, I want to make sure I put this in there, too. So now if I run
over here and I say, I want my duck to move, and I say he moves really fast, let’s
say about one hundred, right, now if I were to run this; really quick I’ll put
a bullet point break right there.

Fr.
Robert: This is what happens if you do it in real time.

Lou: That’s
right. It’s telling me actually, this is what the compiler is saying: it’s
actually not marked; you can’t override this thing, because it’s not marked
correctly.

Fr.
Robert: Right.

Lou: We’ll talk
about what that means later, but I’ll mark this.

Fr.
Robert: I don’t want to freak them out too much.

Lou: Right,
don’t want to freak them out too much. One thing is now it says “flies,” right?
But if I were to basically just create an animal though, and say “animal, move,
speed,” let’s also put him going one hundred, and run this. It’s kind of small,
I apologize, but the animal runs, and the duck flies. So that’s kind of the key
is you can create a base class that does a bunch of things, but then you can, again,
like Padre said, you can copy that functionality, but you can also change it.
So you can say, “I don’t want to do what that base one does, I want to override
that and actually make it move a different way, so I’m going to make it fly.”

Shannon: That’s
cool.

Fr.
Robert: Of course, we are using really super simple examples, here. We could
see the entire class, and we could see the entire inherited class, on less than
a page of code.

Shannon: Right.

Fr.
Robert: But once this starts getting complicated, I mean, once you write a
class to access the screen on a mobile device, it’s going to be big, it’s going
to be really, really big. And you may want to say, “Hey, guess what? That was
the default class to access a screen; I need to create an inherited class,
because I need to access it on a specific Android device; and we all know
Android is a little bit different. So this is for this device, and this one is
for…

Shannon: Make it a
little more specific.

Fr.
Robert: A little more specific. I override the specific parameters that need
to change for that device. The nice thing about that again, is I don’t have rewrite the entire thing, I just say, “Oh, ninety nine
percent of the code will be the same, it’s that.”

Shannon: That one
little bit.

Fr.
Robert: That one little thing. And rather than writing an entirely new class,
I just inherit it.

Shannon:You don’t want to change it in the entire
class. That’s cool, I totally get it.

Fr.
Robert: Yeah, Totally makes sense.

Shannon: Yes!

Fr.
Robert: Now Lou, we do need to stop, because we are running out of time here.

Lou: Sure.

Fr.
Robert: What are we going to do next time?

Lou: So I think
we are going to go a little deeper into different types, and we’re going to
talk about things called interfaces, and they are another version of a type in
C#. And maybe we will go into some of the functionality in Visual Studio and
how to add features to your program too. So I think we will get a little more
into that so you guys can kind of understand Visual Studio as an IDE, like you
were talking about, and give you a little more feature set.

Fr.
Robert: Yeah, that’s actually really, really important. We’re not going to
have regular homework for you, because what we want you to do is we want you to
go ahead and download the IDE for your device, like Shannon showed you at the
beginning. Now she showed you Windows eight, but if you go back into module
one, she also showed you how to use, what was it for
Mac, it was mono…

Shannon: I forget
the name.

Fr.
Robert: Mono Develop. It was something along the lines of that. But there is
an IDE for Mac users as well. So find the one that you need for your device,
and next week we will actually give you homework.

Shannon: Oh, I’ll
do homework this week, though.

Fr.
Robert: Lou, thank you so very much for being our code warrior, thank you for
actually showing us how classes come into play, it is such an important topic,
so I don’t mind burning an entire episode so that we get into people’s heads
what it is, why it is important, and how you use it.

Shannon: It was
worth the thirty minutes, or forty five.

Fr.
Robert: Lou Maresca, the senior developer at
Microsoft, we thank you. Can you tell the folks at home where they can find you
in case they want to see what you do in between your appearances on the TWiT TV network?

Lou: You bet.
It’s Lou MM Twitter, and you can check me out at CRM dot dynamics dot com,
that’s all the work I’ve been working on for the last several years.

Fr.
Robert: And we love you and it’s so good to have you back. We’ll see you next
week. And also, we’ll see you next week.

Shannon: Yes we
will.

Fr.
Robert: That’s right, next week we’re hoping you will have your computers
fully equipped so that you can get the lessons. We know it’s always a little
jarring any time we start a brand new programming language, especially one...

Shannon: It’s
exciting!

Fr.
Robert: It’s exciting, right.

Shannon: Don’t be scurred!

Fr.
Robert: Don’t be scurred.

Shannon: Get ready,
we’re going to do some C#.

Fr.
Robert: Yeah. But seriously, this is a heavy programming language, because
it’s not like Perl, or like PHP, sorry, Python, where you can just write it in
notepad, you do need to use an IDE, it’s going to take some getting used to, so
please spend the next week sitting down and playing . Find in out examples from
module one, play with functions, play with methods, play with variables, output
things to the screen, get things back from the user, because you need to have
all of that as a basis before we continue in this 102 module.

Shannon: I’m ready.

Fr.
Robert: Alright now, in case they get freaked out, they can find…our TD is
strange.

(Technical Director): What, you don’t
like that?

Shannon: Don’t be scurred.

(Technical Director): Don’t be scurred.

Fr.
Robert: If they want to find out show notes Shannon, where do they go?

Shannon: You can go
to TwiT dot TV slash code or Twit dot TV slash Coding
one zero one, all of that goes to the same place, where you can find every
single episode that we have done. You can go back to the original C# module for
Coding 101. You can basically walk yourself through and get caught up with
everything we are going to be talking about on this module. That’s also where
you will find the link to our Get Hub, we have all the original code from the
first module in our Get Hub, so you can go there, find module one, and download
and copy and paste all those different codes that we did for C#, and you can
run them on your own machine and play with them to get an idea of what each and
every one means.

Fr.
Robert: Right. And you don’t actually have to download the episodes, if you
want to, you can just look at the Get Hub. Because if you can
just copy and paste the code from the Get Hub into the console, it will run. And once it starts running, what do we like to say? Break it!

Shannon: Break it!
Yes, play with it.

Fr.
Robert: There is nothing you can do to destroy the computer by running code
unless you get really, really brave.

Shannon: Make it
get errors and try to figure out why those errors exist.

Fr.
Robert: That’s how it works. And if you get stuck, the best place to get help
is out Google Plus page.

Shannon: Love this
place!

Fr.
Robert: We don’t have a shortener anymore, that kind
of broke.

Shannon: I made a bitly, I made a bitly.

Fr.
Robert: What is it?

Shannon: Bit dot L
Y slash TWiT coding one zero one.

Fr.
Robert: Go there, bit dot L Y slash TWiT coding 101,
we’ve got over a thousand users in there, and they are users of every
expertise. You’ve got beginners, you’ve got intermediate, and you’ve got experts,
so go ahead and ask your questions. Or, if you are an expert already, help
those people who have questions. Remember, it’s up to you to make sure that we
get the next generation of code monkeys.

Shannon: And you
can always throw questions at us over there, we’re always on Twitter.

Fr.
Robert: We’re always on Twitter, and you get to find out what we do in
between episodes of Coding 101. Which, by the way, we do live every Thursday at
eleven o’clock, no, at one thirty PM pacific time; I’m stuck on my other show.

Shannon: I wasn’t
aware it was so early.

Fr.
Robert: Yeah, no, I never wake up this early. At Live dot TWiT dot TV, go ahead and jump in, and as long as you‘re there, we’ve got a chat
room, right?

Shannon: We do,
yes, it’s IRC dot TWiT dot TV and we have tons and
tons of people in there asking questions, so we try to throw them out during
the live show so you can get your answers right away.