>> Hey friends, we're continuing our.NET Core 101 video series.
In our last video,
we were refactoring and restructuring our project,
and you said that we should go and get some NuGet libraries.
>> Yeah.
>> That's a funny "Word".
>> Yeah, NuGet is a funny "Word" NuGet is
basically the package manager for.NET,
and a package manager is
any collection of libraries that you can go and grab,
install on your project and those are all
of the dependencies that your project has.
So let's take a look at some of
the libraries that we have available.
>> So NuGet is a whole ecosystem.
I can actually go to NuGet,
or NuGet.org and look at how many packages are out there.
There is hundred of thousands of
packages have been downloaded billions of times.
I can search for them,
I can see statistically the ones that are the most popular.
I can click on them see if they're verified or not and
whether they're one that I want to get involved in.
One of the packages that I thought would be
fun is called Humanizer.
There we go. You can see it says 55 packages
returned because humanized there's actually
a whole series of packages.
They've got a package for
their main project as well
as different resources for different languages.
But if I click on one of those,
I can see how to install it using different techniques.
I can see when the last time it was released.
I can even click to go to
the project site and learn about that project on GitHub,
because it's open source and see that
this is a cool project that does the things I wanted to do.
In fact, Humanizer is really cool because it lets you
display datatypes in friendly humanly ways.
>> So that's like a computer?
>> Yeah, it humanizes things.
So instead of saying an actual time I might want to go
and humanize a date and have it say two hours ago.
>> Or yesterday. Okay.
>> Yeah, that cool?
>> Yeah.
>> So I thought since we're making
a cool bank then maybe we would want to humanize it.
So I guess I could go and download it
and find a zip file and unzip the zip file and put in my project.
>> Let's makes that a little bit easier. Let's do it.
Let's go and grab that package through Visual Studio.
>> Okay. So I'm back in Visual Studio.
Let's play with it first.
What do I do to get that NuGet package?
>> Yeah. So you can right-click on either your
"Solution" or if you're only installing it on one project,
you can right-click on that project
and go to Manage NuGet packages.
>> Okay. So integrated into Visual Studio,
I can go and browse all of those packages.
>> Yeah.
>> So let's go and say humanizer. Here we go.
So I'm going to go and pick ''Humanize
Core'' because I'm just going to use English.
If I picked to the main humanizer one,
I would get all the other languages in
the world that they support.
But for the purposes of what we're doing,
I'll get the simplest one.
If I knew that there was
a certain version I wanted, I could get that.
But I'll just pick the latest
stable version if that's okay with you.
>> Sounds good.
>> Okay. So I'll hit "Install" and it's going to
say that I'm going to go and do that and is that okay, hit "Okay".
Installing NuGet package, completed,
and then what happen?
>> So why don't we go ahead and expand our packages?
See, so now we have Humanizer.Core
installed on our MySuperBank project.
>> This is really important to point out because
remember earlier in our previous video
where we went and we added a reference to our Banky library,
now we have another reference except it's a package reference.
We've brought in someone else's code.
This is the first time we've used someone else's code in
our project and we brought in humanizer.
Okay. So we brought that
in here and super bank as I thought it'd be
fun to play with it first before
we decided to integrate with our bank.
So what I'm going to do for the purposes
of this and I'll just make some room,
and I figured we can just play up at the top but that's okay.
>> Sounds good.
>> So we'll say console.WriteLine,
and humanizer is really cool.
It's got a bunch of different features and its libraries like
this just as an example that make the.NET community so great,
because I could think about ways to write an app
like this or a library like this but I just want to make a bang.
>> Yeah. I love when you realize you have a problem
but probably a lot of other people have had
the same problem and they might have developed
their own solutions for it and shared them with you already.
Never think that you are alone in what
you're coding and what you're trying to accomplish.
>> That's a great point. So here if I say console.WriteLine car,
that's just a string, I could print out car and check this out.
If I hit dot, I get all the stringy things, right?
>> Right.
>> But we just brought in humanizer.
So let's go and say, "Using Humanizer".
So we're telling our system that Humanizer exists.
I'll go back down to car,
and look, this is really a little bit subtle.
I'm going to zoom in here just as it faded away and look at that.
It's a method but you see the little down arrow,
it's a method that Humanizer added to all strings.
It's an extension method pluralizer,
that means Humanizer extended our strings.
So we have new stuff that strings can do. Check this out.
I can pluralize cars or I can pluralize
pant or the ever controversial octopus.
What is the plural of octopus?
>> Octopi.
>> I don't know.
>> Right? Am I wrong?
>> I could depend, it's going to be very controversial.
Let's find out. I hit "Control F5"
>> It's octopuses. I got nervous.
>> It is octopuses we'd have to just stop
immediately and we put a pull request and to fix that.
>> Yeah, of course.
>> So that pluralized goes well.
So that's cool.
What else can we do? Well, this is
when I thought that you would get a kick out of for a bank.
WriteLine, let's say that I could print out a number. All right.
We know that we can do that, numbers work great today.
Okay, if I hit "Control F5" we're just going to output 3501.
>> Okay.
>> Okay. Check this out.
This is little more complicated, ToWords. Yes.
>> So this is going to write it out?
>> Yeah, check this out.
>> Three thousand five hundred and one, how about that?
>> How cool is that?
>> Cool.
>> I could do that but I don't want to do.
Think about the effort involved.
>> I know.
>> It could be huge and I just want to make a bank.
So what do you say we make
this printout words instead of amounts because that's silly?
>> Yeah, sounds fine. Let's be silly.
>> All right. So now we know how to do that.
Now this is interesting because I did that work over here in main,
but I moved our libraries.
Really, we don't want Humanizer down here; do we?
We actually want it somewhere else.
So I can go and remove that package just like that.
I can instead go back up here
and we'll have Humanizer exist up at this level.
Humanizer. So Humanizer is going to be
installed only at the BanckyStuffLibrary.
So we're making a dependency tree; are we?
So BankyStuffLibrary knows about Humanizer
but MySuperBank only knows about BankyStuffLibrary.
>> Yeah, you remove that dependency.
>> A to B to C right?
>> Yeah.
>> Okay. So where did we output all of our stuff?
We did it in get account history.
>> Right.
>> So this is interesting, we have Item.Amount,
and I think we put that on transaction; didn't we? Amount.
>> Right.
>> What about this? Public string AmountForHumans, right?
>> Right.
>> Then we could get that.
We don't want to make a new string that all right,
I don't want to do that work.
Why don't we go and get that string
from where we already had which was in amount,
then we would say why? What was it?
>> It was ToWords.
>> Okay. But ToWords is not available right now because we need
to tell it about the using Humanizer statement.
So then it will go and get that.
Okay. Let's see who's mad at me now.
What is it saying here? Not all code path.
>> I think you do it again.
>> Yeah, so I just said
Amount.ToWords but I never returned it. So thank you for that.
>> Yeah, and it's expecting a string.
>> Yeah, there you go.
It's saying, ''Hey,
Amount.ToWords it doesn't know how to do that.''
So we just learned something about the Humanizer library.
>> Right.
>> It knows how to do that for decimals and it wants ints.
So it can say 1,000 but it can't say what 1,000 point whatever.
So there's a couple of things that we could do.
>> You know I was about to comment when I was in sixth grade,
they taught me in school that when you put and that's what
separates it between 3,001 and one cent.
Is like where you add that
but that's not the way this library was written.
>> Well, there's a couple of ways that we can do that, right?
>> Yeah.
>> So we can do what we learned in the C Sharp class where
we did modulo and we can go and get
just the remainder and this and that we can chop off things.
>> What if I don't really care about the decimals anyway?
>> Right.
>> I can [inaudible].
>> If I don't care, I could be aggressive.
This is probably not saying anyone.
>> [inaudible] makes me nervous.
>> So what do you think? That's one way to do it.
So here we have a decimal that has lots of
information and we learned about that in our C Sharp video.
I could shove it into a tiny box.
But what happens when you take
big things and shove them into tiny boxes?
They crumple and when the package arrives, it's a mess.
I don't know what will happen there.
>> Right.
>> But it might be interesting to see.
It will probably break something because any big number
is going to get squished into that chaos might ensue.
>> I hope it'll work for our purposes but that's just
because we haven't really added all of the tests that we need to.
>> That's a good point. We probably
break this when we get to testing.
>> Yeah. So AmountForHumans.
>> There we go.
>> Then the tabs or ponging to get goofy as well.
Let's see what happens. Okay. So this
is interesting and this will happen to people.
>> Yeah.
>> Yeah. So notice that I'm working over in
BankyStuffLibrary and I hit "Control F5" or I pressed "Debug".
>> What does that one does?
>> Yeah, because it felt comfortable.
It says you can't start this directly.
See how this is boldface.
But if I click here, now that's boldface.
The one that I'm currently clicked on
as the one that we're going to start on.
I can go and right-click and force that is the startup project.
So I really need my program to be the starting project.
>> Yeah, let's keep our console as the startup.
>> If I control, that actually work cool.
10,000 minus 50.
I didn't know is how to put the minus there. There's a nice one.
>> Right. Because we had
negative members when we were doing withdrawals.
>> Right.
>> Okay.
>> So those are the things where you would want to decide when
we write our specification
which we never really did it for our bank.
>> All right.
>> Maybe we wanted to say minus,
maybe we wanted to say negative.
Maybe we remove the "Word" minus because we only
want the amount listed and to negative.
>> Yeah. We'd add like a separate column that calls out
whether or not it's a withdrawal or deposit.
There's a lot of different ways we could do it.
>> Yeah. But that was enabled in
very short notice by just bringing in a NuGet package.
There's so much great stuff that we can go and
do and at some point we need to test this,
because I am starting to feel a little nervous.
Our app is getting complicated
and I don't even know if these numbers add up.
>> Right. So how about in the next video
we go over unit testing in Visual Studio?
>> Let's do it.