Coding 101 8 (Transcript)
Today
on Coding 101 we are finishing up C# for now. With all things objects and classes.
Netcasts you love from people you trust. This is
Twit!
Bandwidth
for this week is brought to you by Cachefly. At cachefly.com.
Fr. Robert Ballecer: Welcome to coding 101. It's the show where we
give you the knowledge to enter the world of the code monkey. I’m Father Robert Ballecer.
Shannon Morse: And I’m Shannon Morse. We are going to get you all coded up on
everything this week on C#, I believe.
Fr. Robert: You know, Shannon, it's kind of sad, this is
the end for C#.
Shannon: I know. This is our last week, well for now.
Fr. Robert: Yeah for now, we can always come back.
Shannon: I think we should revisit it because I had a
lot of fun with C#.
Fr. Robert: Yes it is fun especially the last
episode. When you start taking all that
rudimentary knowledge and you put it into a graphical box. I think a lot of people get excited because
they realize, “Oh this is an app. This
is something I can sell”.
Shannon: That’s true. Now speaking of those graphical boxes; a.k.a. Windows
presentations and foundations. I
got really confused.
Fr. Robert: Yeah. So here is the thing to remember
about any sort of framework, especially when we're dealing with a visual
programming language. You’ve got to
remember that it can’t just be coding by keyboard anymore. A lot of old geeks, and I'm saying we are old
geeks. We remember typing on the command
line, right? You remember putting
together a script? Well in object
oriented programming that doesn't work so well anymore, because we are building
objects. We’re not just building
functions, we're not just building sections of code, we are building entire
objects and objects work better in an IDE, integrated developer
environment. Which includes the windows
and the buttons and all the little things that you can get from your ID and drop on. That is the issue that I think a lot of people
were having with the framework.
Shannon: It makes a little harder because you're
working with more than just one file, which I noticed. And you're working with more than just one
piece of code. You're working with
several different pieces that you stick all together on this pretty little
picture. And you can press buttons.
Fr. Robert: And now you know why we started with the
console. Because with
the console we can just give you all of the code. It comes on one page and as long as you take
that code and you copy it exactly into your IDE it’s going to work. But when you start dealing with an object,
when you start dealing with something like using foundations, or any sort of
framework, there's going to be multiple files. If you looked at our GetHub from the last
episode, there was one for the app, there was one from me then there was the sample files that you also had to copy over
correctly. A lot of people freaked out.
Shannon: Like me. You see all those different files of you think, “Oh wait. Where did Lou say to put this one? I don’t know”!
Fr. Robert: Here’s what I want to offer. Whenever we get into the higher level of
programming, so when we get past that episode five or six what you really want
to do is, our code examples are just that, they're now just examples. It's not going to be how your code is going
to look. If you try to copy and paste
that straight into your developer, it’s probably not going to turn out all that well. Once
we get up to this level what you really want to do, is you want to watch the
episodes, you want to use the code as an example, but then you want to make
your own. What Lou was showing us was a
really simple way to use foundations to make a button, and in making a button
you essentially made a new class or a new function, a new object, a new procedure. Which is why we're going to
talk about that right now.
Shannon: Before we get into that I have a couple of
viewers questions that I would like to share.
Fr. Robert: Oh yeah, that’s right let's do that. Homework!
Shannon: So as usual if you guys have any information,
any code that you want to share with us, you can always go over to our Google
Plus community and we will have a link in the show notes for that Google class
community. It is called Coding 101 and
we have a whole area for you guys to share your code on the GetHub. So if we jump over to my computer I can show
you a couple different ones that were released this week. So our first one comes from Dean T, and Dean
decided to show us a bank emulator, an ATM, that lets you deposit and withdraw
your money. So if I pull up either
Visual Studio you will see my app section has changed a little bit. I'm going to go ahead and open my project and
this is episode 8, example 1. I'm going
to hit start. So this is a very, very
simple really mystery idea of how much money do you have in your bank right
now? I'm going to say I have $7000 in my
bank. I wish. And I want to withdraw money so I will hit
number two. How much do you want to
withdraw? I'm going to say $1000. I wish an ATM would give you this much
money. And then it says I'm going to
check my balance to make sure the math is correct. And now I have $6000. You can continue through that and it just
gives you an idea of a little way that you can use this to check your balance
with your ATM. How cute!
Fr. Robert: And I like that because we are always telling
people to take real world problems and this is actually a real world problem. And you
can imagine an actual ATM programming is a little bit more complicated than
that, but it’s generally the same procedure right? You have something that indicates balance,
you have something they gives you a menu system, you have something that allows
you to either withdrawal or deposit money. That's what’s he built.
Shannon: So our second one comes from Joe. SO Joe sent in this really interesting
one. It is a WPF code all in one file. You can use his directions which are located
at our Google Plus community, to get it running on your own Visual Studio
compiler. His program is going to show
you Coding 101 with with a simple background, and
every time you click your mouse is going to change the colors.
Fr. Robert: I love this stuff. This is just simple.
Shannon: It is very simple and anybody can write
this. And with his code, he didn't have
a couple of interesting things in here like, for example, you have to click on
the name of the project and go to add references. And we haven't gotten into references too
much, but we had to add a couple of different references to get this to
work. So the way I understand this,
these are types of files that are built in. They have to check mark to get those compilations to jump over to your
code.
Fr. Robert: Right. So this is what we're talking about when we talked about
frameworks. This is essentially the same
idea. Including code that has already
been written that has been made available for us to play with. Again this is different from old geeks, as
most of his old geeks worked in early programming languages where if you were
going to use it, you had to build it. Right? Now, you could
go your entire programming life without writing 10,000 lines of code. You could just use the pieces of code that
other people have built, in order to have the desired effect. That is what our audience is picking up on.
Shannon: I do too. It is very interesting. He also
did a second one which is basically an RSS handler for Coding 101. On the second one he also used some of those
added references. For his example he
used system.XAML and system.servicemodel.syndication. You had to add it. Now when I try to run this on my computer I
didn't have that option under my references. That system services syndication. But, I went ahead and ran it with just system services and it worked
fine. So I’m able to run this and it
gives me the last episode that we showed which is Run Time, Fun Time and linked
to pod track so you can download and if you want to see any other episode you
can click on any key. So I’m just going
put U and enter and it shows me the last episode before that which was Padre
and Snubs. And on and
on. Of course I can hit Q and
quit.
Fr. Robert: I like that. And again this is one of those programs which is taking external data. Anytime we have
software or piece of code that pulls external data, all sorts of things can
happen.
Shannon: Oh so fun.
Fr. Robert: Because now you’re no longer limited to stuff
that you hard coded into the system, you’re now pulling from something
else. We love that.
Shannon: It’s really, really cool. So of course, as usual, thank you guys so
much for sharing your input and your codes on there. I’m learning a lot from you as well, so I
really appreciate it.
Fr. Robert: Now, I know we lost a lot of people right?
Shannon: Like me!
Fr. Robert: And that’s okay. This is how learning works. You jump ahead and get a little freaked out
and then you pull back. So we’re going
to pull back a little bit on this last episode of C#. We want to make sure that people have a clear
understanding of what object programming is. Because we are now moving past the console, right?
Shannon: Yes.
Fr. Robert: And once we move past the console you really
have to understand what objects are. You
really have to understand what classes are. We try to keep people away from it because we didn’t want to lose people
in the first episode.
Shannon: We don’t want to freak people out!
Fr. Robert: Exactly! Remember that first episode we were getting from very good comments but
also some people were saying, “Well I wouldn’t do anything until you teach
people what a class is and why there’s no functions in
C-Sharp”. That’s all true.
Shannon: And those are the more advanced people that
already understand it.
Fr. Robert: Exactly. But the reason why we started with the console is that we wanted people
to be able to have something that they could get their hands on. That they could understand before we moved
into something like classes.
Shannon: Oh boy. Classes. Okay.
Fr. Robert: Okay. Let’s go. So, in the last
episode, we talked about the object oriented language approach. And we talked about how it was different that
traditional programming right? Because
in traditional programming you have your code and then you have your data. And the two were separate. Right? You had code that processed data but they
were always kept in different places. They were always kept in different variables. You didn’t really conflate the two. Object oriented programming came about in a
time when people started realizing the easiest way to program is to mimic the
real world. Right? Instead of telling people, “You’re going to
have to start thinking of the world in a different way”, why not give them a
tool, why not give them a structure, why not give them a framework that they
can build and that will let them combine objects out of the real world and come
up with sort of a template.
Shannon: Oh that is cool.
Fr. Robert: That is what a class is.
Shannon: So it’s like a blueprint.
Fr. Robert: A blueprint! Perfect. That is what we are
going to call it from now on. A class is
a blueprint.
Okay. Perfect. Got it.
Fr. Robert: Now here is the thing. We’re going to start talking about
programming classes, but if you look back at the GetHub,
in fact go to my computer right now Brian, and you’re going to see that we’ve
been actually using classes forever and ever. This is from episode 5 and we’ve got a class right here. We had a class called Episode 005. All of the work that we’ve been doing has
been these methods. Has
been these procedures inside of classes. And like you said, what a class is, is a
blueprint for an object.
Shannon: Oh, that’s cool! Okay. So we’ve been using classes all along we just didn’t know it!
Fr. Robert: You trusted us. And this is how we brought you here. Okay, so now, just like any blueprint, a
class doesn’t actually mean anything until it because an object. Right?
Shannon: That’s true. You just have your thing on paper, you can’t
really do anything with it.
Fr. Robert: Precisely. So like a blueprint, I’ve got all my drawings and I know where
everything is going to go. Let’s say it’s
for a house. I know where my walls are,
where my pipes are going to be, where my doors and windows are. And that is great. I might be able to visualize.
Shannon: But you can’t do anything until you build it.
Fr. Robert: You have to build it. Right. And so what we have is when we deal with
classes we have to, I’m going to call it initialize, we’re going to initialize, we’re going to create the object just like we create a
variable. Right? We have to create a variable to allocate
memory. When you do that with a class,
you suddenly turn it from a blueprint into an object.
Shannon: Ooooh. And that is where the fun begins.
Fr. Robert: That’s where the fun begins. So this is the most basic type of way to
describe a class. A class starts with
the attributes, goes to the modifiers, goes to the
identifier and then the type. Now anything
in brackets is really optional.
Shannon: Oh really?
Fr. Robert: Yeah. So I don’t have to put those things. There are defaults, there’s different ways of using these individual
pieces of data to specify what kind of class that you’re creating and who can
access the data inside of the class. But
this one is really only one that is essential. And then, just like every function that you’ve ever built, within these
brackets I’m going to have a body and inside of this body will be everything
contained within those blueprints. Everything that is contained within that class.
Shannon: That body is a lot of the information we’ve
already learned.
Fr. Robert: Exactly. So what I’d like you to do. Brian, if you could go ahead… and let’s erase this really quick and I’m going to show you a simple class as soon as I
find out what happened to our eraser. I
think our eraser has flown the coop. So
you know what? I’m going to write below
it. We’re just going to do this. The most simple class I can think of is something that looks like this. I’m going to call it Class Padre. I have a class called Padre. And then I’m going to put something in the
body and it’s going to look a little bit like this. Console, write line and then hello. So right now, there is nothing in here that
you haven’t seen before. Except I would encapsulate this console, write line inside of a
function. And maybe a couple
other of functions, and then maybe a few more functions and maybe a few more
variables and maybe a few more commands and methods that I want to contain
within this blueprint. Now this is not
actually going to work. Again, this is
pseudo code, right? But I want to show
you that you’ve seen something like this before. Anytime we’ve dealt with a function we’ve seen
this structure. The structure for a
class is not all that much different and so I’m only doing this to make people
say, “Please don’t freak out”. I will
show you something that would work. Go
ahead and switch over to my computer, Brian. You are going to see, I don’t want to write this so I just went ahead
and put it in the google doc, if we’re going to populate a class template with
numbers, I want to do something like this. I have a class called PadreSaysHello. Then inside of it I’m going to create a
function called PrintHello. And inside that function I’m going to make it
say HelloTWITArmy. So that is all it does. This
class is a blueprint which includes a function called PrintHello that allows me to print Twit Army Hello. But that blueprint I need to actually declare it. I need to actually use it. I need to turn it into an object and the way
that I turn it into an object is by actually calling it, and Brian if you could
go ahead and switch back to the computer again, I’m going to show you this line
right here would declare, it would create an object, called Twit. Of the type PadreSaysHello. And then line right here TwitPrintHello would
actually call the function inside that new object that tells it to say
hello.
Shannon: Okay explain that in layman’s terms.
Fr. Robert: Okay. In layman’s terms. What I just did by creating this, I created a blueprint.
Shannon: Right.
Fr. Robert: Okay?
Shannon: Yeah, I got that far.
Fr. Robert: I created a blueprint. Now, I need to turn the blueprint into an
object. But I could have multiple
objects with this blueprint. This
particular blueprint that I created was called Twit. Now with that new object created from this
blueprint, I can call the functions inside that object and make it do stuff.
Shannon: Ohhhhh.
Fr. Robert: Right?
Shannon: Cool!
Fr. Robert: Is that easy to understand? I think that’s pretty much as simple as I can
make it. I know sometimes I kind of talk around myself because I’m in my head. But, Chat Room, listen to me. does that make
sense? Does it make sense to create an
object and then use the functions that are inside of that object? Because essentially that’s all I’m doing when
I create an object out of that blueprint.
Shannon: That is really cool.
Fr. Robert: It is cool but you know I understand that we
still need someone who can actually show us.
Shannon: Oh, absolutely.
Fr. Robert: SO, how about this? For the last time, at least for a while, do
you want to call our code warrior?
Shannon: I think we should. Let’s call him up. What’s up Lou?
Lou Maresca: Hey guys!
Fr. Robert: Ladies and Gentleman it’s Lou Maresca. He’s been with us since Episode 1 of Coding 101 and he is our Code
Warrior. He works for Microsoft and he
is an all around Level One Geek and by way if you
love his code you’re going to love how he makes his hair look like that. It is amazing. It really, really is! Now Lou. We had people kind of freak out over the
foundation because it was the first time that we actually started calling
classes, classes and objects, objects. It was the first time we used our framework. What we want you to do is we want you to back
up a little bit. We want you to take the
theory that we just gave them and actually show them how it works inside the
IDE.
Lou: Sure. So one of the things that people don’t realize is the coding previously,
like before C# and so on, was a lot of what they call procedural code where a
lot of functions and methods were kind of like all over the place. People were calling them spaghetti code over
time, where trying to follow one strand of spaghetti in a big bowl of spaghetti
is kind of tough to do. So that was what
somebody came up with what they called object orient programming which is what
you were just describing to everybody, and it is basically setting up an object
or a class in this sense to describe something. So like what I want to show people is to show a
very simple class. Like
you were showing, Padre. Let’s
say we want to describe a car. In a car
there’s different ways and different things I can add in here. Like for instance if I wanted to describe a
car, let’s say I wanted to return it’s color. There’s two ways to do that in a class. There’s what they call a field, which is just
a variable or a global variable. I can
do that by just creating a variable here and I’ll type string, color and set it
to blue. And now….
Fr. Robert: Actually Lou we need to stop there because we
never talked about a global variable so what we have to explain is when we are
talking about variables within a function those are variables that only exist
within that function. We could return
something using the return command. Lou
was doing it in a different way. What he
is saying is that there is a way to create a variable that exists
everywhere. It exists outside of that
function. So if I change it, another
function, another piece of code can still access it.
Lou: Right. So this is just what we called global variable because it sits outside
all the functions. So what I was going
to show real quick. I can add a
function, which doesn’t return anything so we’re going to do the void. I’m going to say I want it to honk. And in this case I’m just going to do a beeb. And so now, I
have something that describes a car. So
this is really easy. It describes a car
and it returns its color and now we actually have a honk. And I think what you showed in an example is,
in order for me to use this class up here in my console program I have to say I
have this new card and sometimes we have string but in this case we have a new
type we created called Car and I’m just going to make a lower case version of
that. I’m going to say, I want a new
car. I’m going to spit up a new
one. And now I have it a new car. If you notice when I actually click this, Intellisence is telling me that I can return the color and
I can honk it.
Fr. Robert: SO remember when we were doing the early
programming and we were telling people if you look at your compiler and your
IDE as you start to type commands it will drop down a menu of everything that
is available.
Shannon: It will let you know the different options
you can use so that you don’t make errors or typos.
Fr. Robert: Exactly. What Lou just showed you was inside that IDE in
the new class that he just created, in the new instance…
Shannon: It automatically knows.
Fr. Robert: It knows what is in there. It knows those functions and it lets you
choose it in the drop down menu.
Shannon: That is so cool.
Lou: Right. SO, I can pretty much add unlimited functionality here if I wanted
to. I could have it do other
things. I could have it return how many
different features of that car and stuff like that. So basically, I could set all that up for
car. But in this case what I want to do
is, I want to show another type of thing inside of a class that a lot of C# users or
developers use, that is very convenient. It is called the property. The
property is the same thing, it has the same attribute and is pretty much the
same thing as a field or a variable, but instead it is a function in
itself. For instance I wanted a return color, the property would look like this. So if I capitalize it, instead of returning
it like a variable here there are two little things I can stick in here called
a get and set methods. And this might
seem a little confusing but what it does is that if I go up here now and do
this, you’ll see that there is a bigger guy called color in here. Instead of using it like a variable where I
say, “Hey look I want it to be blue”, I can do the exact same thing with the
big guy and say, “I want it to be blue”. And the key here, and the reason for
properties, is so that you can put a middle man in between this equal. So the middle man meaning when I do this
here, it actually goes down to this set method and says, “What do you want to
do with the value you a re getting here. Do you want to set it?” So in this case I can set the variable like
this or, “Do you want to do something else with it before you set it?” So there are other things that you can do and
in this case I want to return the color here.
Fr. Robert: Now folks before you start freaking out
because I know there are some people in the Chat Room that are already going, “Wait,
what?”. In fact
Joe was saying “Wait a minute. You’re
showing global variables to newbs”? I actually would agree with that and
typically I don't tell people to use Global variables it's a very bad process
because it tends to lead to lazy programming. Lou is just doing it for demonstration, but if you do make a program and
there is a way for you to do it without global variable, please do because again, we want to enforce best practices. Folks what he's trying to do here is just
show you how you add functions to your list. Just like you were talking about when you were adding the capabilities
in that menu, you're adding the capabilities of the new framework. What Lou was doing is he was building a class
which will let him play with the properties and the functions of that class,
after he's created an object.
Shannon: Yes.
Lou: So I agree. I think I even posted on Google Plus a little blurb where I got on my
soapbox for a minute and talked about global variables. They are evil, they really are. What I wanted to show though, is that
normally what people do is they do these public properties instead of global
variables. And the reason is because you
can do a lot of other functionality here that’s in between equals.. So that makes it seem like I'm setting a variable to blue,
but really what I'm doing this I'm creating this other function down here,
called set. And then it sets the value
in here. And what I did was I actually
removed where there used to be public here. And now if I go back up here and try to set the color, is says “Oh it's
not there anymore”, and basically that is because it's not public for me to set it
anymore.
Fr. Robert: Those attributes that we were playing with
that we usually just kind of ignore because we use the default, this is where you can actually
use them. If you have an attribute, if
you have a property or a function that you only want accessible in one part of
the code and not another, that is when you can start playing with public or
private. That's when you can start
saying “I want everything to have access to this, or I only want the internal
functions to have access to this”.
Shannon: That does make sense. if you’re doing a really, really long code and you have to use some more names for
all sorts of different functions.
Fr. Robert: Yeah.
Shannon: It makes sense that you wouldn’t want to make
certain ones private so that you’re not screwing up.
Fr. Robert: Exactly. That is the perfect example. If
you’re going to have something that you are dealing with across a lot of
different classes and a lot of different functions within those classes, you
kind of want to make those private. You
want to make that specific to that instance. To whatever you are doing with it at that moment. Because if you make it
public, now everything can access it. And if you’ve forgotten that in line 4000, you would previously use that
and now the code is going to interact. And you just scratch and go, “But it looks right”. It’s because that function you wrote six
weeks ago is now interfering with your code.
Shannon: Okay.
Lou: This is kind of a deep dive, but since this
is the last class I wanted to kind of give an overview of what C# developers do
to kind of clean up their code when it comes to developing stuff. In this case I used a car as a class example
but so the main capabilities, like you were saying, is properties and fields and also accessors being able
to hide things from other people using it. So now if I actually hit intellisence, all I
see is the color and the honk functions that I added. And in these other ones that are in here are
just stuff that the framework adds to it. Things they call objects. So this
is a class, an object and a program all in itself and it is only 30 lines of
code. So it is a fairly simple example
but you could make it very complex. And
obviously over time a lot of people would separate their classes into other
files. So, for instance I can add like a car.cs file and then I would just put the class in
that file and now I have separate classes in separate files. And that allows me to clean up the code and
make it very simple so that all I would have in this file is this.
Shannon: So what happens if you run that?
Lou: Nothing, actually. But I’ll put a break point here. What you’ll see is now if I hover this little
car variable or even if you look down here in my locals, you can see now that
it has a property called blue and it is set to blue. So…
Fr. Robert: You know, Lou. Right now there is a miniature fight going
on between some of the programmers who are saying, “Well, sometimes global
variables are useful”. Global variables
are useful, again, if you are testing something.
Lou: If they are hidden fields, like for instance
I used this hidden field where it stores the value of my property here,
right? So that’s acceptable. And you can use that. Most of the time when people do this they
have different conventions, but in this case I’m just right above my property
where I have a hidden field that is storing the value of it. That is acceptable I think. It’s not necessarily a global variable, I
guess it is in a sense, but it is just saying “Hey, this is where I’m storing
my private variable. Nobody else should
touch it but this property”.
Fr. Robert: The much better use, the much better
practice, would be to pass around values that you need in functions, as they
need them. I mean, again, it is more
active program. It’s not so lazy. And you make sure that you don’t get things
like corrupted data because things are accessing global variables. Because you forgot that you accessed it again
back in line 2 out of a 100,000. Folks
we are now getting into that realm. Lou
deals with this on a daily basis, which is why he wouldn’t imagine using a true
global variable. We’re getting into the
realm where you are going to have programs that have thousands of lines of
code. And when you have thousands of
lines of code, you need a way to keep it neat. You need a way to have best data practices. That means that you need to pass data only when
needed so that you don’t corrupt it. If
you use a global variable everything has access to it. That is just asking for issues.
Shannon: Yeah. I understand that.
Lou: Yeah.
Fr. Robert: So Lou. So let’s get a little crazy here. You wanted to show us something else with a framework. We were talking a little bit about objects,
about classes, people are either going to get that or they’re not going to get
that. That’s okay because they’ve got
places that they can go to find out more about how they work. We’ve given them a general overview. Could we get a bit more back into that
framework and show us some of that magic?
Lou: Sure. Yeah. So, one of the things you
showed last week was the WPF application. And it was a little tough to copy stuff over but I wanted to show you
another simple app. Actually the funny
part about it was that I didn’t know somebody else had already done an example
of RSS feed so this is another example of RSS feed. And actually does take the Coding 101
feed. So I’m glad that a viewer already
did it. But I actually did it in WPF and
I think their code is actually better than mine but this will be a better
example for WPF purposes.
Shannon: Perfect!
Lou: So basically what I did was I set up a WPF
app and I set the background here to just be a URL to an image that I found on
the TWIT.
Fr. Robert: I hate that guy!
Lou: So, then all I did was drag and drop
here. Very simply I just added a drag
and drop button on here and I changed the content to be play. And in this case I want to get rid of this
button because I already had one, but I dragged and dropped it and then I
double clicked on it like this and it brought me to the code behind file
here. And you notice that now I have
what they call an event for that button. So it doesn’t do anything right now. But what I wanted to do is, I wanted to create a separate class, like I
said in Coding files, in a separate class that I call a NetCast Provider and what this will do is it has a property that returns the URL to the
cover art and then again this is a class with a public property. And then I also have another public property
that returns the URL for the MP3 file that you guys have posted out there. And so what it does is it calls a function
just like we’ve done in the past and it retrieves that. And we choose that and again it uses a lot of
framework coding here, so I’m not going to get into what all these do but it’s
very similar to how the other example was done. We used syndication feed and it loads the URI and then it calls Load and
then it loads the XAML and loops through all of it and finds all the Coding 101
and then it rips out the Audio URL. But
again, the whole idea behind this is that it is in a separate class, Net Casts
Provider and when I use it, my code over here, it’s just as simple as saying, “Hey
I want to use a new NetCast provider and I want to
call the property that I created Audio URI”. And then we’ll return that and I basically used this framework function
to execute it. Which that will do if I
click on it now, notice the background loads up and if I click play it will
actually ask me if I want to download it. There is the Coding 101, Episode 7 MP3.
Shannon: That is so cool.
Fr. Robert: What I like about this little program that
you created is how simple it is, right? Because all he did was use the background image so he called up a
background image and then he created a button which was a simple process. He just dragged it over from his bar, dropped
it onto the page and then by double clicking he enters a page that is a
description of the event. So when
someone clicks that button that’s the code that is going to run it. That is the event that is going to
happen. Now Lou, this is a pretty simple
example but I mean this is more or less the foundation of anything that is ever
done in a graphical interface, correct?
Lou: Right. People think that graphical stuff has to be super complex. It really doesn’t need to be. You see web pages today and really all they
are doing is they are taking the fundamental framework stuff that is underneath
the covers and taking advantage of, for instance, shadows and all the stuff
that UI can do. They’re not really doing
any special magic they are just dragging stuff on and applying special styles
and stuff to it. That is really all that
WUI’s are. Other than when you are
starting to build games and that is another story.
Fr. Robert: Right. Something I will say is that there are some people in the Chat Room that
are saying, “It kind of reminds me of Visual Basic”. Yeah, it does. Actually you can use almost exactly the same
methods and procedures to create functions in both languages, to create events
in both languages. Now anytime you are
going to be programming with foundations, yeah it is going to be a little messy
because you start thinking of all the things that you can do, but one of the
things that you have to remember is the lesson from last week, when Lou created
that graphic application he only used codes, slightly modified, from previous
lessons. So don’t freak out folks. If you were able to do it in the console you
can do it in foundations. It will just
take you a little longer to figure out how those events work.
Shannon: Yeah.
Lou: Sure.
Shannon: I think it is a little tough for me to
remember how to open and make it work in Visual Studio.
Fr. Robert: Yeah. Because it is easy to see this and go, “Ok that makes sense” but when
you are sitting behind the IDE you kind of go…
Shannon: “How did I open that file again”?
Fr. Robert: What I would suggest, honestly, is sit down
and download the last episode and download this episode and just have it ready
to play. Really just follow Lou’s
steps. Follow what he does.
Shannon: Play and pause.
Fr. Robert: Play, pause and rewind. He tends to go a little fast just because we
are limited by time. But it really isn’t that hard. The first time you make it work, you’ve had
these… that moment when you hit play and it works! And you’re going, “Oh that was it”? Okay! Got it now!
Shannon: Now I got this.
Fr. Robert: Because you start playing with the properties
of the class, the properties of the windows, and once you see how that actually
works, I promise you all those misgivings about going into this higher level of
programming will just vanish. Lou, what
else have you got for our newbies out there? They've been looking to you for the last eight episodes to give them the
goods on how to program. If you had a
bit of advice for the novice programmer that is freaking out, well what would
you tell them? What kind words of
council would you give them?
Lou: So the way I started was I used people
examples, just like Coding 101 Viewers are doing. Basically, I’d go in and I'd
watch a show or a video, or I'd go read a book and use the examples that came
with those and try to learn by those. Most of the time they provide best practices and that is the best way to
do it is to follow somebody’s best practices. There are some great books out there, for instance C# has a good one out
there, C#, The Good Parts and Java Script, The Good Parts and
Effective C# is another good book. They provide you with best practices for these languages, and then that
allows you to understand what people are using today. Another thing is, to go out onto Get Hub,
like we have on our code, and find other projects. Some might be super complex and some might be
just huge applications but they allow you to go and view how C# and the
specific language that you were using at the time, and
see how other people are using it in the industry. I think then you will start to see patterns
and other things that maybe you've never seen before, like classes and other
things. It will help you learn, and I
think it will help you learn just by doing and viewing and even just compiling
their stuff, because obviously it's public. Those are basically how I did it when I was learning and I think that is
the best way to start.
Fr. Robert: Lou, thank you so very very much. You've been an absolutely awesome
Code Warrior and you will always, always be the first Code Warrior in Coding
101. It’s sad to see you go, for at
least a while but that doesn't mean you're gone forever. You're still going to come back on the
show. Maybe another C#
module or maybe another language right?
Lou: Definitely, I’d love to.
Fr. Robert: As long as we are saying a fond farewell to
you, for at least a while, could you tell the folks at home where they can find
you, and the projects you are working on and what they can do if they want to
learn from your example.
Lou: Definitely. So obviously Twitter, @LouMM and also feel
free to e-mail me at LouMM@outlook.com. I’ve got some great e-mails lately and hopefully will provide us with
some valuable feedback. Also some other
great places to view code, there's obviously Stack Overflow is a great website
for C# developers to where just starting out. There's some great people on there to help you
out. I participate in that website a
lot, providing people with information. And then also, if you want to see what I am working on crm.dynamics.com And that's the best place to see where my work is at.
Shannon: Thank you so much Lou.
Fr. Robert: Bye, Lou. As we bid farewell to our Code Warrior Lou, we are on in uncharted
territory are we not Snubs? We are at
the end of a module.
Shannon: Oh my gosh, what do
we do now?
Fr. Robert: We dance! Folks remember, when we started Coding 101, we told you we were going to
be programming modules and then move onto a whole other language. But that doesn't mean that we're going to
just forget everything we did in the C#, but it does mean that we going to
ratchet down the difficulty a little bit. This is the idea of the Coding 101 show. The last couple of episodes of every module should really challenge you, should really make
you freak out and then we bring it back. We are going to show you about variables again, we're going to show you
about functions again, but just in a different language.
Shannon: Because I’m sure all that stuff isa little bit different when you hit a different code.
Fr. Robert: Exactly. It's going to be different in Java, it's different in Python, it's going to be different in Pearl. Is going to be different in any language you
touch. But hopefully what you're going
to start to see is that you get exposed to more and more languages, is even
though the syntax maybe different, context is still the same.
Shannon: You’re still seeing the same theoretical…. It's all the same.
Fr. Robert: Yes it's all the same. Because it's all about
taking something from the real world and solving it with code. Breaking it down into simple bye that a
computer can use and process and turn into usable information.
Shannon: We are all going to start thinking with ones
and zeros!
Fr. Robert: We are not going to tell you what our next
language is yet, even though we know. What we do want to tell you, is that we're also
going to do something that we planned from the beginning, which is our wildcard
episodes.
Shannon: Fun time!
Fr. Robert: Fun time! For the next two weeks we're putting aside the compiler, right? We’re not going to be worried about exercises, we're not going to be worried about code
samples. What we're going to do…
Shannon: Is this a fun time in class when you got to
watch TV? Watch a movie in class you
just got to sleep through it? So I hope
you don't sleep through it.
Fr. Robert: Yeah don't sleep through it. You're not going to be able to sleep through
it. In fact, Brian if you go to my
laptop right now you're going to see the page of our first guest. He is going to be the first expert coming on,
his name is Liam Kennedy. He started this
kick starter called ISS Above that use a raspberry pie and some very simple
Python programming to give you a signal anytime the international space station
is above you.
Shannon: That is so cool.
Fr. Robert: A very cool project ,very real world and as you can see from his kick starter, he only asked for six
grand but he got $17,000. People
actually kind of like the idea.
Shannon: Yeah! I kind of like the idea. I want to do that.
Fr. Robert: Well you know what? You're going to be able to.
Shannon: Yes I'm so excited
Fr. Robert: So when you tune in next week you're going to
be able to sit down with us, in the living room and speak to Liam Kennedy and ask him
all about how he created that project, why he created that project and he is
going to open up the secret door and let you see what his Python programming
looks like.
Shannon: Ooooh fun!
Fr. Robert: Folks this is what we do because we love
you. oh week after that believe it or not we've also got Randal Schwartz is
going to be expressing how wonderful it is to program in Pearl and I'm hoping
to get him to discuss the lawsuit with Intel all the way back. It was one of the cases where a smart guy, a
hacker, a programmer really figured out a vulnerability in a major manufacturers product. And got in trouble for it. So he is the trailblazer for the rest of us.
Shannon: That is going to be awesome.
Fr. Robert: It is going to be awesome. Right after that we are going to show you,
we're going to give you a little snippet, a little taste of what the new
language is going to be like. But until
then I think we need to tell them where they can find all our code, and can find us and where
they can find Twit.
Shannon: Alright. Twit.tv/code that's where we have all of our show notes. We have all of our information there and we
also have links to our GetHub as well as links to the
Google Plus community where you can find viewers submitted codes as well, that
we showed on the show.
Fr. Robert: We throw everything up on the GetHub. Now the GetHub is going to change. Every time we have a new module we are going to have a new repository,
so the Coding 101 repository is going to fork. Everyone he wants to look at the program and the code for the first
module will be able to look in one area. And then we are going to start a brand new area for our new programming
language. We figured what the best way
to do it right?
Shannon: Seems easiest.
Fr. Robert: Now we don't just offer everything in our
show nuts and on our GetHub. You can also find us on iTunes and you know
what? If you find us on iTunes we were
still new and trending just two weeks ago, so jump in there and tell your
friends about Coding 101. Get this
podcast downloaded it to your device of choice each and every single week and
help us spread the word about the Code Monkeys.
Shannon: We are not just on iTunes though.
Fr. Robert: No, we’re not?
Shannon: No we’re on YouTube too. youtube.com/twitcoding101. That is where you can comment on the show and
tell us what you like and what you don't like. You can watch all of them right there.
Fr. Robert: I like that, and also why not jump into our
Google plus community? It is 600 people
strong and considering how young the show is, that is a lot of people. These are not just people who sit on the
wall, these are active members. We've
got people like Joe full of code for sale. He's the guy who gives us all these mugs and he's got great ideas about
how people should program. And he is
always willing to lend a novice some help when they’ve got problems with their
code. So jump in to gplus.tl/twitcoding101. Do it.
Shannon: Do it right now!
Fr. Robert: Join up and we’re going to see if we can push
that to 1000 before the end of the month.
Shannon: Ooooh. That should be our goal. We can do that, guys!
Fr. Robert: If they’re not in the Gplus groove that means they can’t find us right?
Shannon: No! We’re
on twitter, too. Of course we’re on
twitter. I’m @Snubs.
Fr. Robert: And I think I’m @PadreSJ.
Shannon: You think you are?
Fr. Robert: I don’t know.
Shannon: I think you are, I’ll check!
Fr. Robert: By the way I know that you’ve had 10,000
followers like forever. But I’ve just
got 10,000 followers now!
Shannon: Yay! People like you! They are all
spammers! Just
kidding.
Fr. Robert: I checked. But you know what? If they are
going to watch our show, why not watch it live?
Shannon: We are very fun, live! You get to see our strange and awkward dance
routines before the show actually starts and Brian screws up the intro!
Fr. Robert: If you watch it live at live.twit.tv every
Thursday at 1:30 PM Pacific time you can see us do
everything in the pre-show and the post-show. You can see all the times we mess up, everything that doesn’t make it
into the final edit. And as long as you
are watching us live, why not join us in the Chat Room? You’ll hear us call out to Chat every once in
a while. They live right down here. They are in that little box. They help us figure out whether or not people are actually understanding what we are talking
about. We like that! So jump in there, talk to some of the
people. The same people who make the Gplus community so fun and enjoy the experiment that is
Twit. Until next time, Shannon, what do
we say?
Shannon: I’m Shannon Morse.
Fr. Robert: And I’m Father Robert Ballecer.
Shannon: End of Coding C#!