📺 Develpreneur YouTube Episode

Video + transcript

Deciphering Code: Chaos Strategies for Writing Maintainable Code

2024-04-23 •Youtube

Detailed Notes

This episode delves into the intricate world of code chaos, coding standards, and best practices, and exploring the importance of writing maintainable code. Hosts Rob and Mike share their insights and experiences, shedding light on the challenges and solutions in the realm of software development.

What is Code Chaos?

Rob and Mike set the stage by discussing the frustration of code chaos. This is where similar code functionality is scattered and duplicated code across projects. They emphasize the significance of architecting solutions rather than hastily pushing code changes.

Identifying Testing Challenges

From a QA perspective, the hosts highlight the testing complexities associated with duplicate code. They discuss the pitfalls of repetitive testing efforts and the risk of inconsistent functionality across duplicated segments.

Exploring Refactoring Solutions

Rob and Mike elaborate on various approaches to address code duplication, emphasizing the importance of refactoring. They discuss leveraging modern IDE tools for code standardization and the role of automated code analysis tools like SonarQube.

Implementing Structural Changes

The conversation extends to structural adjustments, such as consolidating duplicated methods into utility functions or superclass inheritance. They stress the need for systematic organization and reuse of code components to streamline development.

Utilizing External Libraries

Recognizing the limitations of legacy code, Rob and Mike advocate for integrating external libraries and dependencies. They emphasize the benefits of leveraging established community-supported solutions to replace outdated or redundant code.

Avoid Code Chaos Encouraging Best Practices

The hosts conclude by encouraging developers to adopt best practices, such as adhering to standardized coding styles and utilizing established libraries. They emphasize the importance of continuous improvement and collaboration within the development community.

Avoid code chaos by writing maintainable code, which emerges as a paramount objective in navigating the complexities of software development. Developers can mitigate code duplication and foster sustainable development practices by embracing strategic refactoring, structural adjustments, and leveraging external resources.

We invite you to share your experiences and insights as we wrap up this discussion. Whether you’ve triumphed over project challenges or faced unexpected hurdles, your stories enrich our collective learning journey. Honesty, clarity, and proactive communication are the cornerstone of successful software development. Until next time, happy coding!

We’d love to hear from you! Email us at [email protected] or visit our website to share your thoughts and stories. Stay tuned for more enriching discussions in the episodes to come.

Additional Resources

* The Importance Of Writing Readable Code - https://develpreneur.com/the-importance-of-writing-readable-code/ * Code Reviews – Build Habits And Best Practices - https://develpreneur.com/code-reviews-build-habits-and-best-practices/ * Software Development Challenges and How To Navigate Them - https://develpreneur.com/software-development-challenges-and-how-to-navigate-them/ * SonarQube - https://www.sonarsource.com/products/sonarqube/

Transcript Text
[Music]
hey everybody we have already started
ranting and so we're just going to hit
hit record and continue uh we're talking
about right now and this is bonus stuff
for you guys that are out there in the
YouTube World we'll pick into more of
the the meat of it shortly on the the
podcast side but we're talking about
code when do you the difference between
like just get it done slam it in there
get it done versus we'll say in quotes
double quotes air quotes doing it right
uh which is there's two layers two
different ways at least to do it right
because there is
the this is how it's you know best
practi is done object-oriented kind of
stuff if you're an object-oriented
language and making sure that you have
readable code and comments and you don't
have functions that have four billion
lines of code in them and things like
that but then there's also the right
that's probably more important a lot of
times which is development standards and
if you're with a team in particular and
you have development standards that's
right whatever it is whether it's wrong
or not in a general sense that is what
you should be doing you should be
working towards that standard and that's
where we sort of got into our our rants
a little bit about the the balance back
and forth and so this episode before I
even introduce Mike because he's just
choing it the bit over there uh we're
going to dive in and we're g to go right
into the podcast side and we're gonna
we're going to talk about this so today
this episode we're gonna we're g get a
little bit on a little ranty a little
soap boxy and we're going to talk about
sort of the the give and take of when do
you when do you do it quick and when do
you do it you know take your time and
really architect Your solution and maybe
is there a Middle Road so let's go ahead
and get started well hello and welcome
back we are continuing our season where
we're just talking about a lot of
different stuff we've we've switched up
our formats a little bit we've gotten
off of some of our other seasonal type
topics and this season we're really
getting into some of the things that we
hit on on a daily weekly basis this
episode we're going to talk about
something that is near and dear to our
part our hearts because we've been
venting just before we hit record and
it's about writing code writing it good
maintainable and part of the whole
discussion is when do you architect a
solution and when you just like slam
that sucker home and on the other side
that's got like smoke coming out of his
ears right now because this is where we
started this all thing is Mike so why
don't you go ahead and introduce
yourself
hey thanks Rob my name is Michael malash
I'm co-founder of velur and founder of
Envision QA and like Rob said we're
talking about coding standards and
coding practices today because you
know I've been working on a project
recently that is uh kind of a hot mess
of code we have duplicate code all over
the place and we're trying to figure out
best standards and things of that
nature and I guess I'm remiss if I don't
U myself if you have a if we haven't met
hi I'm Rob I am a co-founder of develop
or and also uh founder of RB Consulting
you can go check that stuff out at some
point want to dive into this discussion
and that
is the key I think is the replication of
code that Michael just hit on it's like
you what you don't want to do is you
don't want to maintain something where
to change a a feature or to upgrade
something you have to go change it in 15
different places the whole goal I mean
one is you don't want to have billions
of lines of code because it's just hard
to figure out where is where is the the
piece of code that you need to fix what
is the thing that's broken but also if
you want to maintain stuff it is very
painful and error prone to have you know
five different places you have to write
code to do this new feature whatever it
is and then you got to make sure that
every piece you got it every piece
you've got all the same you know the
same functionality
particularly if you're like I've seen
many times where you may have the code
theoretically the same in five different
places but it's not because there's like
a little thing that changed here or
something that changed there and so you
can't just like copy and paste and put
it in each of those and boom we're off
and running you have to make sure that
you're utilizing all the right variables
you got all the right things that all
the context is the same and you have to
test every single one of those pieces so
now you're you're having to test
something probably further
Downstream so we'll start with that is
what are your especially from a QA and a
testing point of view what are your
thoughts in in that world about just the
you know the example I did the codes in
five different places and we got to go
make some
changes so if the codee's already there
and it's in five different places from a
testing perspective unit testing alone
should tell you that hey we've got a
problem we're we've got we're doing the
same functionality in multiple places
uh you could essentially copy and paste
the test but then now you've duplicated
work in the code now you're duplicating
work in the test and the other problem
you might have is whatever uh classes or
methods are calling this code is it
calling the right section you know if
you have a method here that's doing one
thing and you copy that and do it
somewhere else but you change one but
not the
other are you really going to get the
changes you need so having duplicate
code well from a testing standard yeah
you can test it but the problem is from
a coder's perspective how do you know
which one to use uh it it becomes
difficult
and really you got to kind of watch that
I mean yeah you can copy and paste but
unless the functionality of that method
itself is very specific for example if
you're
building uh like online reports so if
you have a worksheet on one page uh on
one report and it's the same worksheet
on another report and but because they
are two different reports potentially
you would copy the code from one report
to the other report because one report
might change in the future so that's one
situation where you might have two
different places of code uh because the
sheet itself might be different at some
point in two different places so you
don't want to change it on one report
and suddenly change it on the other but
with that being said if you have a
universal report or sheet that should be
on each one that would never change
because you're always displaying all the
data then that should be in a central
place then and you should reuse that for
all your reporting
purposes and that I guess will reach
back a little bit into the object
oriented world is that's really when you
want to look at the IDE like the concept
of subclassing something if you've got
that case where you've got two reports
that start out let's say the same or you
know the only difference is maybe a
little bit of the data or maybe a couple
little V variables that you can send in
then maybe it makes sense that those
both live as the we'll call it the
report class but then you see one that
now has a lot of changes to it then
maybe what you do is you now just say
hey I'm going to have a subass I'm have
a child of that report class and I'm
going to do my do all my customizations
there so at the core I can have those
things flow through and then I've got my
extensions basically or my specialties
on that other report that get picked up
now because I don't want to go too long
in this episode because we can I do want
to flip little bit to the all right
we've laid out a problem let's talk
about the solutions for this and one of
the first things
is as you sort of implied is you say Hey
what if what if we come into this
situation so we're sitting there and
we've got to change code and it's in
five different places and we now have to
we see that we see that it's
replicated what do we do now there is
the the the tried and true standard of
kick it down the road turn it into
technology Tech de
create a ticket for it and just move on
however it may be useful for you to in
that time go ahead and simplify that
thing from the five places down to the
one for example this is one that I've
run into a couple of times where
somebody there were different developers
and you may see this at times there's
different developers that come into this
solution and they've come in at
different times and there hasn't been
they haven't really spent a lot of time
learning the code before they got in and
started writing functionality and you
end up having two functions that are
meant to do the exact same thing and
maybe the name is off by a case
difference or there's an underscore or
it's just a slightly different signature
you know there's like one extra variable
that's sent in or something like that
those things and I have been in those
where it's like yeah you can call either
one doesn't matter you're going to get
the same result back technically you're
going to get the same result back either
one you see something like that we have
so many good refactoring tools and just
if nothing else Global search and
replace take one of those things knock
it out put all the code in the other one
and just you if you're gonna take a
little longer to get the code done
that's fine take a little longer to get
the code done and feel free to like just
tell your boss your who the customer
whoever it is this is going to save you
in the long run what are some great what
are some of the approaches you've had so
it's interesting you talk about the
tools so one of the funny things is
because you mentioned this before we hit
record was you know some people when
they're doing code reviews or you're
working on a project they look at what
code changes have been done and if you
do too much
refactoring uh or add to many spaces it
looks like you've made a lot of changes
when you really haven't in one of those
cases you almost every modern day IDE
allows you to do a full refactor or
reformat of all your code so it can be
standard I and there's sites out there
where you can go get uh code style
standards you know Google SC site
there's a whole bunch of places for all
these idees where you can get one decide
what you want like Google you know
Jasper whatever you pick a style you
apply it to your ID basically format
your code compile it all and then go
from there basically you create a
Baseline and you move forward so that's
one approach the other approach is not
only the refactor but so many tools
nowadays not only will do the refactor
but they will also help identify if you
have duplicate code with in your
application for instance you can use
sonar Q um or sonar lint uh basically
the free version of the cloud paid
version and that will help you identify
a lot of places where you have duplicate
code uh where you have code smells and
other potential uh problems within your
system lastly to address that the the
final part of that is the other thing
is and we'll probably get into this a
little bit more but if you find code
that's in multiple places like for
example the one you just said where you
have a method here and a method
there and talking about the object
oriented world there's times when you
want to make it like move it up make it
like a parent move it into an object but
there's other times where you want to
create utility files for
example uh one of the projects I've
worked on recently actually had multiple
methods in different classes on opening
up or creating temporary files on the
system and some actually handled the
file closure correctly some did not some
had bad exception handly and I think I
end up ripping it out of seven places
and creating one files utils with that
method that handled it for everything uh
so that's kind of the last thing I'll
touch on I'll pass it back to you rob
that's actually a great point I like
that last piece because there are I've
been in a few of those where which you
end up having is yeah you spend a little
time rolling all those things up into
the the udle function or method but then
what you end up doing is you can look at
all of those and a lot of times you'll
find that they work they do have
differences so you can sort of take them
and combine them into the best of all of
them combined so you have something now
that that properly handles all the
different types of exceptions does it
does all the resource management it does
all of those things and even if it
doesn't at least now you've got it one
place so now you have consistent
functionality for that feature and
things like that are so common where
it's you know it's like I've seen so
often where it's date formatting types
of things if it's not already built into
and actually even when it is built into
the language there's all these different
ways that people will deal with with
casting and moving dates around file
manipulation is almost always going to
be something uh sending emails sending
sms's notifications those kinds of
things that are just part of an
application it is amazing how often
there's like a or even within little U
you know model files that you'll have
something that there's all these little
format or like little methods that
somebody has that's not really part of
the class they're just like hey I just
need to you know reformat this address
in this way and I'm just going to do it
here as opposed to pulling out to a
utility which begs the question or
pushes the forward to say hey if you're
writing some little utility thing on
your method I mean on your class then
think about pulling it off to a utility
and just put it out there so you have a
nice little container of here's the
things that we may use regardless of
what uh you know what package you happen
to be in yeah it may seem like it's a
little bit Overkill but there's also
stuff like you know you don't have to
you make it depending on the CL the
language you can make it all static so
you don't have to actually instantiate
anything it's basically just like having
free flowing functions floating around
there's a lot of ways you can get around
it if you're worried about that kind of
overhead and you're smirking so I'm
wondering what you're what you wanted to
add on that so one additional thing I'd
like to add to that is a lot of times
especially with Legacy code you have
methods that are out there to do
specific little tasks like format a
string or convert an integer or do some
little utility thing that you couldn't
do within the like the code libraries at
the time A lot of times there are so
many common code libraries out there now
especially like in the Java world you
have Apache Commons um you know
JavaScript has nodejs they have a lot of
different packages you can add on there
and sometimes it's better to just go add
a dependency go add on one of these
utility classes and rip all this code
out get rid of the stuff that is not
tried and true or may be so obsolete
that you're getting bugs just because
you're using that and use something that
the industry already supports that the
community supports that has been flushed
out that does work and then you just
plug it in and your code works I mean
you you remove a lot of that uh
unnecessary uh fluff that's in your code
that doesn't need to be there anymore
and that does that makes it it does make
it a lot easier for for others to come
behind you and read it and see it as
well because they're like oh I've SE
like a patchy Commons is a great example
particularly with like the things that
have evolved over the last several years
I guess now like Json stuff and XML
stuff even file manipulation there's a
lot of those things that it's just yeah
early on it maybe wasn't as good it was
a little clunky it was a little bit of a
pain but now these these libraries have
progressed to a point where a lot of
times there's stuff and it's yeah you'll
find something that was all done by hand
was all manual it's like hey we have to
solve this problem that's awesome you
did an okay job but now let's take it to
this Library where now we can just
include it in we don't have to worry
about you know keeping our keeping up
ourselves with it we can just have that
library and pick up that re that version
or that um you know that pride and true
piece of
code that being said I think we'll wrap
this one up we'll keep it so we don't go
too long because we have done that a few
times and as always if you have any
questions shoot us a email at info
developer.com check us out at
developer.com you can see all kinds of
posts lots and lots of content on wide
ranges of languages and software
development techniques and
entrepreneurial stuff as well and check
us out on YouTube out at youtube.com
develop andur I believe that's itd
develop andur our develop andur Channel
and you can see this plus so many other
things that we put together in the last
several years now uh as always though
you if there's any questions if you need
us to go do a little searching feel free
to ask us and we can probably point you
to some examples um or maybe even some
people that have done some of the same
things that you're struggling to get
through or you know have answers that
are even better than ours for your
questions that being said go out there
and have yourself a great day a great
week and we will talk to you next
time
and there's a little video bonus for
everybody as grabbing a drink of water
between
sessions so what you say I think that
was like a good short ranty kind of one
yeah uh might be a little under 20
minutes on that one um it'll be close
but yeah no that was good I like that
that was a good cut off place um I liked
how we kind of bounced from the the
initial problem
into kind of the different ways to look
at without getting too technical without
going down to too many different
solutions like we didn't even touch on
um you know clean code breaking it down
into pieces we didn't really get too far
into over optimizing over engineering uh
which are topics All In themselves so
yeah I think those are perfect yeah I'm
okay with this going if we go a little
short we go a little short they can come
back to the you know they can come check
out the YouTube channel if they want
extra stuff if they don't get enough of
us from the audio version
[Music]
Transcript Segments
1.35

[Music]

27.199

hey everybody we have already started

28.88

ranting and so we're just going to hit

30.64

hit record and continue uh we're talking

32.84

about right now and this is bonus stuff

34.44

for you guys that are out there in the

35.64

YouTube World we'll pick into more of

38.28

the the meat of it shortly on the the

40.64

podcast side but we're talking about

44.559

code when do you the difference between

47.239

like just get it done slam it in there

49.36

get it done versus we'll say in quotes

51.64

double quotes air quotes doing it right

54.559

uh which is there's two layers two

56.8

different ways at least to do it right

59.239

because there is

60.44

the this is how it's you know best

63

practi is done object-oriented kind of

64.799

stuff if you're an object-oriented

66

language and making sure that you have

68.4

readable code and comments and you don't

71.08

have functions that have four billion

72.4

lines of code in them and things like

73.88

that but then there's also the right

75.96

that's probably more important a lot of

77.439

times which is development standards and

80.84

if you're with a team in particular and

83

you have development standards that's

85.4

right whatever it is whether it's wrong

87.56

or not in a general sense that is what

90

you should be doing you should be

91.88

working towards that standard and that's

94.399

where we sort of got into our our rants

96.88

a little bit about the the balance back

98.6

and forth and so this episode before I

103.32

even introduce Mike because he's just

105.6

choing it the bit over there uh we're

107.2

going to dive in and we're g to go right

108.52

into the podcast side and we're gonna

110.119

we're going to talk about this so today

112.079

this episode we're gonna we're g get a

114.04

little bit on a little ranty a little

115.799

soap boxy and we're going to talk about

117.479

sort of the the give and take of when do

121.079

you when do you do it quick and when do

123.039

you do it you know take your time and

125.6

really architect Your solution and maybe

128.319

is there a Middle Road so let's go ahead

131.879

and get started well hello and welcome

134.68

back we are continuing our season where

136.8

we're just talking about a lot of

138.959

different stuff we've we've switched up

140.68

our formats a little bit we've gotten

142.08

off of some of our other seasonal type

144.76

topics and this season we're really

147.48

getting into some of the things that we

149.36

hit on on a daily weekly basis this

152.84

episode we're going to talk about

154.04

something that is near and dear to our

155.8

part our hearts because we've been

157.599

venting just before we hit record and

159.92

it's about writing code writing it good

163.959

maintainable and part of the whole

166.44

discussion is when do you architect a

168.4

solution and when you just like slam

170.28

that sucker home and on the other side

173.08

that's got like smoke coming out of his

174.44

ears right now because this is where we

176

started this all thing is Mike so why

177.959

don't you go ahead and introduce

178.84

yourself

181.08

hey thanks Rob my name is Michael malash

183.319

I'm co-founder of velur and founder of

185.599

Envision QA and like Rob said we're

189.04

talking about coding standards and

191.2

coding practices today because you

194.959

know I've been working on a project

197.12

recently that is uh kind of a hot mess

200.64

of code we have duplicate code all over

203.36

the place and we're trying to figure out

204.64

best standards and things of that

206.72

nature and I guess I'm remiss if I don't

209.76

U myself if you have a if we haven't met

212.159

hi I'm Rob I am a co-founder of develop

215.159

or and also uh founder of RB Consulting

218.64

you can go check that stuff out at some

220.4

point want to dive into this discussion

223.56

and that

224.56

is the key I think is the replication of

228.2

code that Michael just hit on it's like

231.56

you what you don't want to do is you

233.12

don't want to maintain something where

234.879

to change a a feature or to upgrade

238.4

something you have to go change it in 15

240.439

different places the whole goal I mean

243.159

one is you don't want to have billions

244.68

of lines of code because it's just hard

246.28

to figure out where is where is the the

248.959

piece of code that you need to fix what

250.599

is the thing that's broken but also if

252.439

you want to maintain stuff it is very

255.12

painful and error prone to have you know

258.799

five different places you have to write

260.239

code to do this new feature whatever it

263

is and then you got to make sure that

264.44

every piece you got it every piece

266.12

you've got all the same you know the

268.919

same functionality

270.4

particularly if you're like I've seen

272.479

many times where you may have the code

276.039

theoretically the same in five different

277.919

places but it's not because there's like

279.6

a little thing that changed here or

281.12

something that changed there and so you

283.12

can't just like copy and paste and put

284.68

it in each of those and boom we're off

286.12

and running you have to make sure that

288.8

you're utilizing all the right variables

290.44

you got all the right things that all

291.8

the context is the same and you have to

294.8

test every single one of those pieces so

297.56

now you're you're having to test

299.32

something probably further

301.68

Downstream so we'll start with that is

303.68

what are your especially from a QA and a

305.68

testing point of view what are your

306.84

thoughts in in that world about just the

310.08

you know the example I did the codes in

312.36

five different places and we got to go

314.32

make some

316.919

changes so if the codee's already there

319.36

and it's in five different places from a

321.039

testing perspective unit testing alone

323.12

should tell you that hey we've got a

325.72

problem we're we've got we're doing the

327.96

same functionality in multiple places

330.16

uh you could essentially copy and paste

331.8

the test but then now you've duplicated

333.96

work in the code now you're duplicating

335.72

work in the test and the other problem

338.24

you might have is whatever uh classes or

341.68

methods are calling this code is it

344

calling the right section you know if

345.96

you have a method here that's doing one

348.919

thing and you copy that and do it

350.16

somewhere else but you change one but

352.16

not the

353.24

other are you really going to get the

355.479

changes you need so having duplicate

357.56

code well from a testing standard yeah

360.039

you can test it but the problem is from

362.6

a coder's perspective how do you know

364.199

which one to use uh it it becomes

367.199

difficult

368.8

and really you got to kind of watch that

371.479

I mean yeah you can copy and paste but

374.16

unless the functionality of that method

376.52

itself is very specific for example if

380.28

you're

381.96

building uh like online reports so if

385.72

you have a worksheet on one page uh on

388.68

one report and it's the same worksheet

390.68

on another report and but because they

393.599

are two different reports potentially

395.68

you would copy the code from one report

397.56

to the other report because one report

399.639

might change in the future so that's one

402.44

situation where you might have two

403.96

different places of code uh because the

406.8

sheet itself might be different at some

409.319

point in two different places so you

410.8

don't want to change it on one report

411.96

and suddenly change it on the other but

414.16

with that being said if you have a

415.52

universal report or sheet that should be

418.24

on each one that would never change

421.08

because you're always displaying all the

422.68

data then that should be in a central

424.879

place then and you should reuse that for

426.72

all your reporting

428.479

purposes and that I guess will reach

430.68

back a little bit into the object

432.24

oriented world is that's really when you

434.599

want to look at the IDE like the concept

436.919

of subclassing something if you've got

438.759

that case where you've got two reports

440.36

that start out let's say the same or you

443.24

know the only difference is maybe a

444.36

little bit of the data or maybe a couple

446.639

little V variables that you can send in

448.56

then maybe it makes sense that those

450.039

both live as the we'll call it the

452.319

report class but then you see one that

455.12

now has a lot of changes to it then

456.639

maybe what you do is you now just say

458.52

hey I'm going to have a subass I'm have

460.96

a child of that report class and I'm

462.8

going to do my do all my customizations

465.159

there so at the core I can have those

467.759

things flow through and then I've got my

470.159

extensions basically or my specialties

472.56

on that other report that get picked up

475.599

now because I don't want to go too long

477.479

in this episode because we can I do want

479

to flip little bit to the all right

480.84

we've laid out a problem let's talk

483

about the solutions for this and one of

485.639

the first things

487.159

is as you sort of implied is you say Hey

490

what if what if we come into this

492

situation so we're sitting there and

493.84

we've got to change code and it's in

496.479

five different places and we now have to

498.599

we see that we see that it's

500.44

replicated what do we do now there is

503.919

the the the tried and true standard of

506.68

kick it down the road turn it into

508.28

technology Tech de

510.039

create a ticket for it and just move on

513.279

however it may be useful for you to in

516.919

that time go ahead and simplify that

520

thing from the five places down to the

521.8

one for example this is one that I've

524.36

run into a couple of times where

527.64

somebody there were different developers

529.2

and you may see this at times there's

530.519

different developers that come into this

532.399

solution and they've come in at

534.2

different times and there hasn't been

536.399

they haven't really spent a lot of time

538.24

learning the code before they got in and

540

started writing functionality and you

542.079

end up having two functions that are

545

meant to do the exact same thing and

548.12

maybe the name is off by a case

550.68

difference or there's an underscore or

552.44

it's just a slightly different signature

554.88

you know there's like one extra variable

556.399

that's sent in or something like that

558.959

those things and I have been in those

561.2

where it's like yeah you can call either

562.959

one doesn't matter you're going to get

564.519

the same result back technically you're

565.959

going to get the same result back either

567.279

one you see something like that we have

570.6

so many good refactoring tools and just

572.92

if nothing else Global search and

574.399

replace take one of those things knock

576.76

it out put all the code in the other one

579.36

and just you if you're gonna take a

582.2

little longer to get the code done

583.72

that's fine take a little longer to get

585.2

the code done and feel free to like just

587.519

tell your boss your who the customer

589.279

whoever it is this is going to save you

591.64

in the long run what are some great what

594.16

are some of the approaches you've had so

596.76

it's interesting you talk about the

598.44

tools so one of the funny things is

600.519

because you mentioned this before we hit

602.2

record was you know some people when

605.92

they're doing code reviews or you're

607.36

working on a project they look at what

609.32

code changes have been done and if you

611.36

do too much

612.519

refactoring uh or add to many spaces it

615.56

looks like you've made a lot of changes

616.959

when you really haven't in one of those

619.64

cases you almost every modern day IDE

623.279

allows you to do a full refactor or

626.68

reformat of all your code so it can be

628.959

standard I and there's sites out there

631.32

where you can go get uh code style

633.56

standards you know Google SC site

635.639

there's a whole bunch of places for all

637.16

these idees where you can get one decide

640.92

what you want like Google you know

642.8

Jasper whatever you pick a style you

645.76

apply it to your ID basically format

648.56

your code compile it all and then go

651.12

from there basically you create a

652.24

Baseline and you move forward so that's

655.279

one approach the other approach is not

658.399

only the refactor but so many tools

660.839

nowadays not only will do the refactor

663.36

but they will also help identify if you

665.8

have duplicate code with in your

668.44

application for instance you can use

670.36

sonar Q um or sonar lint uh basically

674.079

the free version of the cloud paid

676.399

version and that will help you identify

679.44

a lot of places where you have duplicate

680.959

code uh where you have code smells and

683.48

other potential uh problems within your

686.519

system lastly to address that the the

689.68

final part of that is the other thing

693.04

is and we'll probably get into this a

695.079

little bit more but if you find code

698.44

that's in multiple places like for

699.92

example the one you just said where you

701.16

have a method here and a method

703.639

there and talking about the object

705.6

oriented world there's times when you

707.079

want to make it like move it up make it

709.2

like a parent move it into an object but

711.24

there's other times where you want to

712.48

create utility files for

714.639

example uh one of the projects I've

716.72

worked on recently actually had multiple

719.72

methods in different classes on opening

722.32

up or creating temporary files on the

725.04

system and some actually handled the

727.36

file closure correctly some did not some

729.68

had bad exception handly and I think I

733.32

end up ripping it out of seven places

735.279

and creating one files utils with that

738.079

method that handled it for everything uh

740.44

so that's kind of the last thing I'll

742.56

touch on I'll pass it back to you rob

744.32

that's actually a great point I like

745.6

that last piece because there are I've

747.959

been in a few of those where which you

749.32

end up having is yeah you spend a little

750.88

time rolling all those things up into

753.24

the the udle function or method but then

756.32

what you end up doing is you can look at

757.72

all of those and a lot of times you'll

759.56

find that they work they do have

761.72

differences so you can sort of take them

763.76

and combine them into the best of all of

765.839

them combined so you have something now

767.56

that that properly handles all the

769.279

different types of exceptions does it

771.16

does all the resource management it does

773.16

all of those things and even if it

775.88

doesn't at least now you've got it one

777.76

place so now you have consistent

780.199

functionality for that feature and

783.88

things like that are so common where

785.56

it's you know it's like I've seen so

787.32

often where it's date formatting types

788.92

of things if it's not already built into

790.88

and actually even when it is built into

792.639

the language there's all these different

794.04

ways that people will deal with with

796.36

casting and moving dates around file

798.399

manipulation is almost always going to

800.12

be something uh sending emails sending

802.199

sms's notifications those kinds of

804.68

things that are just part of an

807.36

application it is amazing how often

809.68

there's like a or even within little U

812.8

you know model files that you'll have

814.32

something that there's all these little

815.76

format or like little methods that

818.44

somebody has that's not really part of

820.16

the class they're just like hey I just

822.24

need to you know reformat this address

825.56

in this way and I'm just going to do it

827.24

here as opposed to pulling out to a

829.88

utility which begs the question or

832.639

pushes the forward to say hey if you're

835.6

writing some little utility thing on

837.959

your method I mean on your class then

841.519

think about pulling it off to a utility

843.36

and just put it out there so you have a

845

nice little container of here's the

848.12

things that we may use regardless of

850.519

what uh you know what package you happen

853.04

to be in yeah it may seem like it's a

855.44

little bit Overkill but there's also

857.399

stuff like you know you don't have to

859

you make it depending on the CL the

860.44

language you can make it all static so

861.92

you don't have to actually instantiate

863.56

anything it's basically just like having

866.16

free flowing functions floating around

868.48

there's a lot of ways you can get around

870.32

it if you're worried about that kind of

872.44

overhead and you're smirking so I'm

874.399

wondering what you're what you wanted to

875.92

add on that so one additional thing I'd

879.079

like to add to that is a lot of times

882.56

especially with Legacy code you have

885.24

methods that are out there to do

887.32

specific little tasks like format a

890.24

string or convert an integer or do some

894

little utility thing that you couldn't

897.519

do within the like the code libraries at

899.92

the time A lot of times there are so

902.36

many common code libraries out there now

904.399

especially like in the Java world you

905.759

have Apache Commons um you know

908.079

JavaScript has nodejs they have a lot of

910.56

different packages you can add on there

912.8

and sometimes it's better to just go add

915.56

a dependency go add on one of these

918.24

utility classes and rip all this code

920.36

out get rid of the stuff that is not

923.68

tried and true or may be so obsolete

926.68

that you're getting bugs just because

928.399

you're using that and use something that

931.04

the industry already supports that the

932.72

community supports that has been flushed

935.199

out that does work and then you just

937.199

plug it in and your code works I mean

939.36

you you remove a lot of that uh

941.639

unnecessary uh fluff that's in your code

944.079

that doesn't need to be there anymore

946

and that does that makes it it does make

947.759

it a lot easier for for others to come

949.639

behind you and read it and see it as

951.199

well because they're like oh I've SE

952.6

like a patchy Commons is a great example

954.519

particularly with like the things that

957

have evolved over the last several years

959.639

I guess now like Json stuff and XML

962.16

stuff even file manipulation there's a

964.079

lot of those things that it's just yeah

966.319

early on it maybe wasn't as good it was

968.279

a little clunky it was a little bit of a

969.519

pain but now these these libraries have

971.759

progressed to a point where a lot of

973.519

times there's stuff and it's yeah you'll

975.36

find something that was all done by hand

977.88

was all manual it's like hey we have to

979.68

solve this problem that's awesome you

981.319

did an okay job but now let's take it to

983.639

this Library where now we can just

984.8

include it in we don't have to worry

986.8

about you know keeping our keeping up

989.36

ourselves with it we can just have that

991.399

library and pick up that re that version

994.199

or that um you know that pride and true

997.639

piece of

998.839

code that being said I think we'll wrap

1001.56

this one up we'll keep it so we don't go

1003.12

too long because we have done that a few

1005.319

times and as always if you have any

1007.6

questions shoot us a email at info

1009.399

developer.com check us out at

1011.079

developer.com you can see all kinds of

1012.519

posts lots and lots of content on wide

1015.319

ranges of languages and software

1017.399

development techniques and

1018.959

entrepreneurial stuff as well and check

1021.36

us out on YouTube out at youtube.com

1024.16

develop andur I believe that's itd

1026.039

develop andur our develop andur Channel

1027.52

and you can see this plus so many other

1030.24

things that we put together in the last

1032.319

several years now uh as always though

1035.079

you if there's any questions if you need

1036.959

us to go do a little searching feel free

1038.88

to ask us and we can probably point you

1040.48

to some examples um or maybe even some

1043.439

people that have done some of the same

1045.039

things that you're struggling to get

1046.52

through or you know have answers that

1048.72

are even better than ours for your

1050.44

questions that being said go out there

1052.84

and have yourself a great day a great

1054.6

week and we will talk to you next

1059.16

time

1061.84

and there's a little video bonus for

1064.24

everybody as grabbing a drink of water

1066.12

between

1067.96

sessions so what you say I think that

1070.88

was like a good short ranty kind of one

1074.24

yeah uh might be a little under 20

1077.36

minutes on that one um it'll be close

1080.44

but yeah no that was good I like that

1082.159

that was a good cut off place um I liked

1085.96

how we kind of bounced from the the

1088.76

initial problem

1090.28

into kind of the different ways to look

1092.559

at without getting too technical without

1094.44

going down to too many different

1096

solutions like we didn't even touch on

1099.159

um you know clean code breaking it down

1102.36

into pieces we didn't really get too far

1104.36

into over optimizing over engineering uh

1107.48

which are topics All In themselves so

1110.039

yeah I think those are perfect yeah I'm

1112.72

okay with this going if we go a little

1113.799

short we go a little short they can come

1115.32

back to the you know they can come check

1116.679

out the YouTube channel if they want

1118.039

extra stuff if they don't get enough of

1120.24

us from the audio version

1123.91

[Music]