>> ON.NET today, we're
going to be talking
about e-commerce with.NET Core.
Yeah, that's the thing.
Join me and John, define
about nopCommerce.
[MUSIC]
Welcome to another show of ON.NET.
Today, I am with John [inaudible]
, Donnelly developer.
We're going to be talking about .NET
e-commerce with nopCommerce. Right.
>> Yes.
>> Well, thanks for
coming today, John.
>> Oh, thank you. Came all
the way from St. Louis.
>> Well, that's a hell of a trick.
>> Yes, it was.
>> Tell us about a nopCommerce
and how did you get
involved with that.
>> Sure. Well, nopCommerce
is a ASP.NET Core
open-source solution
that is truly free in
open-source unlike a lot of
other solutions out there.
I got interested in nopCommerce
more as I was looking for
an enterprise level
architecture that was in
the Microsoft stack that I can
plug and play technologies with.
So I wanted something that I wanted
to use for training purposes and I
didn't want to have to base
my work on a "hello world"
type example.
>> Right.
>> I wanted a true
enterprise application
that's used by millions of people,
and It would be a great test bed to
interchange technologies
within that tech stack.
>> Fantastic. It's
a weird name. Do you know how?
>> NopCommerce? Yeah. Well, I
guess if you search enough
you'll find the answer.
But the answer is actually in
a blog post that I saw that Andre,
the Creator of nopCommerce,
kind of responded to
someone's question.
He basically responded
simply, it's three letters.
In other words, I think
he was just looking
for something that had three letters.
Then of course, the jokes
kind of went on from
there to where it
was not only PayPal,
and there's also some really
technical term for nop.
I think my favorite is not
our problem, since it's open-source.
Yeah. So I think
Andres reason for that was like
you can call it whatever you want.
You find a lot of companies
based around nopCommerce using
that same little prefix of
nop Templates, nopAdvance.
So a lot of companies around
nopCommerce kind of use that
three-letter in front of their name.
>> Interesting. So tell
us a little bit about it.
How do I get started
with a nopCommerce if I
were to spin up my own version of it?
>> Sure. So I prepared a few things.
I'm going to jump into
that, then we will navigate
the site and look at GitHub
a little and some code.
>> Perfect.
>> I'm just going to fire this up.
>> Yep.
>> So, what is nopCommerce?
I've been giving this presentation
around the country
to get the word out more about
nopCommerce at various.NET meetups.
Because it is an architecture that is
this very strong example what a .NET
developers should be looking
at from the front-end,
business logic and mid-tier,
and at the database level,
and work within Entity Framework.
So nopCommerce itself,
when it comes to being
a shopping cart it
also has features in there
like a blogging platform.
It does well when it comes like
a SEO engines and things like
that, you do multiple store.
So I think that the features
themselves are on
par with many other storefronts
that you find out there.
But it's in the.NET
developer stack which is
very appealing to us.NET developers.
When you fired it up,
the store front itself,
the example, it looks pretty
appealing out of the box.
It's even responsive.
So on a mobile device,
you just shrink it down,
it looks pretty decent.
>> Yeah.
>> Even on the admin side for where
you're managing a lot
of different pieces,
that's also responsive as well.
So I don't know if too
many people are actually managing
products when on their mobile
device, they might be,
but their site itself on
the mobile site is pretty
decent even for the admin site.
>> Very nice. So it has everything.
It has a front end to allow
you to spin up the platform.
It has a comprehensive back end,
to allow you to manage
the platform end to end.
>> Right. Then, we'll even look at
some plug-ins later on too
and how you extend it.
>> Yeah. Because
no ecosystem is good if you
don't have plugins to work with.
Although you can write
your own, I suppose,
and we'll look into
that later on, right?
>> Right. Exactly. We'll
touch on some examples.
So this is the stack, really
what makes a nopCommerce.
Matter of fact, This is
a tat outdated because
it is a.NET Core now,
compiling on the 2.2.
Uses any Framework Core.
It's still uses a jQuery
and the Razor view engine
on the front end,
so it'll be interesting
where nop goes from here.
Are they going to adopt Angular,
React, View? It's kind
of up in the air.
But of course, that's
why it's open-source.
That's why they had
GitHub and they have
forums for people to
share their opinions.
I have found that most or
many people that really want,
let say Angular, they'll probably
do a custom template anyway.
>> Right.
>> So they're just
going to use Angular in
their custom template if they
really want to use that tech stack.
So in a way it's nice that
nopCommerce is generic
on the front end.
>> It's not opinionated.
>> It's not opinionated.
>> You use your own technology.
>> Yes. Autofac is used
for its container.
There's also FluentValidation.
We'll touch on some of these as
well throughout the architecture.
>> So from looking at this,
it looks like a very
comprehensive kind of
a stock and touches all the layers of
development from the front end to the
famous like Autofac and AutoMapper
which are very well-established,
to the backend which is
SQL Server and I suppose
you can run it on Azure.
That's the ideal scenario, right?
>> Yes. It's actually
a great code base
even just to learn
more about AutoMapper.
FluentValidation, which is
another open-source library that it
uses entity framework in Autofac,
It's a great repository to
understand those better.
So we'll walk through the
application front end
and the business layer and the
data access layer for this.
>> Sure. Yeah.
>> So the solution itself
is actually pretty clean.
Your nop up web is your storefront,
and then you have
a common framework there,
and your libraries are
pretty straightforward.
I have some test around the
architecture as well, which is great.
Then, there's plugins that come
with the solution out of the box.
It's great that they don't
have everything in there.
They don't try to have
everything in there
because obviously
things change a lot.
There is a process on how you
would install a plug-in
and work with that.
But they give you
enough plug-ins to get
started on the different kinds of
plugins that you want to create.
So payment-type plugins,
shipping plugins,
and we'll take a closer look
at one or two of
these a little later.
>> Awesome.
>> So first, I guess we'll come
looking at the splash
of technologies and
maybe keep those in
the back of our mind as we
walk through the architecture itself.
>> Yeah.
>> So the architecture
is pretty clean.
I don't want to make it
sound like it's this clean.
So Nop.Core, everything
points at core.
When it comes to the Nop.Data,
it's really referring to just the
SQL Server-type connectivity.
So like file access,
even Redis is part of this.
A lot of that codes
with the Nop.Core.
So I guess my point on this is that
the architecture is probably one of
the cleanest architectures I've seen,
but it's not like perfect.
>> Sure.
>> Everybody's got an opinion.
>> Yeah.
>> But this one's
pretty doggone good.
>> Excellent.
>> All right. So I'm going
to fly forward through
some slides here.
So we're going to go through
Nop.Web.Framework
a little bit closer.
The store front itself
when you fire it up,
this is what you would get out.
However, the first time that
you fire it up, Nop.Web,
you actually get an installation page
of where do you want
to put the database.
>> Right.
>> So the barrier of entry of
work we adopt is pretty easy.
>> Yes.
>> Outside of going the barrier
of downloading the source code,
and I'll share some tips
on that later,
just compiling it, running it.
What do you do next? You need
to know where the
data is going to be.
It steps you through that process
if it cannot find the settings.
>> Okay.\.
>> So yeah, it'll put the settings.
A little bit of
an article location in
the earlier versions
in this settings file.
The reason I highlight this is
because anything that
seems a little odd
about this solution that you
may not find in another solution,
I try to highlight that.
>> So I see there is
a setting called TXT,
and I suppose that the SQL Server
settings will end up in there.
>> They are in there, yes.
They're underneath app
data which is fortunately
secured by default when
you do an install.
>> So still in clean.
>> Yeah. There's better
ways to do it, I agree.
>> Yes.
>> I agree.
>> Through requests.
>> Yeah, I agree. I'm surprise
how most of the committee
is comfortable with how AppData
itself is secured to a point.
Are they focused on
the security around AppData?
>> Yeah. There's always space
for improvement, right?
>> Yes. So when it comes to
finding the connection setting
nowadays for nop app up,
they put it in a different location.
So some things that you move around.
So like if you're going to
jump into an architecture,
you might think you want to
jump into the homepage first.
So typically, the homepage
is broke up in
these different sections,
and it's not a bad place to start.
However, we go to the code behind,
and it's not really telling me
much about this architecture
and what it's doing.
So I thought I'd start with
a really drop-dead easy page,
basic phase or registration page.
>> Sure.
>> So looking at this
example moving forward,
you would look at okay.
The way I go look at
an MVC architecture
is I'll go to the controller first.
So here we have the out of
the register actual result.
What we have here is
that it's returning
the view which the model is
instantiated with inside of it.
So the main thing I'm really
trying to point out in
this example is there's
nothing crazy here.
>> Yeah.
>> It's just your normal
MVC architecture.
But then you're going to see
where there's some aspects of,
I guess you'd say
decorated around this.
So one of those, if we look at
the model for that Last Name,
we had this NopResourceDisplayName
that is really this p-value.
So out of the box, it's multilingual.
In other words, it handles
multi-localization.
So out of the box,
you basically have multiple
resource files per the language,
and the standard throughout
the whole application is to
use a Key rather than putting
in some direct texts so tight.
>> Right. Fantastic.
>> It's a really good example of
just putting that in
your architecture.
Now, like in the same
example of this last name.
So we highlight just this piece.
We see we have some
common aspects here like
what you would find an interview.
But here, we have those nop-required.
So what's cool within
the 4.0 version,
4.2 now is the current version.
But when they're preparing craze
for.NET Core and using
these tag helpers,
they implemented a pretty neat way.
So this is an example,
where nop-required was implemented
as a custom tag helper,
and that's tied to this
particular key value that we have
here and way that
highlights because that's
what binds it to there.
Then down below, do get that
little red asterisk on the screen,
we had a little bit of
code that puts it better.
So I found Nop as just a
great reference architecture.
You might see where
this is leading to
the great store front if you
have a need for e-commerce.
But if you're just said .NET
developer wanting to
learn good architecture,
this is the solution that dig into.
>> Brilliant.
>> So we go on from here
to where it also in
the front and they use
this open-source library for
that validation that
Jeremy Skinner has created,
and the programming style and most
of the solution has this
fluent feel about it.
>> Right.
>> So probably, we will look at
some example code here on
the fluent validation and
how this really works.
So by using that particular
FluentValidation.Attributes,
we have this attribute around
our model in which we have
this register validator class
that we're going to
look at a little bit
closer and how it binds
those two together.
So normally, you're putting
your validation on your model.
It has attributes throughout.
You're going to find that in
every Hello World example,
this is a little different.
Meaning that, when we look at
this validator little bit closer,
we see is its own class and
that wind down here that I
have highlighted might be
hard to see but that is the line
that's doing the validation of
returning the message that
the last name is required.
>> Right.
>> So it's centralizes in a way
that might be good, might be bad.
But what I like the most about
this programming pattern
that was new to me
is that this register validator class
is something that you
can inject data into.
>> Right.
>> Therefore, it can be testable.
>> Yes. Yes.
>> That's what's
really valuable about
pursuing this pattern
a little bit closer.
>> I liked it also uses
localization as well.
So the error message will be in
the right language which is
fantastic through out there.
>> Exactly, and I'm afraid
that you can test for that.
You could definitely
test for these pieces.
>> Nice.
>> So then we have the admin piece.
I'm probably going to jump into
the business logic here shortly.
Actually, the Admin is not
its own project anymore.
It always has been part of
the deployment of the storefront.
In the 3.9 version earlier,
it was its own project.
I left this screenshot and
they're just done, highlighted.
It is really as its own code base.
I find this to be
a really good architecture
to look as a.NET
Developer because this is
the application that most of us are
actually programming
in the real world.
>> Yeah. Line of
business applications.
>> Yes. So yeah,
I find this to be a good
place to start and
for maybe finding some coding
patterns for that purpose.
The navigation is very common here,
Search, you have the grid here.
For the grid itself, I now use
DataTables, DataTables.NET.
They actually just switched over to
this open source library
and version 4.2,
the current version this year.
Previously, they were using
a Kendo UI for a lot of this.
>> I've worked with
both, the challenge
is depending on what you're doing.
Now, going back to
the storing of the data.
One of the questions that
will probably come up
or usually should becoming up is,
how GDPR compliant is Nop?
>> Great point. I didn't
expect to talk about this.
But since I was there firsthand,
I was at the Nop Congress
Conference in 2017.
An individual was
giving a talk on GDPR.
>> Right.
>> Nop community was there like
Andre and the rest of
the people are that make up.
They're like GDPR, we
better pay attention.
It's amazing how fast
they turned in really got
that out in the next version
to support GDPR and have
improved it in every release.
So I think they discovered
GDPR around the 4.0 version,
four that was already out.
>> Okay.
>> They put in some GDPR aspects
on 4.1 and 4.2, they made it better.
So they definitely listen
a respond to the community.
I saw it firsthand that
they take this so serious.
>> Yep.
>> Andre and his team that
they will listen to you.
>> Well, it could have
some significant implications if
you don't implement it right.
So if you're an e-commerce company
and you're using
an open source framework,
you need to make sure that it is,
and that's not just for this one but
for our audience as well
as they were watching.
If you're using any a
platform.stores customer data,
you need to be aware of GDPR
and how that can impede because
the fines can be severe as
we are learning
the last couple of weeks.
>> I find that when it
comes to GDPR on the like
the business features as well
as in the technical features.
I find that nopCommerce has like
right where they should be.
In other words, we're not
bleeding edge on either.
>> Sure.
>> They're right there at
the edge but not falling forward.
Actually, I have a good
example of that.
>> Sure.
>> I highlighted certain versions
to like version 1.9 to 2.0.
They actually move from web forms
back in the day to MVC.
>> The glory days of
webform. Bring it on.
>> Fun in that change and all that.
Then when it comes to
prepping for core,
I liked how they didn't
just cut over the.NET Core.
>> Sure.
>> So what they did
from version 3.9 to
4.0 is that they put in more
that when it comes to
the views whatnot in
working with tag helpers.
They still compiled
the framework in 4.0 but they
were able to move a ladder
codebase more.NET Core ready.
>> Right.
>> So they didn't make
his hard mandate.
We got to compile to core.
>> Yes.
>> They did what was sensible,
and I think this is actually a
really good example just looking at
how this company did it and
how most companies should
probably adopt core.
>> Yep. It's all right.
>> It doesn't have to be that hard.
>> Yeah. Absolutely. It's
a big transition as well.
So if you're interested on .NET,
the full framework,
going to.NET Core,
there's a big learning
curve, and there's
a lot of work that is required,
especially for opposite hit
them to grow organically.
>> Yeah.
>> So I think that's
a great example and if people want
to look at how that was done.
I think that's one way to go, right?
>> Yes, and then 4.0 to 4.1,
that's when you could
cup out of core,
and then 4.1 to 4.2,
4.2 is just released
out in the spring.
Now, they're advocating even
that you can run this on
Linux and it's also is Docker ready.
So when it comes having Docker file,
all that in place that
you could utilize,
it's ready to go, pretty impressive.
>> I suppose, considering
the size of the website
of the advocating going
towards a microservices architecture
or using some like AKS
to run the site.
>> You could, I guess. Because
the architecture itself,
I think if you really want
to break it out into like
microservices or something
like that, you could.
>> Okay.
>> So they're appealing to
a lot of different markets.
They are appealing to market
like WordPress using
WooCommerce or even Magenta.
So we could have something
up and running fast.
It's not so easy to have
a multi-tier Architecture
of microservices and message queues,
that'll be up and running fast.
But if you really wanted to work with
their core libraries and put your
own entry points into those pieces,
I think you really could break this
up if you really had to scale.
>> So right now, it's more or less of
a monolith that runs in
a container rather than
running on bare bones or say
a web app on Azure, right?
>> Right. But it's a library
that you can pull into
multiple entry points.
>> Yeah. Absolutely.
>> So they did a right thing.
They didn't put everything under.
A matter of fact, let's look
at some business logic here.
>> Sounds good.
>> Because if you're not, let's see.
We jump in here. All right.
So we're going to look at the
Nop.Services and Nop.Core
a little bit closer.
Just a little bit recap,
we got the controller that
instantiates the model,
and it also returns the view that
has a reference to the model,
your normal MVC stuff.
>> Sure.
>> Then the controller
will get its data for
something called the service,
a factory to make you
think of as a service,
and that service is going to
populate a domain entity,
and then it's going
to fill in the model.
So the separation that concerns in
this architecture is pretty strong.
>> Nice.
>> So that's yes, exactly.
>> I suspect that auto-mapper
is somewhere around
here where it comes.
>> Yes, we will show
an example of that.
>> Good.
>> So Dependency Injection
and Inversion of Control,
these are two different topics.
I always get introduced to me as
some definition like this
or some boxes and all that.
So dependency injection
is typically data
that you're trying to pass
through a constructor.
That's how it's implemented
most of the time.
>> Okay.
>> Then inversion of control is
a framework around how
things can go very crazy,
and I will show an example
of how things go very crazy.
When it comes to looking
at dependency injection,
looking at the customer controller,
I could've picked on
one of the services,
but picked on the
customer controller.
Here we have about 30 plus
dependencies.
> Yeah.
>> Going into that controller.
So you can probably think of those as
each one of those
maybe hitting a table,
hopefully one or more tables in
order by the appropriate context.
The example that we looked at earlier
where we came to
populating the model.
>> Yeah.
>> That basically came
from that first dependency
that's passed to prepare
the register model.
>> Got it.
>> So all the data is
getting injected correctly.
>> Okay.
>> Let me ask you this, why
do we do things like this?
>> Testability.
>> Testability, yes it's
a softball question.
>> I pass.
>> So the customer service classes
and this example is one of
the classes in the solution
and it works mocking out data.
By yes, this is the reason
why we do this,
is why we make it wasn't this
hard of the '90s, I tell people.
But that's done for good reasons,
and we can write unit test and
control the data for those tests.
So here's where things can go crazy.
So we're back at the same example,
and what if we look
this address model factory?
>> Right.
>> For what that has an
all of its dependencies,
you would think that it
is a pretty simple class
or pretty simple factory for.
>> Making assumption
because you never know.
>> Here we go. So we take
a closer look at this
and if we were to make
a constructor with no parameters,
we're in wine, I will instantiate
all of these classes.
>> Sure.
>> I thought I'd see where this ago.
So this is not enough commerce.
So for the address
model factory itself,
he can see that you've got
the dependencies of the
dependencies that you would have
to consider if you were to
manually instantiate this
everywhere where you see red
is a database connection.
I purposely left that
so you see that.
>> Well.
>> But yes, I type
all the cinema watching
some TV show and there was like 2,
300 some-odd dependencies
of dependencies.
>> Yes.
>> When it comes to managing
dependency injection.
>> Oh, wow still going.
>> Still going. Yes,
this was not fun to do.
Of course, I didn't do the rest,
I just wanted to get
to know [inaudible].
>> Wow, that was not a complete list?
>> Yeah.
>> That's a lot. I mean it's
a big application show,
there is a lot of services,
there is a lot of
factories there, I get it,
but it goes to show how
complicated these
applications can be, right?
>> Right, and that shows why out
of the box you really should
think of a Container.
Fortunately, there is one built-in,
ASP.NET Core, but Autofac
was carried forward.
They might switch over to
the built-in, I'm not sure,
but Autofac was available at
the time along with a few
other ones to choose from.
So as an example,
the pattern that's put
in place for Autofac,
you'll see what this looks
like. They had this pattern.
So where are the have this
dependency register class that is
used within the architecture
itself as well as
within your plugins.
>> Yeah.
>> Because the plug-ins
themselves follow
the same architecture as everything
else we're looking at today.
>> Right.
>> I did a search, I'm sorry,
on the dependency register class to
show world it's found
throughout the architecture,
but it's really
the Autofac Container builders
getting passed to
this particular registry method,
and there's that same instantiation
of the address model factory
that we had to worry about,
and it's also interface-based.
So here, we're able to
do and one line of code
and safe way versus
the ugly way of worrying
about how to instantiate.
>> Yes, that's optional right.
>> So this like Hamlet at Home
for me the value of an IOC.
>> Yes. Hopefully,
everyone else out there
[inaudible] especially for be
size of application, right?
>> Yes.
>> All right. So a couple
other examples on Autofac.
There's this ones kind
like by criteria,
but I think these are a
little bit more [inaudible] .
By type, it's anything
on this type going
and deal with
the instantiation on that,
all the controllers,
all the controllers
up a memory, instantiated.
>> Right, yeah.
>> So the customer
controller we're looking
at would have been a good
example of how that
would've been caught,
and more commonly for
your data access layer.
Now, this code might be a
little difficult to read,
but this is where you find working
with containers most
often used initially.
>> Sure.
>> I guess you'd say when it comes
to working with your repositories.
>> This one using indifferent
more core to interact
with the database, right?
>> Is it this?
>> Right, brilliant.
>> I will be curious when we
look at that if you have seen
Entity Framework implemented
this way in the past.
So first off we're going to show
this other example of AutoMapper.
>> Yeah.
>> I know this is a popular library,
and we're pretty much
object.last time wherever
they dug out equals.
It saves you that tedious work.
>> Correct, yeah.
>> That's awesome library
that's out there.
So you get little things can
looking at this code base.
So you have these mapping
[inaudible] ,
and there's a reason I had
version 3.9 around this.
Where they even treated
AutoMapper almost like
a dependency that they wanted to
control and contain so they created
these non-extension methods when it
comes to for example
retrieving the manufacturer
and populating the models.
So the way this one
line of code here is
used it really just calls
the one-liner code of AutoMapper.
>> Yeah.
>> But when you look at how it's
used then you will say okay,
and this is nice to where
you get manufacturer,
and then it populates
domain manufacturer,
and then here you
have the one layer of
two model that populates
the model itself.
So you got the
separation of concerns,
but this is a nice way of
AutoMapper to fill those in.
Now, this was the 3.9 version,
when I went to look at
the 4.2 version recently,
like, hey, it has changed.
>> Yeah.
>> So I was like okay,
the pride changed.
For a good reason, they probably
want more business logic
around that filling in from
the entity to the model.
So this prepare manufacturer model,
I thought I've got to, okay,
let's dig deeper into that one.
>> Sure.
>> Dig into that
a little bit further down,
I noticed while there's
the one-liner now,
but now it's using generics.
So when the 4.2 version
they even made it
cleaner to work with AutoMapper
by passing a generic data,
where you don't have to create
these extension methods everywhere.
>> I also suspect that this game at
the same time that AutoMapper
was because there was
a major breaking changes
to the latest framework
if I remember correctly,
so a lot of things changed
around how AutoMapper.
Yeah, so it definitely looks cleaner.
>> But it's nice to see how
much on top and we've been
working with these other libraries
how much they're on
top of making them better.
>> Yes.
>> Good.
>> All right. So yeah
we looked at services,
the domain entity and
that fills the model.
Let's see. Yeah, we didn't
make any logic yet.
In other words, this is a logic class
where you got to delete customer.
>> Yeah.
>> That's just tacking
on data deleted,
updating the record is not
really deleting anything.
>> So soft delete
more or less, right?
>> Exactly soft delete like
most architectures
that you see in it is
passing the customer entity
to this to work with.
What I like about this
is that if you were
to look at one those entities closer,
you see that they're pretty dumb.
It's just properties
and child properties,
I guess you'd say it, our child
collections as you see here,
but all the business logic
is in the right spot.
>> Right.
>> There not mixing or hiding
any other business logic
in your domain entities,
so that it's a really clean
and even at that minute level.
So I'm going to jump to
some data access stuff.
>> Yes.
>> Now, this is where I'm curious.
If you've seen Entity Framework
implemented like this before.
>> As a reminder, we're looking at
the.NET Framework Core stuff, right?
>> Yes, and yet they brought
this ported over to core really,
and you could even do
a comparison of
the different versions
as the effort it was there and it
wasn't that difficult is more so
waiting for core to have
certain standards in place.
>> Yes.
>> That framework had.
>> So while there are
some subtle differences like
the many-to-many relationships
that are expressed
differently on EF Code nowhere
in the previous expressions
like in [inaudible].
So I suspect that there were
some changes in the modal
around that but.
>> Yeah, there could have been.
But what I like about
the database model
itself for what I was
looking for an architecture,
the database is a very
simple database to follow.
So just zooming in on how customers
are related to other pieces.
It's not over-complicated
in those regards at all.
>> Yeah, for the sides
of the application.
I mean it looks fairly simple.
>> Sometimes you find really
crazy structures and [inaudible].
>> But naming or [inaudible]?
>> They try to make the
relational database
until like an object database,
and has based on craziness going on.
There's a little bit of
that error, very little,
but assuming things have struck
the right balance of that.
>> Yes.
>> When it becomes a really work
with relational database,
and the best way when you have
to work with things that are
more like entities like would you
probably use with a NoSQL Database.
>> Which is something that
was going to ask like if you
are a big org that
decides to use the one,
how hard would it be to transition
to say Cosmos DB from a SQL,
but not that it doesn't work but.
>> Now, you're going to get into
my example because this is where.
>> It's something
you've done here, okay.
>> So yes, they moved
from.NET Framework
6 to.NET Framework Core for all this,
and the way this architecture
is created is that they use
the Repository pattern.
So a service will work with
one or more repositories
to get his data,
and it works with his domain
map requests that provides us
flow and way of tacking on
metadata to the domain itself.
So it's not duplicating data
objects code I guess you'd like,
but when it comes to
a Domain mapper class,
we're going to look
at an example here.
>> So we're enriching
the data rather than.
>> Exactly, instead of putting
all those attributes around
your domain entities,
those data attributes,
they've done it in a way
that we use the Domain mapper
that keeps it in a clean way.
>> Nice and clean, cool.
>> We're going to see some
of that too. All right.
So here's a pretty common example
like GetCustomerID where it's
really almost like a pass-through.
>> Yeah.
>> Get ID. I've seen
this in many architectures
where we had this interface,
I have repository of
this type customer
in an on the interface has
his GetByID, seen this a lot.
So you had this I repository it has
GetByID insert update audio crud
operations on your domains.
IRepository is implemented by
EF Repository which is pretty nice.
I think it's kind of funny. I
think this comment is now gone,
but this is in the Source Code
of why they did this way.
>> I like comments.
>> But it's great why is there.
So I think they actually have taken,
but nonetheless I thought
is pretty neat they
actually are pretty open up like
this is why we did it this way.
>> Okay.
>> All right, so this
is where I'm curious
to get your opinion on this to
whether you like this or not.
So here you have the table property,
that's a type I queryable.
What's actually as a passthrough
here at the end of this via IDbSet.
Now, if we were to go to
the Customer Service class,
it's in the business logic.
Because we have that table property
exposed, in theory,
we're just projecting this query to
Entity Framework which is
then issuing that query.
So under the covers, you really,
in theory should be change out
any framework and put it
in let's say and Hibernate
or Dapper or some other ORM
that adheres to the interface.
Now, when people see
this example, they see,
okay, in the business logic,
you're doing a query.
DBAs probably don't like this.
Most DBAs I know. But
I found it to be,
not so much that I liked
it or didn't like it,
I found it to be interesting.
I never thought of using Entity
Framework in this way in the past,
and it does provide that
for quick queries like
this where you're doing
a query on a key and you
want to buy this order,
it's probably okay.
But if you have something
pretty complex,
I'm sure you want to do
something a different way.
I'm pulling back
that data. Now, have you
seen Entity Framework used
this way in the past?
>> Well, I've seen sometimes in
the framework getting
into business logic.
layers that shouldn't be there,
but at the same time,
it's a compromise between
efficiency and modularity.
So sometimes, you do it where it's
faster and more efficient and
sometimes it gets code smells
that are not the best.
So I would say use sparingly
and based on a case-by-case
scenario, but-
>> So in theory is if
your provider adheres to
those interfaces, you
have the same power?
>> Yeah.
>> So I found that to
be very interesting.
So I've given this talk
quite a few times to
where I will ask has
anybody seen this before.
I'm so impressed that
it's a lot of people
that are people that have just
come right out of college.
So they're professor taught
them how to use Entity Framework
in this way which
blows me away that they abstract
Entity Framework that far in college.
>> Well, sometimes too many layers
can also cause problems,
especially if you're a new developer
into a big codebase,
it becomes like a treasure hunt
where you have to find
where things get instantiated
and actually get cold.
So you're down the rabbit hole.
So I prefer to favor simplicity
over complicated stuff,
but this is a big solution show.
Again, having that ability
to modularize
your backend will be
fantastic to be able
to. Not many people do it.
They don't go from
Entity Framework to say Dapper,
just halfway through the project,
but I know a couple of guys.
I asked it on Twitter the other day,
and some people came back and said,
yeah, we actually moved
to a different framework,
because the one that
we initially chose was
not performing or did not
have the capability
to we're looking for.
So having the architecture to
support, that is fantastic.
>> Yes, we really could go down
the path of changing it up.
>> You said that we're
going to look into
some extensions row, right?
>> Yes, I was going to
wrap up on the mapper
to show that example how
this domain mapper works.
Then yes, I think we can
look at some plug-ins.
So you have this customer map class,
and when it comes to that attribute,
I'd like the length
of the system name,
instead of putting it
as an attribute on
the model or the domain entity.
It's here in the fluid type syntax
is getting tacked on.
>> Its separation of
concerns as well,
so you can update this one.
We are having to update
the unit base class.
>> Exactly, by keeping
the right spot.
Now, this isn't actually
a nopCommerce thing.
This isn't any framework.
So not to confuse out what's
getting inherited there.
I really to wrap up
the data side. I'm sorry.
Image files, you can store them
in the database file system.
The configuration management's
pretty rich here.
There's a lot of things
that are out-of-the-box
and help prepare for Azure,
also the readiness for
a caching solution.
I found this architecture pretty
cool to look at when it comes
to looking into ways how simple
how this was implemented.
If I can't take you directly
into code right now,
but that piece of it but it's
a great architecture to look at
on how do I implement Redis.
You'll probably be pleasantly
surprised on that.
So yes, what I want to point out.
One thing I glossed over is that you
can just run the application life.
You can run the storefront and
the administrator map to path.
We fire these up at a time and you
can log into the administrator
and really just play around,
create orders, break stuff.
They refresh the database
every 15 minutes,
and you can play around there.
When it comes to GitHub, of course,
definitely go out there to check out
the source code and let's
look at some code here.
So what I want to point out first off
actually probably we
dig into that code
itself when it comes
to work with GitHub.
Hopefully, this is easy
to see for everyone else.
You can work on GitHub
in two different ways.
You don't have to use Git,
you can actually use SVN.
I know there's not a lot
of people that use
SVN and why would they use it,
but it is nice how you can
actually use the SVN way of
doing things if you really want to
have those specific
versions available.
So if you're nopCommerce developer,
you are typically wanting to
test against previous versions.
>> Yes.
>> Having a structure
like this where SVN,
you have these different tags
that you can have out
there, those source code.
I know it's a copy, but nonetheless,
you might want to
keep those copies out
there for you to work with,
as well as what's going
on in trunk and develop.
So I actually worked with both.
I use SVN, how I connect
with GitHub as well as this.
I use Git first of all.,
then I work with things
in the normal fashion.
So really want to wrap up here,
when it comes to looking at
all the plugins that
come out of the box.
You don't really want to
get into detail on these,
but when you get that breadth
of what the architecture
looks and feels
like when it comes to
dependency injection
and how Entity Framework
is implemented,
and even with that mapper class
I showed at the end,
you can go to one of
the more complicated plug-ins
like this fixed or by
countries state zip.
What that is on
the shipping side is a plug-in
that you can manually put in
place and how you'd
calculate shipping cost.
There's also providers
for UPS and all them as
well where you can hit
a web service and and get that,
but this is one that's
out of the box.
So something like this has
a database table involved.
>> Right.
>> It has domain entities.
It has views that you're changing out
from administering to what
you're doing on the UI.
So what's most awesome about
this architecture is that it
just follows that same pattern of
the full application even
at the plug-in level.
>> Brilliant.
>> The plug-ins themselves, yes,
as a software developer that can
test where a lot of
I think developers
are attracted to create
their own plug-ins or themes also.
There's a market out
there for having different themes
that are nopCommerce.
As a matter of fact, I would
like to show you one example.
If we look at the nopCommerce site
to get a feel for what's out
there on the marketplace.
So yes, if you scroll through here,
I think this will even tell us
how these port numbers out.
I believe there's as we get
at the marketplace here,
you can see what's our free
or what you can pay for.
But actually, what I wanted to show
was the partner solution.
Here's a whole bunch
of examples out there.
Showcase. There we go.
So yes, you can see the
100,120 examples that are
out there that are
highlighted on their site.
They're now shared at 50,000
active sites using up Commerce.
Just a couple of years ago,
their number was 30,000.
>> Just growing and
growing dramatically.
>> They almost doubled in two years
on the number of active sites.
So yeah, when it comes to
the nopCommerce, I mean,
I think it even though it's been
around for close to 11 years,
as a.NET developer, you
didn't miss anything.
Now's the time to dig
into this solution.
There's other ones out there.
There's other e-commerce solutions
out there that are interesting,
but I think this one
has that stack for .NET
developer that really
is worth digging into.
>> Well, John. Thanks for
coming today and telling us all
about nopCommerce and
e-commerce, and.net core.
>> Yeah, thanks for having me.
>> If you want to learn about
an nopCommerce as well,
then make sure to check the
aka.ms/On.NET-NopCommerce.
Thank you.
[MUSIC]
