In this session, we will discuss the importance of code quality and then evaluate various code quality metrics available to measure and benchmark code quality using relevant examples using C#.
👉 Code Quality Conference 2024
https://codequalityconf.com/
📺 CSharp TV - Dev Streaming Destination http://csharp.tv
🌎 C# Corner - Community of Software and Data Developers https://www.c-sharpcorner.com/
#CSharpTV #csharpcorner #CodeQualityConf
Show More Show Less View Video Transcript
0:03
so hi all like today I bring you an
0:05
so hi all like today I bring you an
0:05
so hi all like today I bring you an interesting topic like how to measure
0:08
interesting topic like how to measure
0:08
interesting topic like how to measure code quality for the code you write
0:10
code quality for the code you write
0:10
code quality for the code you write definitely it's important and our leads
0:12
definitely it's important and our leads
0:12
definitely it's important and our leads keep bugging us like uh please write
0:14
keep bugging us like uh please write
0:14
keep bugging us like uh please write proper code proper code but no one tells
0:16
proper code proper code but no one tells
0:16
proper code proper code but no one tells us like how to quantify the quality so
0:20
us like how to quantify the quality so
0:20
us like how to quantify the quality so here we will see some techniques or or
0:21
here we will see some techniques or or
0:22
here we will see some techniques or or rather some measures that we can use to
0:25
rather some measures that we can use to
0:25
rather some measures that we can use to actually quantify the quality of
0:27
actually quantify the quality of
0:27
actually quantify the quality of code so before we move into the topic I
0:30
code so before we move into the topic I
0:30
code so before we move into the topic I would like to introduce myself so I work
0:33
would like to introduce myself so I work
0:33
would like to introduce myself so I work as a cloud architect and have a
0:35
as a cloud architect and have a
0:35
as a cloud architect and have a little less than 19 years of Industry
0:38
little less than 19 years of Industry
0:38
little less than 19 years of Industry experience I've designed digital
0:40
experience I've designed digital
0:40
experience I've designed digital Transformations using Cloud Ai and
0:42
Transformations using Cloud Ai and
0:42
Transformations using Cloud Ai and Robotics all these years and I have
0:45
Robotics all these years and I have
0:45
Robotics all these years and I have built Enterprise grade solutions for
0:47
built Enterprise grade solutions for
0:47
built Enterprise grade solutions for large and complex organizations across
0:48
large and complex organizations across
0:49
large and complex organizations across the globe I have published seven books
0:51
the globe I have published seven books
0:51
the globe I have published seven books with as like bpb and appas on asure I'm
0:55
with as like bpb and appas on asure I'm
0:55
with as like bpb and appas on asure I'm toab certified and I am a PhD from swis
0:58
toab certified and I am a PhD from swis
0:58
toab certified and I am a PhD from swis Clow business management in the field of
1:01
Clow business management in the field of
1:01
Clow business management in the field of uh digital transformation in
1:03
uh digital transformation in
1:03
uh digital transformation in healthcare so with this introduction so
1:06
healthcare so with this introduction so
1:06
healthcare so with this introduction so let me move ahead and what I have for
1:09
let me move ahead and what I have for
1:09
let me move ahead and what I have for you is like uh we'll start with on a
1:12
you is like uh we'll start with on a
1:12
you is like uh we'll start with on a very lighter note try to understand why
1:14
very lighter note try to understand why
1:14
very lighter note try to understand why we need to measure code quality in the
1:16
we need to measure code quality in the
1:16
we need to measure code quality in the first place so what is the role of code
1:18
first place so what is the role of code
1:18
first place so what is the role of code quality so once we understand that then
1:21
quality so once we understand that then
1:21
quality so once we understand that then we will be able
1:23
we will be able
1:23
we will be able to understand or interpret the quality
1:26
to understand or interpret the quality
1:26
to understand or interpret the quality metrics that we have in hand and how we
1:28
metrics that we have in hand and how we
1:28
metrics that we have in hand and how we can use this metrics to measure the code
1:30
can use this metrics to measure the code
1:30
can use this metrics to measure the code quality so we'll see that and post that
1:33
quality so we'll see that and post that
1:33
quality so we'll see that and post that like uh like we are going I I'm going to
1:36
like uh like we are going I I'm going to
1:36
like uh like we are going I I'm going to show you I'll open a project a live
1:38
show you I'll open a project a live
1:38
show you I'll open a project a live project and I will show you uh in like
1:42
project and I will show you uh in like
1:42
project and I will show you uh in like in maybe a two to three minutes or a
1:43
in maybe a two to three minutes or a
1:43
in maybe a two to three minutes or a five minutes activity so where I will
1:45
five minutes activity so where I will
1:45
five minutes activity so where I will show you like how to measure the code
1:48
show you like how to measure the code
1:48
show you like how to measure the code quality for that uh entire project and
1:51
quality for that uh entire project and
1:51
quality for that uh entire project and how to interpret it as well and post
1:54
how to interpret it as well and post
1:54
how to interpret it as well and post that uh like uh very important thing end
1:56
that uh like uh very important thing end
1:56
that uh like uh very important thing end of the day everything is a business we
1:58
of the day everything is a business we
1:58
of the day everything is a business we write a code to like
2:00
write a code to like
2:00
write a code to like uh someone earns or makes some Financial
2:02
uh someone earns or makes some Financial
2:02
uh someone earns or makes some Financial benefits out of the code we write and
2:04
benefits out of the code we write and
2:04
benefits out of the code we write and when we have some Financial benefits we
2:07
when we have some Financial benefits we
2:07
when we have some Financial benefits we have uh legal obligations so what is the
2:10
have uh legal obligations so what is the
2:10
have uh legal obligations so what is the impact of bad quality code on business I
2:14
impact of bad quality code on business I
2:14
impact of bad quality code on business I have a snip that I'll show you but uh we
2:17
have a snip that I'll show you but uh we
2:17
have a snip that I'll show you but uh we won't be diving much into the business
2:18
won't be diving much into the business
2:18
won't be diving much into the business impact of uh like code quality okay to
2:24
impact of uh like code quality okay to
2:24
impact of uh like code quality okay to start with why do we need to measure the
2:26
start with why do we need to measure the
2:26
start with why do we need to measure the quality of code so why it is needed
2:30
quality of code so why it is needed
2:30
quality of code so why it is needed so in the very first place so like uh if
2:34
so in the very first place so like uh if
2:34
so in the very first place so like uh if you don't write a proper code we will
2:37
you don't write a proper code we will
2:37
you don't write a proper code we will end up in introducing bug in our code
2:39
end up in introducing bug in our code
2:39
end up in introducing bug in our code base right the delivery will be
2:42
base right the delivery will be
2:42
base right the delivery will be defective you will have very fine guys
2:45
defective you will have very fine guys
2:45
defective you will have very fine guys sitting at the other end of the table
2:47
sitting at the other end of the table
2:47
sitting at the other end of the table and uh like uh chatting out very good
2:50
and uh like uh chatting out very good
2:50
and uh like uh chatting out very good functional requirements they will strike
2:53
functional requirements they will strike
2:53
functional requirements they will strike up very nice discussion with the
2:54
up very nice discussion with the
2:54
up very nice discussion with the customer or you yourself like many times
2:56
customer or you yourself like many times
2:56
customer or you yourself like many times like developers also get part of the
2:59
like developers also get part of the
2:59
like developers also get part of the team that does a business analysis so
3:01
team that does a business analysis so
3:01
team that does a business analysis so during the business analysis process so
3:04
during the business analysis process so
3:04
during the business analysis process so you will have the requirements Crystal
3:07
you will have the requirements Crystal
3:07
you will have the requirements Crystal Clear you'll be able to map all the nfrs
3:10
Clear you'll be able to map all the nfrs
3:10
Clear you'll be able to map all the nfrs so you'll have everything in place then
3:12
so you'll have everything in place then
3:12
so you'll have everything in place then you go and like try to translate those
3:16
you go and like try to translate those
3:16
you go and like try to translate those requirements into code so when you
3:18
requirements into code so when you
3:18
requirements into code so when you translate it if you don't if the
3:20
translate it if you don't if the
3:20
translate it if you don't if the translation is not proper or or rather
3:23
translation is not proper or or rather
3:23
translation is not proper or or rather in a hurry like uh we write a code maybe
3:25
in a hurry like uh we write a code maybe
3:25
in a hurry like uh we write a code maybe for various reasons many times I see
3:28
for various reasons many times I see
3:28
for various reasons many times I see like uh we get a push from from the
3:29
like uh we get a push from from the
3:30
like uh we get a push from from the customer that we need the delivery right
3:31
customer that we need the delivery right
3:31
customer that we need the delivery right away or like something like uh uh we
3:35
away or like something like uh uh we
3:35
away or like something like uh uh we need to like uh do this uh uh
3:39
need to like uh do this uh uh
3:40
need to like uh do this uh uh immediately or something like that due
3:41
immediately or something like that due
3:41
immediately or something like that due to some kind of pressure we end up in
3:43
to some kind of pressure we end up in
3:43
to some kind of pressure we end up in writing some bad buggy code and that
3:45
writing some bad buggy code and that
3:45
writing some bad buggy code and that adds to uh a defect delivery and finally
3:49
adds to uh a defect delivery and finally
3:49
adds to uh a defect delivery and finally what we deliver to the customer is uh
3:51
what we deliver to the customer is uh
3:51
what we deliver to the customer is uh like maybe like it meets the requirement
3:53
like maybe like it meets the requirement
3:53
like maybe like it meets the requirement but when the customer plays around with
3:55
but when the customer plays around with
3:55
but when the customer plays around with it uh then like uh it sees that its
3:58
it uh then like uh it sees that its
3:58
it uh then like uh it sees that its functionalities are not working prop
3:59
functionalities are not working prop
3:59
functionalities are not working prop properly as expected or as outlined
4:03
properly as expected or as outlined
4:03
properly as expected or as outlined during the requirement discussion so
4:05
during the requirement discussion so
4:05
during the requirement discussion so that is one of the areas then we have
4:07
that is one of the areas then we have
4:07
that is one of the areas then we have performance issues like uh very
4:10
performance issues like uh very
4:10
performance issues like uh very challenging so we all face that so like
4:13
challenging so we all face that so like
4:13
challenging so we all face that so like at least my team faces that if my team
4:15
at least my team faces that if my team
4:15
at least my team faces that if my team is watching now this video they can
4:17
is watching now this video they can
4:17
is watching now this video they can actually correlate like uh what I'm
4:20
actually correlate like uh what I'm
4:20
actually correlate like uh what I'm talking about so normally we do a
4:22
talking about so normally we do a
4:22
talking about so normally we do a performance test but rather like uh if
4:26
performance test but rather like uh if
4:26
performance test but rather like uh if you don't write the code properly so we
4:29
you don't write the code properly so we
4:29
you don't write the code properly so we are are liable to introduce performance
4:32
are are liable to introduce performance
4:32
are are liable to introduce performance issues so that can bring down your
4:35
issues so that can bring down your
4:35
issues so that can bring down your system or make your system slow okay so
4:39
system or make your system slow okay so
4:39
system or make your system slow okay so then we have the technical depth that is
4:41
then we have the technical depth that is
4:41
then we have the technical depth that is a very important thing we don't write
4:43
a very important thing we don't write
4:43
a very important thing we don't write proper code okay we don't give proper
4:46
proper code okay we don't give proper
4:46
proper code okay we don't give proper comments we don't indent it properly we
4:49
comments we don't indent it properly we
4:49
comments we don't indent it properly we do all kind of uh things that should not
4:52
do all kind of uh things that should not
4:52
do all kind of uh things that should not be done with the code and we end up
4:55
be done with the code and we end up
4:55
be done with the code and we end up creating a code that is lot of debt like
4:58
creating a code that is lot of debt like
4:58
creating a code that is lot of debt like what I mean by that is as a developer on
5:01
what I mean by that is as a developer on
5:01
what I mean by that is as a developer on the ground I write some bad code okay
5:04
the ground I write some bad code okay
5:04
the ground I write some bad code okay then I hand over the bad code to my like
5:08
then I hand over the bad code to my like
5:08
then I hand over the bad code to my like uh to my to another developer I take a
5:11
uh to my to another developer I take a
5:11
uh to my to another developer I take a release from the project and I move to
5:12
release from the project and I move to
5:12
release from the project and I move to the next project so the other developer
5:15
the next project so the other developer
5:15
the next project so the other developer will not be able to make out much of the
5:17
will not be able to make out much of the
5:17
will not be able to make out much of the things out of the code why because your
5:19
things out of the code why because your
5:19
things out of the code why because your code is uh not having that kind of
5:22
code is uh not having that kind of
5:22
code is uh not having that kind of quality that uh someone can easily read
5:25
quality that uh someone can easily read
5:25
quality that uh someone can easily read it and understand
5:26
it and understand
5:26
it and understand it and and that's how you add a
5:30
it and and that's how you add a
5:30
it and and that's how you add a technical debt to it okay you are adding
5:32
technical debt to it okay you are adding
5:32
technical debt to it okay you are adding a debt to it and uh this debt flows into
5:35
a debt to it and uh this debt flows into
5:35
a debt to it and uh this debt flows into the next thing that is the
5:37
the next thing that is the
5:37
the next thing that is the maintainability okay so the code won't
5:39
maintainability okay so the code won't
5:39
maintainability okay so the code won't be maintainable and you will end up in
5:41
be maintainable and you will end up in
5:41
be maintainable and you will end up in having like writing really bad uh code
5:44
having like writing really bad uh code
5:44
having like writing really bad uh code and uh like it's not maintainable and to
5:48
and uh like it's not maintainable and to
5:48
and uh like it's not maintainable and to whomever you are handling it over or or
5:49
whomever you are handling it over or or
5:49
whomever you are handling it over or or rather like you are on a day leave your
5:51
rather like you are on a day leave your
5:51
rather like you are on a day leave your peer comes and takes up your code he
5:54
peer comes and takes up your code he
5:54
peer comes and takes up your code he won't be able to make out anything out
5:55
won't be able to make out anything out
5:55
won't be able to make out anything out of the code he will like uh and like
5:58
of the code he will like uh and like
5:58
of the code he will like uh and like it's an not easy to maintain and also
6:01
it's an not easy to maintain and also
6:01
it's an not easy to maintain and also like you might have scenarios when there
6:03
like you might have scenarios when there
6:03
like you might have scenarios when there are defects or or you want to add some
6:05
are defects or or you want to add some
6:05
are defects or or you want to add some new features to it okay so if uh when
6:08
new features to it okay so if uh when
6:08
new features to it okay so if uh when you are adding some new features if the
6:10
you are adding some new features if the
6:10
you are adding some new features if the current code base is not clean it will
6:12
current code base is not clean it will
6:12
current code base is not clean it will be very difficult for it like for
6:14
be very difficult for it like for
6:14
be very difficult for it like for example like uh some class you will not
6:17
example like uh some class you will not
6:17
example like uh some class you will not be able to easily inherit okay you won't
6:19
be able to easily inherit okay you won't
6:19
be able to easily inherit okay you won't be able to extend some kind of
6:20
be able to extend some kind of
6:20
be able to extend some kind of functionality in some other code so it's
6:23
functionality in some other code so it's
6:23
functionality in some other code so it's very difficult to maintain that okay so
6:25
very difficult to maintain that okay so
6:25
very difficult to maintain that okay so if the code quality is not proper and
6:28
if the code quality is not proper and
6:28
if the code quality is not proper and with all these
6:30
with all these
6:30
with all these you you end up introducing a business
6:32
you you end up introducing a business
6:32
you you end up introducing a business loss okay because your customer will
6:35
loss okay because your customer will
6:35
loss okay because your customer will take this and whenever any customer
6:38
take this and whenever any customer
6:38
take this and whenever any customer signs a contract they have a penalty
6:40
signs a contract they have a penalty
6:40
signs a contract they have a penalty Clause okay if the delivery is not
6:43
Clause okay if the delivery is not
6:43
Clause okay if the delivery is not proper they can invoke the penalty
6:45
proper they can invoke the penalty
6:45
proper they can invoke the penalty clause and you'll get into the legal
6:47
clause and you'll get into the legal
6:47
clause and you'll get into the legal issues okay the customer will say take
6:51
issues okay the customer will say take
6:51
issues okay the customer will say take okay whatever it is so I I don't want to
6:53
okay whatever it is so I I don't want to
6:54
okay whatever it is so I I don't want to go ahead with
6:55
go ahead with
6:55
go ahead with uh uh like let me just deliver this
6:58
uh uh like let me just deliver this
6:58
uh uh like let me just deliver this project I don't want to go anymore like
7:00
project I don't want to go anymore like
7:00
project I don't want to go anymore like with you I'll find some other vendor for
7:02
with you I'll find some other vendor for
7:02
with you I'll find some other vendor for my other stuff or they can pull out the
7:04
my other stuff or they can pull out the
7:05
my other stuff or they can pull out the project and give it to someone else
7:06
project and give it to someone else
7:06
project and give it to someone else resulting in business loss and you'll
7:08
resulting in business loss and you'll
7:08
resulting in business loss and you'll get into legal Tangles like because they
7:10
get into legal Tangles like because they
7:10
get into legal Tangles like because they will invoke the penalty clause and in
7:12
will invoke the penalty clause and in
7:12
will invoke the penalty clause and in turn everything will lead to a
7:14
turn everything will lead to a
7:14
turn everything will lead to a reputation loss okay so like next time
7:17
reputation loss okay so like next time
7:17
reputation loss okay so like next time the customer will not like
7:19
the customer will not like
7:19
the customer will not like to get into this and at the same time
7:23
to get into this and at the same time
7:23
to get into this and at the same time they won't be able to like um drive this
7:27
they won't be able to like um drive this
7:27
they won't be able to like um drive this further or or or like they won't be be
7:29
further or or or like they won't be be
7:29
further or or or like they won't be be able to do a word of mouth to other
7:31
able to do a word of mouth to other
7:31
able to do a word of mouth to other customers in that reason as a result of
7:34
customers in that reason as a result of
7:34
customers in that reason as a result of which like uh in the industry like you
7:36
which like uh in the industry like you
7:36
which like uh in the industry like you won't have a good reputation and no one
7:38
won't have a good reputation and no one
7:38
won't have a good reputation and no one will come and take your code or or or
7:41
will come and take your code or or or
7:41
will come and take your code or or or take your service to build some product
7:43
take your service to build some product
7:43
take your service to build some product or
7:44
or
7:44
or something okay so with this background
7:48
something okay so with this background
7:48
something okay so with this background so let's see what are the different code
7:50
so let's see what are the different code
7:50
so let's see what are the different code quality
7:51
quality
7:51
quality metrics we have the very first two
7:54
metrics we have the very first two
7:54
metrics we have the very first two metrics that I show you here is like um
7:59
metrics that I show you here is like um
7:59
metrics that I show you here is like um like these are the golden metrics I
8:01
like these are the golden metrics I
8:01
like these are the golden metrics I would call out whenever you write any
8:03
would call out whenever you write any
8:03
would call out whenever you write any code so you should actually measure this
8:07
code so you should actually measure this
8:07
code so you should actually measure this uh metrics okay one is the very famous
8:10
uh metrics okay one is the very famous
8:10
uh metrics okay one is the very famous holed software metrics it's a very
8:12
holed software metrics it's a very
8:12
holed software metrics it's a very famous one and what exactly it is is so
8:16
famous one and what exactly it is is so
8:16
famous one and what exactly it is is so it goes to the roots of how the
8:18
it goes to the roots of how the
8:18
it goes to the roots of how the programming languages are built any of
8:20
programming languages are built any of
8:20
programming languages are built any of the programming languages it can be
8:22
the programming languages it can be
8:22
the programming languages it can be built using either it can be built or or
8:26
built using either it can be built or or
8:26
built using either it can be built or or when you write any program it comprises
8:28
when you write any program it comprises
8:28
when you write any program it comprises of tokens okay so what are these tokens
8:31
of tokens okay so what are these tokens
8:31
of tokens okay so what are these tokens they can be operant or operators okay so
8:36
they can be operant or operators okay so
8:36
they can be operant or operators okay so these uh operant and operators can
8:39
these uh operant and operators can
8:39
these uh operant and operators can actually Define the complexity like for
8:42
actually Define the complexity like for
8:42
actually Define the complexity like for example you writing something a code
8:44
example you writing something a code
8:44
example you writing something a code like int a equals B plus C okay this
8:48
like int a equals B plus C okay this
8:48
like int a equals B plus C okay this equal to is your operator the plus is an
8:50
equal to is your operator the plus is an
8:50
equal to is your operator the plus is an operator maybe let me show you in uh
8:53
operator maybe let me show you in uh
8:53
operator maybe let me show you in uh draw.io I'll be able to talk about like
8:56
draw.io I'll be able to talk about like
8:56
draw.io I'll be able to talk about like what I'm trying to say
8:59
what I'm trying to say
8:59
what I'm trying to say okay suppose I write a code something
9:01
okay suppose I write a code something
9:02
okay suppose I write a code something like this int a equal to B+ C I'll make
9:05
like this int a equal to B+ C I'll make
9:05
like this int a equal to B+ C I'll make it big so that it's well
9:11
visible
9:13
visible
9:13
visible text I'll make
9:23
it
9:26
it
9:26
it sorry okay
9:32
for some
9:34
for some
9:34
for some reasons okay this is good okay I write
9:37
reasons okay this is good okay I write
9:37
reasons okay this is good okay I write int a equals B plus C so equal to and
9:41
int a equals B plus C so equal to and
9:42
int a equals B plus C so equal to and plus are operators and all these are
9:44
plus are operators and all these are
9:44
plus are operators and all these are tokens in this variable a b c okay your
9:48
tokens in this variable a b c okay your
9:48
tokens in this variable a b c okay your program is nothing but it constitutes of
9:50
program is nothing but it constitutes of
9:50
program is nothing but it constitutes of all such tokens that can be either
9:52
all such tokens that can be either
9:52
all such tokens that can be either operator or your uh like these
9:57
operator or your uh like these
9:57
operator or your uh like these operants so these since our code
10:01
operants so these since our code
10:01
operants so these since our code consists of only this uh like operators
10:03
consists of only this uh like operators
10:03
consists of only this uh like operators or operants so these are the only areas
10:06
or operants so these are the only areas
10:06
or operants so these are the only areas or these are actually the areas that
10:08
or these are actually the areas that
10:08
or these are actually the areas that will add to the complexity of the code
10:11
will add to the complexity of the code
10:11
will add to the complexity of the code that's what like um Hall State software
10:15
that's what like um Hall State software
10:15
that's what like um Hall State software metrics talks about it's a colle any
10:17
metrics talks about it's a colle any
10:17
metrics talks about it's a colle any software program is a collection of
10:19
software program is a collection of
10:19
software program is a collection of tokens tokens that can be operat or
10:21
tokens tokens that can be operat or
10:21
tokens tokens that can be operat or operators and tokens Define the
10:24
operators and tokens Define the
10:24
operators and tokens Define the complexity and volume of a software
10:26
complexity and volume of a software
10:26
complexity and volume of a software volume why because more the number of
10:28
volume why because more the number of
10:28
volume why because more the number of lines of code more more uh Hefty is your
10:30
lines of code more more uh Hefty is your
10:30
lines of code more more uh Hefty is your software and uh how do you quantify the
10:33
software and uh how do you quantify the
10:33
software and uh how do you quantify the volume by this operant operators and all
10:37
volume by this operant operators and all
10:37
volume by this operant operators and all so how do you see as per Hall State it's
10:40
so how do you see as per Hall State it's
10:40
so how do you see as per Hall State it's not me who saying it's the hall State
10:42
not me who saying it's the hall State
10:42
not me who saying it's the hall State what Hallstead is proposed is any
10:44
what Hallstead is proposed is any
10:44
what Hallstead is proposed is any program length can be the total tokens
10:46
program length can be the total tokens
10:46
program length can be the total tokens in a program okay that means the number
10:48
in a program okay that means the number
10:48
in a program okay that means the number of operates and operators the program
10:51
of operates and operators the program
10:51
of operates and operators the program volume is nothing but it's the size of
10:53
volume is nothing but it's the size of
10:53
volume is nothing but it's the size of programming memory okay what is volume
10:56
programming memory okay what is volume
10:57
programming memory okay what is volume volume is a space that anything takes
10:59
volume is a space that anything takes
10:59
volume is a space that anything takes right so your program will take some
11:01
right so your program will take some
11:01
right so your program will take some space in the memory so the program
11:03
space in the memory so the program
11:03
space in the memory so the program volume is the size the program takes in
11:06
volume is the size the program takes in
11:06
volume is the size the program takes in the memory and program levels is the
11:08
the memory and program levels is the
11:08
the memory and program levels is the levels of abstraction provided by a
11:10
levels of abstraction provided by a
11:10
levels of abstraction provided by a program okay so when I say abstraction
11:13
program okay so when I say abstraction
11:13
program okay so when I say abstraction go think about the oops principle okay
11:15
go think about the oops principle okay
11:15
go think about the oops principle okay in objectoriented programming we
11:17
in objectoriented programming we
11:17
in objectoriented programming we abstract classes right so that what is
11:20
abstract classes right so that what is
11:20
abstract classes right so that what is there underhood is not visible we just
11:22
there underhood is not visible we just
11:22
there underhood is not visible we just make it visible what needs to be
11:24
make it visible what needs to be
11:24
make it visible what needs to be consumed or to be known by the end
11:26
consumed or to be known by the end
11:26
consumed or to be known by the end consumer not everything how it functions
11:29
consumer not everything how it functions
11:29
consumer not everything how it functions okay so the number of levels of
11:31
okay so the number of levels of
11:31
okay so the number of levels of abstractions we add that adds to the
11:35
abstractions we add that adds to the
11:35
abstractions we add that adds to the program level okay so with this three
11:38
program level okay so with this three
11:38
program level okay so with this three like program length program volume and
11:40
like program length program volume and
11:40
like program length program volume and program level are very famous software
11:42
program level are very famous software
11:42
program level are very famous software metrics that you should consider while
11:45
metrics that you should consider while
11:45
metrics that you should consider while like uh quantifying your code quality
11:48
like uh quantifying your code quality
11:48
like uh quantifying your code quality but these are not the ones there these
11:50
but these are not the ones there these
11:50
but these are not the ones there these are not the only ones there are lot of
11:52
are not the only ones there are lot of
11:52
are not the only ones there are lot of other metrics that H has proposed just
11:55
other metrics that H has proposed just
11:55
other metrics that H has proposed just for like we have a very short period so
11:57
for like we have a very short period so
11:57
for like we have a very short period so I can't uh uh take this Hall St end to
12:00
I can't uh uh take this Hall St end to
12:00
I can't uh uh take this Hall St end to end so like these are the main ones the
12:03
end so like these are the main ones the
12:03
end so like these are the main ones the next one is the cyclopedic complexity
12:06
next one is the cyclopedic complexity
12:06
next one is the cyclopedic complexity okay that is nothing but the flow of
12:08
okay that is nothing but the flow of
12:08
okay that is nothing but the flow of your code how your code flows okay for
12:11
your code how your code flows okay for
12:11
your code how your code flows okay for example let me again go
12:15
example let me again go
12:15
example let me again go here okay I write
12:18
here okay I write
12:18
here okay I write if a greater than
12:21
if a greater than
12:21
if a greater than b okay
12:27
then conso dot right
12:36
line hello
12:41
Okay one
12:51
minute
12:53
minute
12:53
minute okay
12:55
okay
12:55
okay else I write
13:03
console. right
13:09
line he so in this piece of code okay
13:13
line he so in this piece of code okay
13:13
line he so in this piece of code okay whatever piece of code I have
13:15
whatever piece of code I have
13:15
whatever piece of code I have here just
13:17
here just
13:17
here just one so whatever piece of code I have
13:20
one so whatever piece of code I have
13:20
one so whatever piece of code I have here so like you can see like uh one
13:23
here so like you can see like uh one
13:23
here so like you can see like uh one thing like uh uh it has two path correct
13:27
thing like uh uh it has two path correct
13:27
thing like uh uh it has two path correct one is this uh if if a is greater than b
13:30
one is this uh if if a is greater than b
13:30
one is this uh if if a is greater than b then we take this path like console.
13:32
then we take this path like console.
13:32
then we take this path like console. right line hello okay
13:36
right line hello okay
13:36
right line hello okay if if uh it's the other path then like
13:40
if if uh it's the other path then like
13:40
if if uh it's the other path then like else path then we have cons. right line
13:43
else path then we have cons. right line
13:43
else path then we have cons. right line High okay so my code has two path here
13:46
High okay so my code has two path here
13:46
High okay so my code has two path here okay if it would have been for example a
13:48
okay if it would have been for example a
13:48
okay if it would have been for example a while loop while a less than 10 so my
13:51
while loop while a less than 10 so my
13:51
while loop while a less than 10 so my code has 10 path okay there can be
13:53
code has 10 path okay there can be
13:53
code has 10 path okay there can be nested paths as well like we can have
13:55
nested paths as well like we can have
13:55
nested paths as well like we can have nested hips nested uh uh Loops so all
13:59
nested hips nested uh uh Loops so all
13:59
nested hips nested uh uh Loops so all these contribute to like cyclomatic
14:02
these contribute to like cyclomatic
14:02
these contribute to like cyclomatic complexity why it is complex because you
14:05
complexity why it is complex because you
14:06
complexity why it is complex because you are opening multiple paths in your code
14:10
are opening multiple paths in your code
14:10
are opening multiple paths in your code okay your execution can take multiple
14:12
okay your execution can take multiple
14:12
okay your execution can take multiple paths in your code okay so that is why
14:16
paths in your code okay so that is why
14:16
paths in your code okay so that is why we like introduce uh cyclomatic
14:18
we like introduce uh cyclomatic
14:18
we like introduce uh cyclomatic complexity
14:21
complexity
14:21
complexity correct so if you go by cyclomatic uh
14:24
correct so if you go by cyclomatic uh
14:24
correct so if you go by cyclomatic uh complexity here in this case my cytic
14:27
complexity here in this case my cytic
14:27
complexity here in this case my cytic complexity can be calculated ated as two
14:30
complexity can be calculated ated as two
14:30
complexity can be calculated ated as two based on the number of path it is taking
14:33
based on the number of path it is taking
14:33
based on the number of path it is taking okay so coming back here so what is
14:35
okay so coming back here so what is
14:35
okay so coming back here so what is cyclet complexity it is based on your
14:38
cyclet complexity it is based on your
14:38
cyclet complexity it is based on your code flow how your code flows okay more
14:41
code flow how your code flows okay more
14:41
code flow how your code flows okay more the number of code flows higher is the
14:43
the number of code flows higher is the
14:43
the number of code flows higher is the complexity greater is the probability of
14:45
complexity greater is the probability of
14:45
complexity greater is the probability of error why because if you have 10 paths
14:48
error why because if you have 10 paths
14:48
error why because if you have 10 paths like if Els if Els like this you have 10
14:51
like if Els if Els like this you have 10
14:51
like if Els if Els like this you have 10 paths okay so you may not be able to
14:54
paths okay so you may not be able to
14:54
paths okay so you may not be able to code coverage everything okay there then
14:57
code coverage everything okay there then
14:57
code coverage everything okay there then like there are high chances that some
14:59
like there are high chances that some
14:59
like there are high chances that some some piece of code will some path will
15:01
some piece of code will some path will
15:01
some piece of code will some path will get untested and like there uh is a
15:03
get untested and like there uh is a
15:03
get untested and like there uh is a chance that if if you have done some
15:06
chance that if if you have done some
15:06
chance that if if you have done some mistake there there is a probability
15:08
mistake there there is a probability
15:08
mistake there there is a probability that uh you are introducing an error and
15:11
that uh you are introducing an error and
15:11
that uh you are introducing an error and number of paths the program takes it is
15:12
number of paths the program takes it is
15:12
number of paths the program takes it is the cyclomatic complexity so these two
15:15
the cyclomatic complexity so these two
15:15
the cyclomatic complexity so these two are the golden metrics apart from it
15:18
are the golden metrics apart from it
15:18
are the golden metrics apart from it from Microsoft documentation you can see
15:21
from Microsoft documentation you can see
15:21
from Microsoft documentation you can see few more uh metrics like maintainability
15:24
few more uh metrics like maintainability
15:24
few more uh metrics like maintainability index okay so how well you can maintain
15:28
index okay so how well you can maintain
15:28
index okay so how well you can maintain your pro this is very important and
15:31
your pro this is very important and
15:31
your pro this is very important and whenever you are measuring the
15:32
whenever you are measuring the
15:32
whenever you are measuring the maintainability index make sure your
15:35
maintainability index make sure your
15:35
maintainability index make sure your code should be between 20 to 100 uh see
15:38
code should be between 20 to 100 uh see
15:38
code should be between 20 to 100 uh see above 50 is very difficult but at least
15:40
above 50 is very difficult but at least
15:40
above 50 is very difficult but at least 40 to 60 it should 40 to 50 like it
15:43
40 to 60 it should 40 to 50 like it
15:43
40 to 60 it should 40 to 50 like it should be ideally 10 to 20 is considered
15:46
should be ideally 10 to 20 is considered
15:46
should be ideally 10 to 20 is considered modate but if you are having a low score
15:49
modate but if you are having a low score
15:49
modate but if you are having a low score like 0 to 9 it is very dangerous and how
15:51
like 0 to 9 it is very dangerous and how
15:52
like 0 to 9 it is very dangerous and how it is deduced it is deduced from a
15:55
it is deduced it is deduced from a
15:55
it is deduced it is deduced from a formula I don't have the formula handy
15:57
formula I don't have the formula handy
15:57
formula I don't have the formula handy here you can go to the Microsoft site
15:59
here you can go to the Microsoft site
15:59
here you can go to the Microsoft site and see that it takes a len of a
16:02
and see that it takes a len of a
16:03
and see that it takes a len of a logarithmic calculation of Hall State
16:05
logarithmic calculation of Hall State
16:05
logarithmic calculation of Hall State volume cyclomatic complexity and the
16:08
volume cyclomatic complexity and the
16:08
volume cyclomatic complexity and the number of lines of code your code base
16:10
number of lines of code your code base
16:10
number of lines of code your code base has okay based on this like it does it
16:13
has okay based on this like it does it
16:13
has okay based on this like it does it calculates an index and that index is
16:16
calculates an index and that index is
16:16
calculates an index and that index is between 0 to 100 zero is very is less
16:18
between 0 to 100 zero is very is less
16:18
between 0 to 100 zero is very is less maintainable 100 is most most
16:21
maintainable 100 is most most
16:21
maintainable 100 is most most maintainable that is what the
16:22
maintainable that is what the
16:22
maintainable that is what the maintainability index speaks
16:25
maintainability index speaks
16:25
maintainability index speaks about
16:27
about
16:27
about Okay so uh like what is the importance
16:30
Okay so uh like what is the importance
16:30
Okay so uh like what is the importance of this so when you have a low
16:32
of this so when you have a low
16:32
of this so when you have a low maintainability index that clearly says
16:34
maintainability index that clearly says
16:34
maintainability index that clearly says that you can't hand over the code to
16:36
that you can't hand over the code to
16:36
that you can't hand over the code to someone and if you're handing it over
16:39
someone and if you're handing it over
16:39
someone and if you're handing it over then like he's going to struggle with
16:41
then like he's going to struggle with
16:41
then like he's going to struggle with understanding the code and uh taking
16:43
understanding the code and uh taking
16:43
understanding the code and uh taking your code forward apart from it if you
16:45
your code forward apart from it if you
16:45
your code forward apart from it if you introduce a new feature then if you see
16:47
introduce a new feature then if you see
16:47
introduce a new feature then if you see a maintainability index score of a uh is
16:50
a maintainability index score of a uh is
16:50
a maintainability index score of a uh is is so less then you should uh like it's
16:52
is so less then you should uh like it's
16:52
is so less then you should uh like it's very difficult to add uh feature and all
16:55
very difficult to add uh feature and all
16:55
very difficult to add uh feature and all and I will give you a very nice example
16:57
and I will give you a very nice example
16:57
and I will give you a very nice example like few years back like we were taking
16:59
like few years back like we were taking
16:59
like few years back like we were taking a project from another vendor okay so it
17:02
a project from another vendor okay so it
17:02
a project from another vendor okay so it was a vendor switch the very first thing
17:04
was a vendor switch the very first thing
17:04
was a vendor switch the very first thing that we did was we calculated the
17:06
that we did was we calculated the
17:06
that we did was we calculated the maintainability index but again this was
17:08
maintainability index but again this was
17:08
maintainability index but again this was not this formula we never used uh we
17:10
not this formula we never used uh we
17:10
not this formula we never used uh we used hallad volume and cyclet complexity
17:13
used hallad volume and cyclet complexity
17:13
used hallad volume and cyclet complexity but lines of code was not facted in so
17:15
but lines of code was not facted in so
17:15
but lines of code was not facted in so we used uh we calculated the
17:18
we used uh we calculated the
17:18
we used uh we calculated the maintainability index and we saw that
17:20
maintainability index and we saw that
17:20
maintainability index and we saw that the maintainability of the code is very
17:22
the maintainability of the code is very
17:22
the maintainability of the code is very low we went back to the customer and
17:25
low we went back to the customer and
17:25
low we went back to the customer and said that the code is not maintainable
17:27
said that the code is not maintainable
17:27
said that the code is not maintainable at all we can't take a and uh get
17:30
at all we can't take a and uh get
17:30
at all we can't take a and uh get started with it right away this code
17:32
started with it right away this code
17:32
started with it right away this code requires refactoring okay so what is the
17:36
requires refactoring okay so what is the
17:37
requires refactoring okay so what is the next thing that will fall from or like
17:39
next thing that will fall from or like
17:39
next thing that will fall from or like that will happen from this uh
17:41
that will happen from this uh
17:41
that will happen from this uh maintainability index that is nothing
17:43
maintainability index that is nothing
17:43
maintainability index that is nothing but like uh refactoring of the code okay
17:46
but like uh refactoring of the code okay
17:47
but like uh refactoring of the code okay if the code is not maintainable so the
17:49
if the code is not maintainable so the
17:49
if the code is not maintainable so the maintainable index will be low so that
17:52
maintainable index will be low so that
17:52
maintainable index will be low so that is where you can decide on to make the
17:54
is where you can decide on to make the
17:54
is where you can decide on to make the code maintainable I need to refactor and
17:56
code maintainable I need to refactor and
17:56
code maintainable I need to refactor and again do it so for our customer like
17:58
again do it so for our customer like
17:58
again do it so for our customer like with the the project contracts were
18:00
with the the project contracts were
18:00
with the the project contracts were changed and customer we could prove the
18:02
changed and customer we could prove the
18:03
changed and customer we could prove the customer that this is the score that
18:04
customer that this is the score that
18:04
customer that this is the score that comes and we are not going to take this
18:06
comes and we are not going to take this
18:06
comes and we are not going to take this project ases and maintain it so we need
18:08
project ases and maintain it so we need
18:08
project ases and maintain it so we need to refactor it and then take it forward
18:11
to refactor it and then take it forward
18:11
to refactor it and then take it forward so this it changed the scope of the
18:13
so this it changed the scope of the
18:13
so this it changed the scope of the contract the S got changed okay so
18:17
contract the S got changed okay so
18:17
contract the S got changed okay so another important thing is depth of
18:19
another important thing is depth of
18:19
another important thing is depth of inheritance I'll give you
18:21
inheritance I'll give you
18:21
inheritance I'll give you example let me again go back to
18:25
example let me again go back to
18:25
example let me again go back to draw. okay I have a class A
18:38
okay I have a class here we have another
18:43
okay I have a class here we have another
18:43
okay I have a class here we have another class B
18:45
class B
18:45
class B okay we
18:49
have a third class C okay
18:55
have a third class C okay
18:55
have a third class C okay and we have
18:58
and we have
18:58
and we have say another class D I'll give an
19:01
say another class D I'll give an
19:01
say another class D I'll give an example okay
19:05
example okay
19:05
example okay B inherits from a c inherits for
19:11
B inherits from a c inherits for
19:11
B inherits from a c inherits for D and D inherits again
19:15
D and D inherits again
19:15
D and D inherits again from a okay this is how your inheritance
19:20
from a okay this is how your inheritance
19:20
from a okay this is how your inheritance looks like may be any programming
19:22
looks like may be any programming
19:22
looks like may be any programming language these are our classes a b c and
19:24
language these are our classes a b c and
19:24
language these are our classes a b c and d are classes so here we have three
19:27
d are classes so here we have three
19:27
d are classes so here we have three levels of inheritance okay we have three
19:30
levels of inheritance okay we have three
19:30
levels of inheritance okay we have three levels of inheritance suppose B is
19:33
levels of inheritance suppose B is
19:34
levels of inheritance suppose B is implementing a function from a I mean to
19:36
implementing a function from a I mean to
19:36
implementing a function from a I mean to say like B is like uh overriding a
19:39
say like B is like uh overriding a
19:39
say like B is like uh overriding a function from a okay and D is also
19:42
function from a okay and D is also
19:42
function from a okay and D is also overriding the same function and there
19:43
overriding the same function and there
19:43
overriding the same function and there is some changes in that function or
19:45
is some changes in that function or
19:45
is some changes in that function or overloading sorry let's call it uh
19:48
overloading sorry let's call it uh
19:48
overloading sorry let's call it uh overloading okay so it's both of them
19:50
overloading okay so it's both of them
19:50
overloading okay so it's both of them are overloading some function from a and
19:52
are overloading some function from a and
19:52
are overloading some function from a and both and a there is some change in the
19:54
both and a there is some change in the
19:54
both and a there is some change in the base class so what will happen is the
19:56
base class so what will happen is the
19:56
base class so what will happen is the normally like what the developer did was
19:58
normally like what the developer did was
19:58
normally like what the developer did was he made some changes in class A based on
20:01
he made some changes in class A based on
20:01
he made some changes in class A based on the requirements of D okay then this B
20:03
the requirements of D okay then this B
20:03
the requirements of D okay then this B and C goes into toss okay because he did
20:07
and C goes into toss okay because he did
20:07
and C goes into toss okay because he did not consider or studied BNC properly
20:09
not consider or studied BNC properly
20:09
not consider or studied BNC properly without studying BNC he CH made some
20:12
without studying BNC he CH made some
20:12
without studying BNC he CH made some changes in the Base Class based on the
20:13
changes in the Base Class based on the
20:13
changes in the Base Class based on the requirements from D so your entire
20:15
requirements from D so your entire
20:15
requirements from D so your entire system goes on scoop okay so there your
20:19
system goes on scoop okay so there your
20:19
system goes on scoop okay so there your uh it becomes complex so the depth of
20:22
uh it becomes complex so the depth of
20:22
uh it becomes complex so the depth of inheritance is very important for
20:24
inheritance is very important for
20:24
inheritance is very important for example like I'll give you another
20:25
example like I'll give you another
20:25
example like I'll give you another example so like a makes some changes B
20:28
example so like a makes some changes B
20:28
example so like a makes some changes B is inheriting it so the changes are in
20:31
is inheriting it so the changes are in
20:31
is inheriting it so the changes are in accordance to B but C is also inheriting
20:33
accordance to B but C is also inheriting
20:33
accordance to B but C is also inheriting from B and it's it can't consume the
20:35
from B and it's it can't consume the
20:35
from B and it's it can't consume the changes that a has made okay so like
20:38
changes that a has made okay so like
20:38
changes that a has made okay so like again like we are introducing error in
20:40
again like we are introducing error in
20:40
again like we are introducing error in this inheritance so number of levels of
20:43
this inheritance so number of levels of
20:43
this inheritance so number of levels of inheritance that is nothing but your
20:45
inheritance that is nothing but your
20:45
inheritance that is nothing but your depth of inheritance in this case the
20:46
depth of inheritance in this case the
20:46
depth of inheritance in this case the depth of inheritance is
20:48
depth of inheritance is
20:48
depth of inheritance is three okay
20:51
three okay
20:51
three okay so let me go
20:53
so let me go
20:53
so let me go here so all all that I said number of
20:57
here so all all that I said number of
20:57
here so all all that I said number of different classes that inherent from one
20:59
different classes that inherent from one
20:59
different classes that inherent from one another and more The Inheritance greater
21:01
another and more The Inheritance greater
21:01
another and more The Inheritance greater is the chance for introducing error due
21:03
is the chance for introducing error due
21:03
is the chance for introducing error due to modification in Base Class okay so
21:06
to modification in Base Class okay so
21:06
to modification in Base Class okay so keep your inheritance minimum but again
21:08
keep your inheritance minimum but again
21:08
keep your inheritance minimum but again you need to inherit or else like your
21:09
you need to inherit or else like your
21:09
you need to inherit or else like your code uh will not be reusable but you
21:12
code uh will not be reusable but you
21:12
code uh will not be reusable but you need to strike that balance so you need
21:13
need to strike that balance so you need
21:14
need to strike that balance so you need to write a proper code but keep
21:16
to write a proper code but keep
21:16
to write a proper code but keep measuring the depth of
21:18
measuring the depth of
21:18
measuring the depth of inheritance another important thing is
21:20
inheritance another important thing is
21:20
inheritance another important thing is class coupling that we know right what
21:22
class coupling that we know right what
21:22
class coupling that we know right what we do when we are writing any code like
21:25
we do when we are writing any code like
21:25
we do when we are writing any code like we have two functions okay so in one
21:27
we have two functions okay so in one
21:27
we have two functions okay so in one function uh two functions in different
21:30
function uh two functions in different
21:30
function uh two functions in different class okay so I write something like uh
21:34
class okay so I write something like uh
21:34
class okay so I write something like uh Class A okay this class A has um like
21:39
Class A okay this class A has um like
21:39
Class A okay this class A has um like two variables okay like int a okay maybe
21:44
two variables okay like int a okay maybe
21:44
two variables okay like int a okay maybe like they should be properties but uh
21:46
like they should be properties but uh
21:46
like they should be properties but uh I'm just like uh for to save time I'm
21:48
I'm just like uh for to save time I'm
21:48
I'm just like uh for to save time I'm just writing it this way public
21:51
just writing it this way public
21:52
just writing it this way public in public in uh B okay then I have one
21:57
in public in uh B okay then I have one
21:57
in public in uh B okay then I have one more class
22:01
then I have one more
22:03
then I have one more
22:03
then I have one more class so in this class I have a
22:09
function I have a
22:11
function I have a
22:11
function I have a function so this function what it will
22:13
function so this function what it will
22:13
function so this function what it will do
22:15
do
22:15
do is maybe something like
22:18
is maybe something like
22:18
is maybe something like public int like maybe
22:22
public int like maybe
22:22
public int like maybe funk I will take a of a you understand
22:27
funk I will take a of a you understand
22:27
funk I will take a of a you understand this right uh H sorry this will be a of
22:33
this right uh H sorry this will be a of
22:33
this right uh H sorry this will be a of a
22:35
a
22:35
a and and and I have my regular business
22:38
and and and I have my regular business
22:38
and and and I have my regular business code here so what I'm doing is I'm
22:40
code here so what I'm doing is I'm
22:40
code here so what I'm doing is I'm trying to couple this class say in this
22:42
trying to couple this class say in this
22:42
trying to couple this class say in this okay so in this uh function so like uh I
22:46
okay so in this uh function so like uh I
22:46
okay so in this uh function so like uh I have this class A this uh a object is
22:49
have this class A this uh a object is
22:49
have this class A this uh a object is passed here so we are introducing some
22:51
passed here so we are introducing some
22:51
passed here so we are introducing some kind of a coupling out here so and this
22:54
kind of a coupling out here so and this
22:54
kind of a coupling out here so and this adds to complexity because if if there
22:56
adds to complexity because if if there
22:56
adds to complexity because if if there are if if there are like if if something
22:59
are if if there are like if if something
22:59
are if if there are like if if something breaks here okay if something breaks
23:02
breaks here okay if something breaks
23:02
breaks here okay if something breaks here in a okay then the same thing it
23:04
here in a okay then the same thing it
23:04
here in a okay then the same thing it will have an impact on function and it
23:06
will have an impact on function and it
23:06
will have an impact on function and it will break here okay so like if you go
23:11
will break here okay so like if you go
23:11
will break here okay so like if you go by that so this also adds to like code
23:15
by that so this also adds to like code
23:15
by that so this also adds to like code complexity okay so this is the class
23:17
complexity okay so this is the class
23:17
complexity okay so this is the class compling impact so in another class we
23:19
compling impact so in another class we
23:19
compling impact so in another class we are using another class that has a
23:21
are using another class that has a
23:21
are using another class that has a function and that function takes uh like
23:25
function and that function takes uh like
23:25
function and that function takes uh like a class variable and that class variable
23:27
a class variable and that class variable
23:27
a class variable and that class variable like if there are any changes in the
23:28
like if there are any changes in the
23:28
like if there are any changes in the class that can actually have some uh
23:31
class that can actually have some uh
23:31
class that can actually have some uh like impact on the code the very next uh
23:35
like impact on the code the very next uh
23:35
like impact on the code the very next uh code quality metrics is the number of
23:37
code quality metrics is the number of
23:37
code quality metrics is the number of lines of source code you have okay it
23:40
lines of source code you have okay it
23:40
lines of source code you have okay it can also include a blank lines so
23:42
can also include a blank lines so
23:42
can also include a blank lines so whenever you're calculating the number
23:44
whenever you're calculating the number
23:44
whenever you're calculating the number of source code because more the bulky
23:46
of source code because more the bulky
23:46
of source code because more the bulky your program is more is the chance that
23:48
your program is more is the chance that
23:49
your program is more is the chance that you can introduce an error okay so if
23:51
you can introduce an error okay so if
23:51
you can introduce an error okay so if the total number of lines in a program
23:53
the total number of lines in a program
23:53
the total number of lines in a program like is uh some like x amount so your it
23:58
like is uh some like x amount so your it
23:58
like is uh some like x amount so your it it it's like proportionately your code
24:00
it it's like proportionately your code
24:00
it it's like proportionately your code is complex by x amount okay then the
24:03
is complex by x amount okay then the
24:03
is complex by x amount okay then the lines of executable code that means the
24:06
lines of executable code that means the
24:06
lines of executable code that means the number of codes that are ex actually
24:08
number of codes that are ex actually
24:08
number of codes that are ex actually executing okay it can also include the
24:10
executing okay it can also include the
24:10
executing okay it can also include the blank lines when your control flow is
24:12
blank lines when your control flow is
24:12
blank lines when your control flow is traversing through your code base it's a
24:14
traversing through your code base it's a
24:14
traversing through your code base it's a number of operations that is actually
24:17
number of operations that is actually
24:17
number of operations that is actually there in that uh code
24:19
there in that uh code
24:19
there in that uh code base then few more metrics that I will
24:23
base then few more metrics that I will
24:23
base then few more metrics that I will call it out duplicate code so when we
24:25
call it out duplicate code so when we
24:25
call it out duplicate code so when we write any code like uh it's a
24:27
write any code like uh it's a
24:27
write any code like uh it's a maintainability issue actually so when
24:30
maintainability issue actually so when
24:30
maintainability issue actually so when you write any code you tend to like what
24:32
you write any code you tend to like what
24:32
you write any code you tend to like what to do is like uh
24:35
to do is like uh
24:35
to do is like uh you do write some duplicate code like we
24:38
you do write some duplicate code like we
24:38
you do write some duplicate code like we keep repeating the code again and again
24:40
keep repeating the code again and again
24:40
keep repeating the code again and again okay instead like we should create a
24:41
okay instead like we should create a
24:41
okay instead like we should create a function have all those code there and
24:43
function have all those code there and
24:43
function have all those code there and call the function from different places
24:45
call the function from different places
24:45
call the function from different places okay that will reduce the code
24:46
okay that will reduce the code
24:47
okay that will reduce the code duplication
24:48
duplication
24:48
duplication percentage then is the code test
24:50
percentage then is the code test
24:50
percentage then is the code test coverage okay but again code duplication
24:53
coverage okay but again code duplication
24:53
coverage okay but again code duplication percent is something that you won't be
24:54
percent is something that you won't be
24:54
percent is something that you won't be able to measure using your uh Visual
24:56
able to measure using your uh Visual
24:56
able to measure using your uh Visual Studio or vs code you like but ID is
24:59
Studio or vs code you like but ID is
24:59
Studio or vs code you like but ID is like idea webstorm uh int intellig ID
25:03
like idea webstorm uh int intellig ID
25:03
like idea webstorm uh int intellig ID and webstorm they can actually help you
25:05
and webstorm they can actually help you
25:05
and webstorm they can actually help you detect this and code cover test coverage
25:08
detect this and code cover test coverage
25:08
detect this and code cover test coverage is a very important parameter so I can
25:10
is a very important parameter so I can
25:10
is a very important parameter so I can give a nice example I'll come to that
25:12
give a nice example I'll come to that
25:12
give a nice example I'll come to that what it means uh so like uh when I
25:15
what it means uh so like uh when I
25:15
what it means uh so like uh when I started my career so like uh in
25:18
started my career so like uh in
25:18
started my career so like uh in Microsoft like uh we used to like uh
25:21
Microsoft like uh we used to like uh
25:21
Microsoft like uh we used to like uh test uh Windows operating system so we
25:23
test uh Windows operating system so we
25:23
test uh Windows operating system so we used to fix code there and uh test the
25:25
used to fix code there and uh test the
25:25
used to fix code there and uh test the Windows XP so we used to to release a
25:29
Windows XP so we used to to release a
25:29
Windows XP so we used to to release a code coverage percentage
25:32
code coverage percentage
25:32
code coverage percentage there mostly I won't call out the
25:34
there mostly I won't call out the
25:34
there mostly I won't call out the numbers but based on the percentage you
25:37
numbers but based on the percentage you
25:37
numbers but based on the percentage you choose whether to release the product or
25:39
choose whether to release the product or
25:39
choose whether to release the product or not because if the code coverage
25:42
not because if the code coverage
25:42
not because if the code coverage percentage is for example 40% the
25:45
percentage is for example 40% the
25:45
percentage is for example 40% the testing is fairly good enough your test
25:48
testing is fairly good enough your test
25:48
testing is fairly good enough your test has tested at least 40% of the code base
25:51
has tested at least 40% of the code base
25:51
has tested at least 40% of the code base whatever test cases automatic test cases
25:53
whatever test cases automatic test cases
25:53
whatever test cases automatic test cases you have executed it has touched upon
25:55
you have executed it has touched upon
25:55
you have executed it has touched upon 40% of the code base okay now
25:59
40% of the code base okay now
25:59
40% of the code base okay now uh like uh uh suppose you have a code
26:02
uh like uh uh suppose you have a code
26:02
uh like uh uh suppose you have a code test coverage of 70% it's very difficult
26:05
test coverage of 70% it's very difficult
26:05
test coverage of 70% it's very difficult to reach a code test coverage of 70%
26:07
to reach a code test coverage of 70%
26:07
to reach a code test coverage of 70% like on the grounds like uh so it's if
26:11
like on the grounds like uh so it's if
26:11
like on the grounds like uh so it's if 70% then the code is very good whatever
26:13
70% then the code is very good whatever
26:13
70% then the code is very good whatever test cases automated test cases you have
26:15
test cases automated test cases you have
26:15
test cases automated test cases you have designed it has touched upon uh like the
26:17
designed it has touched upon uh like the
26:17
designed it has touched upon uh like the entire code base then a very modern kind
26:20
entire code base then a very modern kind
26:20
entire code base then a very modern kind of thing it has very recently it has
26:22
of thing it has very recently it has
26:22
of thing it has very recently it has sced up like codes Smiles okay that is
26:25
sced up like codes Smiles okay that is
26:25
sced up like codes Smiles okay that is use of depricated apas normally we do it
26:27
use of depricated apas normally we do it
26:27
use of depricated apas normally we do it right we write a code
26:28
right we write a code
26:28
right we write a code we write some apis and tomorrow we tend
26:31
we write some apis and tomorrow we tend
26:31
we write some apis and tomorrow we tend to forget it and it again Pops Pops out
26:35
to forget it and it again Pops Pops out
26:35
to forget it and it again Pops Pops out and haunts us back as uh deprecated apis
26:39
and haunts us back as uh deprecated apis
26:39
and haunts us back as uh deprecated apis okay this code should be regularly
26:40
okay this code should be regularly
26:40
okay this code should be regularly audited and upgraded so normally so you
26:43
audited and upgraded so normally so you
26:43
audited and upgraded so normally so you should check for the deprecated apas you
26:45
should check for the deprecated apas you
26:45
should check for the deprecated apas you should be regularly auditing the code if
26:48
should be regularly auditing the code if
26:48
should be regularly auditing the code if there are any deprecated apas you need
26:50
there are any deprecated apas you need
26:50
there are any deprecated apas you need to take the necessary action either
26:52
to take the necessary action either
26:52
to take the necessary action either upgrade it or like go for the next
26:54
upgrade it or like go for the next
26:54
upgrade it or like go for the next alternative substitute you have okay so
26:58
alternative substitute you have okay so
26:58
alternative substitute you have okay so these are few of the metrics that uh uh
27:01
these are few of the metrics that uh uh
27:01
these are few of the metrics that uh uh I had thought of so I would present one
27:04
I had thought of so I would present one
27:04
I had thought of so I would present one is Hall State cyclomatic maintainability
27:06
is Hall State cyclomatic maintainability
27:06
is Hall State cyclomatic maintainability index depth of inheritance class
27:08
index depth of inheritance class
27:08
index depth of inheritance class coupling lines of source code number of
27:10
coupling lines of source code number of
27:10
coupling lines of source code number of executable code code duplication test
27:12
executable code code duplication test
27:13
executable code code duplication test coverage and code smells so these are
27:14
coverage and code smells so these are
27:14
coverage and code smells so these are few of the important ones that I covered
27:16
few of the important ones that I covered
27:16
few of the important ones that I covered but uh trust me these are just uh maybe
27:19
but uh trust me these are just uh maybe
27:19
but uh trust me these are just uh maybe few of the metrics that you can think of
27:22
few of the metrics that you can think of
27:22
few of the metrics that you can think of there are lot of other metrics as well
27:24
there are lot of other metrics as well
27:24
there are lot of other metrics as well like lot of more and more metrics so you
27:27
like lot of more and more metrics so you
27:27
like lot of more and more metrics so you can think of and more you make your code
27:31
can think of and more you make your code
27:31
can think of and more you make your code measurable the quality of code
27:33
measurable the quality of code
27:33
measurable the quality of code measurable if you're able to quantify
27:35
measurable if you're able to quantify
27:35
measurable if you're able to quantify the quality of code then half of your
27:37
the quality of code then half of your
27:37
the quality of code then half of your journey is W actually in in producing a
27:41
journey is W actually in in producing a
27:41
journey is W actually in in producing a good project okay and what are the
27:44
good project okay and what are the
27:44
good project okay and what are the different tools that uh can help us in
27:47
different tools that uh can help us in
27:47
different tools that uh can help us in doing code quality metrics few these are
27:49
doing code quality metrics few these are
27:49
doing code quality metrics few these are this is a very comprehensive list at
27:52
this is a very comprehensive list at
27:52
this is a very comprehensive list at least the ones that I have used and I
27:54
least the ones that I have used and I
27:54
least the ones that I have used and I have seen but uh you'll find lot of good
27:57
have seen but uh you'll find lot of good
27:57
have seen but uh you'll find lot of good Tools around
27:58
Tools around
27:58
Tools around like uh I could think of Visual Studio
28:00
like uh I could think of Visual Studio
28:00
like uh I could think of Visual Studio vs code
28:02
vs code
28:02
vs code intellig sonar Cube sonar cube is very
28:04
intellig sonar Cube sonar cube is very
28:04
intellig sonar Cube sonar cube is very popularly used dip scan like if you're a
28:07
popularly used dip scan like if you're a
28:07
popularly used dip scan like if you're a JavaScript and a typescript you write
28:09
JavaScript and a typescript you write
28:09
JavaScript and a typescript you write lot of a lot of angular program you
28:11
lot of a lot of angular program you
28:11
lot of a lot of angular program you should consider doing a dip scan okay so
28:15
should consider doing a dip scan okay so
28:15
should consider doing a dip scan okay so with this
28:16
with this
28:16
with this background uh like let me do like it's
28:18
background uh like let me do like it's
28:18
background uh like let me do like it's all or else it will look all Theory so I
28:21
all or else it will look all Theory so I
28:21
all or else it will look all Theory so I thought like let me do some Visual
28:23
thought like let me do some Visual
28:23
thought like let me do some Visual Studio activity so I will show you in
28:25
Studio activity so I will show you in
28:25
Studio activity so I will show you in Visual Studio how you can actually
28:26
Visual Studio how you can actually
28:26
Visual Studio how you can actually analyze the code it's very very
28:28
analyze the code it's very very
28:28
analyze the code it's very very easy so here I have a project okay I
28:32
easy so here I have a project okay I
28:32
easy so here I have a project okay I have a project so like uh it's my
28:35
have a project so like uh it's my
28:35
have a project so like uh it's my personal development that I'm like
28:37
personal development that I'm like
28:37
personal development that I'm like building some some stuff okay so it
28:41
building some some stuff okay so it
28:41
building some some stuff okay so it looks uh there are five projects and in
28:45
looks uh there are five projects and in
28:45
looks uh there are five projects and in DB scripts also okay it's just a script
28:47
DB scripts also okay it's just a script
28:48
DB scripts also okay it's just a script okay so like uh and for this five
28:50
okay so like uh and for this five
28:50
okay so like uh and for this five projects let me see what is the
28:52
projects let me see what is the
28:52
projects let me see what is the complexity okay let me see just for this
28:56
complexity okay let me see just for this
28:56
complexity okay let me see just for this Enterprise startup toolkit what is the
28:58
Enterprise startup toolkit what is the
28:58
Enterprise startup toolkit what is the complexity okay I can go to analyze very
29:00
complexity okay I can go to analyze very
29:00
complexity okay I can go to analyze very easy calculate code Matrix for
29:03
easy calculate code Matrix for
29:03
easy calculate code Matrix for Enterprise startup toolkit see for this
29:07
Enterprise startup toolkit see for this
29:08
Enterprise startup toolkit see for this particular project it will give me like
29:10
particular project it will give me like
29:10
particular project it will give me like uh see like uh the program okay like uh
29:14
uh see like uh the program okay like uh
29:14
uh see like uh the program okay like uh there is some specific class 404
29:15
there is some specific class 404
29:15
there is some specific class 404 requirement for this class like
29:18
requirement for this class like
29:18
requirement for this class like maintainable it's it's a highly
29:19
maintainable it's it's a highly
29:19
maintainable it's it's a highly maintainable code okay that means my
29:22
maintainable code okay that means my
29:22
maintainable code okay that means my team has done a good job then cyclomatic
29:25
team has done a good job then cyclomatic
29:25
team has done a good job then cyclomatic complexity okay so all these so this
29:28
complexity okay so all these so this
29:28
complexity okay so all these so this green is orange it will show you green
29:30
green is orange it will show you green
29:30
green is orange it will show you green Amber red okay number of lines of code
29:32
Amber red okay number of lines of code
29:33
Amber red okay number of lines of code so all these like this maintainability
29:35
so all these like this maintainability
29:35
so all these like this maintainability index I told you right it is between 0
29:36
index I told you right it is between 0
29:36
index I told you right it is between 0 to 100 so it's calculating those
29:39
to 100 so it's calculating those
29:39
to 100 so it's calculating those maintainability index one more thing you
29:41
maintainability index one more thing you
29:41
maintainability index one more thing you can do is I did it just for a single
29:43
can do is I did it just for a single
29:43
can do is I did it just for a single project what if I want to measure all
29:45
project what if I want to measure all
29:45
project what if I want to measure all the projects in my solution so how I can
29:48
the projects in my solution so how I can
29:48
the projects in my solution so how I can do is go to the analyze calculate Cod
29:51
do is go to the analyze calculate Cod
29:51
do is go to the analyze calculate Cod metrics for Enterprise startup
29:55
toolkit so wait sorry
29:59
toolkit so wait sorry
29:59
toolkit so wait sorry analyze for solution okay when you do it
30:01
analyze for solution okay when you do it
30:02
analyze for solution okay when you do it for the solution for all the project it
30:04
for the solution for all the project it
30:04
for the solution for all the project it will give you your code quality metrics
30:07
will give you your code quality metrics
30:07
will give you your code quality metrics okay since I've written some good code
30:10
okay since I've written some good code
30:10
okay since I've written some good code that's why I see all green if there
30:12
that's why I see all green if there
30:12
that's why I see all green if there would be some issues in the code base
30:15
would be some issues in the code base
30:15
would be some issues in the code base it's it's a pretty much of a real-time
30:16
it's it's a pretty much of a real-time
30:16
it's it's a pretty much of a real-time project actually to be very honest that
30:18
project actually to be very honest that
30:18
project actually to be very honest that I'm building so like uh you can see this
30:22
I'm building so like uh you can see this
30:22
I'm building so like uh you can see this okay so it's very simple analyze
30:25
okay so it's very simple analyze
30:25
okay so it's very simple analyze calculate code Matrix and you are sorted
30:28
calculate code Matrix and you are sorted
30:28
calculate code Matrix and you are sorted and you should keep track of this daily
30:29
and you should keep track of this daily
30:29
and you should keep track of this daily to see that you're always green here
30:32
to see that you're always green here
30:32
to see that you're always green here okay now let me come to the last part of
30:35
okay now let me come to the last part of
30:35
okay now let me come to the last part of the
30:37
the
30:37
the presentation that is the business impact
30:40
presentation that is the business impact
30:40
presentation that is the business impact okay that we can have so there are
30:42
okay that we can have so there are
30:42
okay that we can have so there are instances in industry in India as well
30:44
instances in industry in India as well
30:44
instances in industry in India as well as abroad like in Us in uh Europe like U
30:48
as abroad like in Us in uh Europe like U
30:48
as abroad like in Us in uh Europe like U where we have written bad quality code
30:51
where we have written bad quality code
30:51
where we have written bad quality code and like uh there are a lot of uh uh
30:56
and like uh there are a lot of uh uh
30:56
and like uh there are a lot of uh uh like legal tassels and all that has
30:59
like legal tassels and all that has
30:59
like legal tassels and all that has happened you you read this like uh this
31:01
happened you you read this like uh this
31:01
happened you you read this like uh this is from the CIO dive okay it's a CIO
31:04
is from the CIO dive okay it's a CIO
31:04
is from the CIO dive okay it's a CIO dive magazine so it's a exerpt from
31:07
dive magazine so it's a exerpt from
31:07
dive magazine so it's a exerpt from there so and this is the link I like a
31:10
there so and this is the link I like a
31:10
there so and this is the link I like a link for uh the CIO drive from where I
31:14
link for uh the CIO drive from where I
31:14
link for uh the CIO drive from where I have taken it so you can read here poor
31:16
have taken it so you can read here poor
31:16
have taken it so you can read here poor software quality cost organizations
31:17
software quality cost organizations
31:17
software quality cost organizations across all us sectors okay this is like
31:20
across all us sectors okay this is like
31:21
across all us sectors okay this is like it includes like uh uh both like uh the
31:25
it includes like uh uh both like uh the
31:25
it includes like uh uh both like uh the customers who have taken poor quality
31:28
customers who have taken poor quality
31:28
customers who have taken poor quality code they have lost 2.08 trillion in
31:31
code they have lost 2.08 trillion in
31:31
code they have lost 2.08 trillion in 2020 and also includes the integrators
31:35
2020 and also includes the integrators
31:35
2020 and also includes the integrators or like the develop the uh
31:37
or like the develop the uh
31:37
or like the develop the uh application uh Builders or the
31:40
application uh Builders or the
31:40
application uh Builders or the developers who have delivered so like uh
31:43
developers who have delivered so like uh
31:43
developers who have delivered so like uh this is the number like collectively
31:45
this is the number like collectively
31:45
this is the number like collectively they have
31:46
they have
31:46
they have lost and uh also like the operational
31:48
lost and uh also like the operational
31:49
lost and uh also like the operational software
31:50
software
31:50
software failures okay like uh is the leading
31:54
failures okay like uh is the leading
31:54
failures okay like uh is the leading driver of cost okay if there are how
31:56
driver of cost okay if there are how
31:56
driver of cost okay if there are how will you get soft after failure when you
31:58
will you get soft after failure when you
31:59
will you get soft after failure when you have not written the right code okay
32:01
have not written the right code okay
32:01
have not written the right code okay your code has bugs your code have
32:03
your code has bugs your code have
32:03
your code has bugs your code have defects when your code will have defect
32:05
defects when your code will have defect
32:05
defects when your code will have defect it will introduce uh software
32:08
it will introduce uh software
32:08
it will introduce uh software failures okay cost estimates for
32:10
failures okay cost estimates for
32:10
failures okay cost estimates for operational software failures may fall
32:12
operational software failures may fall
32:12
operational software failures may fall short in context of a Serge in cyber
32:14
short in context of a Serge in cyber
32:14
short in context of a Serge in cyber security failures as well so it's
32:16
security failures as well so it's
32:16
security failures as well so it's dangerous so you include cyber security
32:18
dangerous so you include cyber security
32:18
dangerous so you include cyber security risk I I I did not name intentionally
32:22
risk I I I did not name intentionally
32:22
risk I I I did not name intentionally any of the companies but if you'll
32:23
any of the companies but if you'll
32:23
any of the companies but if you'll Google around you can find lot of
32:24
Google around you can find lot of
32:25
Google around you can find lot of companies like uh who have actually
32:27
companies like uh who have actually
32:27
companies like uh who have actually suffered because of bad quality from
32:28
suffered because of bad quality from
32:28
suffered because of bad quality from both the sides of the table so may be
32:31
both the sides of the table so may be
32:31
both the sides of the table so may be from uh like on uh the pretext of a
32:34
from uh like on uh the pretext of a
32:34
from uh like on uh the pretext of a customer or consumer of the code or the
32:36
customer or consumer of the code or the
32:36
customer or consumer of the code or the developer of the code okay
32:43
[Music]
#Programming
#Windows & .NET


