Transcripts
1. Welcome to this course!: Hello guys and
welcome to the scores on the IntelliJ idea IDE. My name is Alex and I'm a software engineer
that has been vaping code within these IDE for
the best three years. When I heard of the
possibility of creating a course to explain all of
the features that it has. I was quite eager
to develop one. This class will be structured in nine lessons that contain
practical steps for you to take in order to understand
what these IPE is capable of and how you can
take advantage of this knowledge when coding
unit at your own pace. I will show you how you can
create enter on a project and also how all the major
features of it works. Things like debugging,
code completion, refactoring, and
version control. If you are interested in a
new IDE to write code in, Consider this course for you. There are no other
requirements then an Internet connection for the
project of this class, it will be extremely
practical and it will involve you to follow the steps presented
in the course. So you can start on
your journey of writing code with a huge block of
knowledge under your belt. That is how to work in a code editor using
professional settings. We thought the set, I think you already see you in
the first lesson.
2. Setting up the environment: Guys, welcome again
to this tutorial. In this tutorial,
we are going to get started learning
by of course, getting our environment
ready on our local machine. So first of all, of course, being the framework that
it's using Java code, we need to make
sure that we have the JDK installed on
our local machine. So GDP comes from Java SDK. Sdk comes from software
development kit. For this tutorial. We are going to
use the version of one dot dot 01 for Java 16. First of all, you
need to make sure that you have these JDK
installed on your computer. Now, I have a Windows
machine here. How would you check if
you have this JDK already installed on your computer
or you don't have it, you just need to run your CMD. So your command prompt
with administration, and then write in each
java dash version. As you can see, I don't
have it installed. And the thing that brings
on my screen is Java is not recognized as an internal
or external command, is not installed. This way you can confirm that you don't
have it installed. If it would have been installed, the message would
be something like Java version and then it
will tell you the version, then some other
farming messages. But now that we know that
we don't have it installed, we are going to go
on image store it. If you already
have it installed, you can skip to the next step that is going
to be in a few minutes. But for now, how would you
install it would be to go to the link that I provided
in this screen right here, and that's oracle.com,
Java technologies. Java SE downloads the HTML. This you can see we have here the Java SE downloads
job, I see 16. And we can click under the
Oracle JDK on JDK download. Now it will redirect us to
the Java Development Kit 60. So you see Java SDK and
then scrolling down, you can choose the version for your operating
system, in my case, is a Windows 64 beats, so it's the version right here. I will directly select
the executable files so we can go on and
review the agreement, then click on Download. You can see the executable is actually
downloading right now. In just a few seconds, it will be done so we
can click on the nail. And as you can see it
starting this installation, welcome to the installation. We can click Next. Now, the default bath where
it would install it. And I suggest that you leave
it SEC is C Program Files, Java, dish, and then
the JDK version of it. The reason why I tell you to leave it this way
is because we will be later setting some
variables of the environment. The spec. And if you change it, you are going to need to
remember that Beth it's changed the two and have it may be based in
Notepad document. But for now we can just
go on and click Next. And as you can see, it will basically start
installing be GDK, that it was
completely installed. We can close it. And just like that,
the first step of this tutorial is done. The second step, as I said, we need to set an
environment variable, more specifically the Java
home environment variable. And we need to point it to the bath where we
stop these JDK. So to do that, you need to
go to the Search button, then write the system
environment variables. Click on Enter. Then here on
environment variables. Then we can click on New. Then we have the variable name, which is going to
be Java under home, and then the browse directory. And then the directory
is going to BSA said Local Disk C Program Files, and then of course Java, and then this JDK for
the debt, it got us. So this is going to be okay. And as you can see here, the Java home system
variable is now added and the value of it
is the actual Beth. Now we can furthermore, other than adding the system
variable of Java home with the value of the
path in here at bat, we need to edit this
and also add new. And then we need to graphs for the bin folder debt
with edit here. And then as you can see, the Java JDK and
these folder of being right here after I reached,
started my computer. Because if you do
not restart it, you will not be able to see
that the Java installed when you restart it and
enter java dash version, you can see that it actually
tells you some information about the attributes and specifically the
fact that the JDK installed successfully
on your computer. Once again, I added into the
system variables in Java underscore home set
to the path where the GDK was installed
and I added to the back. So user variables for your user, then you click on
it, click on Edit, and then new browser, and then the bin folder of
JDK installation breath. If you do that after installing the JDK that you
get from this link, you are going to
successfully installed the JDK on your computer and complete the
first two steps. For now. This was about the Enter. I thank you guys very
much for sticking with me up to the end
of this lecture.
3. Installing IntelliJ IDEA: Hello guys and welcome
back to the tutorial. For this tutorial, we need to obviously have an IDE
which we can jump code. And for that we're going to
use the IntelliJ idea IDE, which my opinion is the best
IDE for java out there. But we can just
starts to grow for intelligent and then click on the Download on
JetBrains website. This will direct you to the
download of Intel G idea. Now of course, we are going
to use the community version. Not the ultimate is not write
code for it enterprise. We are just going to use these from the comfort
of our own homes. But if you want to do
that by all means, if you have a company
or something like that, you can go for the ultimate is just dead for this tutorial, we are going to go
with those dot EXE. And as you can see,
download basically started. I'm going to get back to
you guys once it finishes. Okay, so I'm back
that Intel has been downloaded beats and now when we click on these executable file, we are going to be greeted by
an installation processes. You can see the setup weekend
just go on in installing. It eats our default destination
folder in the C drive. The 64-bit longitude
is what you are going to need to select here. Then we are going to associate
the Java files we need. Then we can update
the context menu, edit the Open Folder is project. The launchers
directories to the bed. I don't think that's
necessary is that we'll open things up from the actual application so
we can go on and click on Next and then install it. After it has been installed, you are going to be greeted
with these final window. And you can choose
to run Intel J after these actually
finished installing and we can click on debt. We confirmed that we have
read and click on Continue. You can see the Intel G ID is
going to open up right now. And it will furthermore ask us to open a project
or create a new one. And then of course, some plug-ins and the
customization window regarding Color Themes
and stuff like that. So this was about it
with the installation of GID for the job that we're going to
use in this tutorial. It is a pretty simple and
straight WordPress is, but I thought I should do the tutorial on these
just to make sure that you guys are aware of the
way that you are going to get up and running. Hopefully, you got something
out of this tutorial, and I really look forward to
seeing you in the next one. Thank you very much
for sticking with me up to the end
of this lecture.
4. Creating our first project: Hello guys and welcome back to these intelligent IPE
tutorial will be better understand how we can
write efficient code using these modern IDE
specifically made for Java. They've said in the
previous lecture where we installed IntelliJ j, we have downloaded the 2021
that one, that one version, which is currently the
latest version at the time when I am recording this course
and you open up until g, you will be greeted with this window that you saw in
the last lecture as well. On the left side of it, it has different banners that do a different
kind of stuff. And we are going to
run through each of them and explain what they do. The first one that will be automatically selected
Easter project step. It tells you, basically, Welcome to the
Intel GIT, our IDE. You can either create a new project to
start from scratch. If you wish to do that, you can open an
existing project. And here you have two options. You can either open it
from your teeth if you already have that project on
your local machine stored, or you can open it from a
version control system. I'm not going to get into the version control
system that hard. But if you have a GitHub repository or
Mercurial or a subversion, you can point the URL to
it and it will of course, clone it to your local machine and it will furthermore open it. And of course this, IT has version control
integrated within it. And it's much easier
for you using debt to do eventual commit
branches and so on. After the project step, we have the customized stamp, which lets you specify
Intel J theme, which can be light
Windows ten, right? Dracula, which is this one, high contrast, which looks
like this. As you can see. The window stem light
is inspired Dr domain, which has debt theme, but the dark color
is by default, and we will let that be ICDs. And you can of course also choose to sync with
the OS that you have, meaning that it will
synchronize with the operating system
team that you use. And then the
accessibility options that you get, that font. And you can see that you can
select it to be much bigger, but by default it
is at 12, I think. We will leave it to debt. Then we can adjust colors
for red-green deficiency. And then we can also
use some key maps, which we'll get into
of course later. But you can also
import settings if you have some legacy settings
left on your local machine. You can also click on the
All Settings in order to get into all the
settings of the IDE, right from this starting window, which we are not going to do. We're going to do that,
as I've said later. Next weekend, manage
our plugins that our IDE makes available to
us in the third tab, if you are wondering
what plugins are, there are some pieces of functionality that extends
the core functionality, that detail GID already has. By installing these plugins, you can get some the
additional features. For example, let's
say you want to use Docker in your Java
project that you're going to create with the Intel GID can
go on and write dr. Here it is. You can see it has this plugin and you
can click on Install. Indeed. Furthermore, link it and
install it with you where I BE. And of course, it has also a small description
here on the right part. But up here you have all
the plugins that are available and you also have
the Installed plugins. You will need to pay
attention here to search in the marketplace for a new one
and not in the installed. Of course here we have an
under Settings button, the weekend disabled the
plug-ins that we download it. We can stop plug-ins that we
have locally on our machine. And of course we can manage
the plugin repositories and certificates and some
other HTTP proxy settings. Now in the last step we have
the IntelliJ idea where they refer some tutorials
linked from their website. And also there is
a training course that you can do
right on their ID, which is the interactively,
it's just like. Let's get started with
this ID type of thing. And if you want that, you can click on the start learning and it will
redirect you to a basic default project they have and show you
some stuff there. But we are not going to do that. We're going to just create a new project from that
button right there. We can just use the Java type of project with no additional libraries
or frameworks for these basic projects that we are going to be making in order to emphasize the different features that these IDE makes
available to us. Now clicking on Next, we can create a project from template of the
command line app. And this is, as you can see from the
description right here, just a Java application that includes a class with
the main method, which is of course useful because if you wanted to get
something up and running, we print something on
the screen to check that you are working
with the JDK. You may want to do that. But something that I
forgot to mention. Instead, here we have the GDK selected right
after the project. Sdk. Software development kit is a Java Development
Kit in our case, that I showed you
how to install. And it is already linked here. So you don't need to
worry about that. But if you did not
followed that lecture, you can also download a
specific JDK or you can add it if it is not already linked by default here
as it was in my case, that's very important thing. You need to have the GDK linked so your code will compile. But after also checking
this template, we can choose our
project name cell. Well, we are going to name this one the Intel GIDL project. And it will by default
put it into the C Users, then you are a Windows user. Then the folder Idea projects, and then the name
of you are project. This is just for you to know
where it is by default. Or you can of course, change that from these
three dots right here and putting on desktop
or somewhere else, There's more comfortable
for you to click it. And you can also select
from the base package, which by default is
the conduct company. And I'm not going
to change that. But as you can see, it opened up our newly
created project. Just so we know that
everything is working. We are going to bring something else on the screen right now. We are going to bring
this system dot out, dot print line, hello world. And we are going to run in order for us to
get everything working. It is going to take awhile
the first time that you run it from the cell ID as it sets up
some stuff in the back-end. But as you can see, it ran and everything
worked out just fine. So just like that,
you can create a first project in intelligence. It's just that simple
and you can already see that we printed
something out on the screen. And we are going to get
more in detail with some visual components
that we see in this code editor in
the next lecture. So if that sounds interesting, I will look for the guys there. But I really appreciate that you followed me up to the end
of this tutorial and said, I'm looking forward to see
you guys in the next one.
5. Running a project: Hello guys, welcome back
to these IntelliJ idea. How we can more efficiently code in Java using this editor. In this lecture, we are going to discuss different ways of running the project written in Java that we have nice IDE. When we talking about
training projects in these GID or IDE,
you should think. Correlate these
running the project with the term APP
configurations. The configurations are basically
a way to execute code. In intelligent you have multiple
types of configurations. We are going to run
through each one of them and understand
what they are, how they can be useful in what's different for each of them. The first type of
configuration that there is in each the temporary
configuration I have created here another
main function that also has another main class that
also has a main method in it. Only this method,
print hello world. Do we know how to
differentiate between them to know which of them,
hence being executed. So we have these two
classes and each of them has a main function. How we random main class. And of course by default
the main method of it. The easiest way possible. Well, that's with the help of
a temporary configuration. The temporary configuration
is made available when we right-click on the
class that we want to run. The main function. Do we have this Run button? Or we also have the
shortcut Control Shift F, then both of them work. If we click on it, we
get the Hello World. The main method was executed. And the same goes for
this main function. If you right-click
on it and click on Run main two, as you can see, the Hello World to has been displayed and that means that this main function
has been executed. Now, on the other hand, we also have permanent
configurations which are made available in this drop-down that is positioned in the
upper part of the screen. To switch in-between
different configurations. You can click on Edit Configurations and these are made available
do all the time. This is why they are called
permanent configurations. If you want to edit
them, change them, add or remove some of them. You can click on this edit configuration
button from the drop-down. And as you can see here, are made available the application configurations
that there are. And the main one was already
here and it was created. You can see that the
right part of the screen, we have its properties. First of all, we have
the name for it, which would be
specifically correlated to the class name or the
method that is executed. But since the method is pretty much all the
time called main, it should be correlated
to the name of your class or something
that you wanted to do. But just end this name. We have to build
and run options. First of all, of course,
we have the JDK, the Java Development Kit, specifically selected
here in order for the Intel G IDE to know which JDK to actually use
to compile your code. Then to the right. Most important part
from the configuration, which is the FQDN or the fully qualified name for the class that contains
the main method. And if you want to change it, you can click on this
paper right here. And you can see here
we have both of our classes from
the combat company. We can choose the main class
here and it will know, as you can see, two
random main method of this class right here. Other than that, the
working directory is already selected by
default to the bath. You don't have to
worry about that. The only difference
on me to type it was changing the
name to me too, and change the class of which the main function
should be executed. Two, main, two. Now to add a new configuration, you can click on this
plus button right here and select an
application configuration. And of course write
its name and then choose the class for which
you want it to be configured. I will not do that
right now because I already did with these
main two configuration. But to delete the configuration, you can click on this
minus sign right here, and it will get you read a bit. There are also
some templates for configuration if
you want to run, for example, a Gretel or
groovy type of application. You have, of course, template for each of those, depending on what
you want to do with your project and the type
of project that you have. But this is about the
permanent configurations. And as you can see here, we have available both the main 2M, the main configuration, and when we select one of them, will be related to the buttons
that we have right here. More specifically,
the build project. Then the run may do, which of course will randomly function from the
main two classes, we specify the to
do the Debug Main, which is a completely
other topic. We will dedicate a
whole lecture on debugging to understand
how it is done in what it actually is intelligent and also
run into with coverage. And as you saw, if we
select the Run mean to hear the hello world
message will be displayed. And that's a good sign
because that means the main two configuration
was selected and the main method of the mean to class was actually executed. So this was about, it fits into configurations
part of this tutorial and also the running of the project that you
have in Intel J. As you can see, it's pretty straightforward
and not only that, it's pretty versatile and flexible given the fact that you have two ways in which
you can run your classes, either by temporary running them with the right-click
on the class and running option or the
Control Shift F M shortcut. Or you can create a
specific configuration that will be permanently
stored here. And by selecting it,
you can furthermore, Ronald debug, debt
specific configuration. So I hope you got something
out of this lecture guys. In the next one,
we're going to talk about the basic
elements of these ID. So the visual elements that you see on the screen
to understand what each visual part of B's ID
xy yz and what it does. If that sounds
interesting to you, I look forward to seeing you there and thank you very much for sticking up with me up
to the end of this lecture.
6. Visual elements of the IDE: Hello guys. Welcome back to this intelliJ IDE tutorial
where we better understand how we can write
more efficient code in Java with the help of this IDE. In this lecture, we are
going to get even more familiar with the
IntelliJ IDE by discussing the visual
elements that these IDE presents, the developer. We can do this of course, in order for us to
just become quicker. When do we want to do an
action with our code? We can of course have up
faster approach if we know where each item is situated
at visually in the IDE. That will makes our developing
journey much easier. Of course, the first part
that this delta G IDE has many applications these days have each the menu bar in
the top of the screen. It provides, of course, the basic options
and actions that are related to either projects. So code refactoring, making
new projects, opening them, building them, running them, version system controls
for them, and so on. You can see that we have the
file as you navigate code, analyze, refactored,
rebuilt run tools, and then window and help. And D to D stamps
display many options. For them. We are going to analyze some of them in the future lectures. But for now, we need
to just know that, for example, in this file you can create a new
project from here. And you can of course create some classes already
existing projects, so we don't need to actually
create them project. You can, as I showed you before, create a new project
for a repository. We can open a
project, close them. We can open up the
settings for the IDE. And then of course, in the edit, the basic commands of copy, gut based and so on. Each context menu has
related things that are suggested the main
header that we see, and of course, the after it, we also have the utility GID and names, the
name of the project. We have n. Then we are having the name of the class where we
are right there, right under the menu bar, we have displayed the toolbar, which is actually just
this right half of the screen from this
hammer to the right of it. And this provides shortcuts to, as you see, R1 and of course, debug, build and select the configuration that you want for your specific project. This 0s except
called the toolbar. And to the right, we
have the navigation bar, which you can see these Intel
GID or SRC comp company, the main class and main method, which is of course, specifying the we are at
the current moment and it made for making easier
navigation within a project. And this feature can of
course come handy as your project becomes more and more complex and of course big. Now we have also the two stamp that we see on the left
side of the screen. So we have the project,
and then here we have the structure and
then the favorite. In this two-step, we can access some important
tools like databases. If we had somebody most
important thing we have is the project site menu, which of course shelves us all files within
our project MBE. It's pretty similar to the
Solution Explorer that we had on Visual Studio IDE. If you've ever used that. As I said, the project
dep can also be called DAP project perspective and
shows various elements. It can show, as I said, either the structure, their
favorite, the project. So that entire left part
that you see here where we have right now
display the project and the structure is called
project perspective. Lastly, we have the sixth part, which is actually the
last one in these, the most important part,
the editor window. And as you may already
intuitively think, it's the place
where the developer spent most of the
time writing code and writing the code for the file that you select
from a project perspective. It also highlighting the
syntax for the jump code and using some other
useful features. At the bottom of
the window there is a status bar which shows
some additional attributes. And you can see that we have the run window that pops up when we are trying to run
the script that we have built the project
or debugging, so on. Then we can also have a to-do list problems which can be
erased if we have an error. So if we were to write our
code with mistakes in, into problems with B, display here, Then determiner, we also have a terminal which is pretty similar to
the Windows Cmd, just in case you wanted to
maybe get statements from here directly or built
with the JDK manually. And then Leslie, we
have built window that is triggered when we are
trying to build our project. You can see our project
builds successfully. There are no problems there. That was pretty straightforward
other than debt, some important things
can be found in to the file and then Settings tab. From here we can manage
our plugins, of course, as we already saw them into the opening damp that we get when we opened the
Intel GID editor. I'm not going to go
through it again. I already gave you
the definition, what they do, how they
can be useful there, but they can be
accessible from here once you already
created your project. But here we have key maps,
editors, version control, and of course, some other settings that are made available
in more detail. And we are going to run through
them at a later lecture. But for now, this was about, with this one where we
just took a deeper look and understood where
each important item in the psi B is
actually positioned. And this will of course help us, as I said in the future, to write more efficient
code and help us quickly reach to the site of the
project that we wanted to do. Change and know by heart where everything is located and
each feature is positioned. I thank you guys for
sticking with me up to the end of this lecture. In the next one, we are going to discuss how can
refactorings be made available within the GID IDE?
That sounds interesting. I really look forward to
seeing you guys there.
7. Code refactorings: Hello guys and welcome back to this intelliJ IDE tutorial, where we understand
how we can write better and more efficient
Java code using these IDE. In this lecture, we are going to discuss code refactoring. Now in case you've never
heard of refactoring, refactoring increase
first to a process that implies the improvement of your source code
that you wrote. But this improvement is done without creating
new functionality. This refactoring,
if done correctly, should help keep your
code very organized, well-maintained, solid,
and furthermore, easy to maintain in the future. This I said it's basically
a way to rewrite some of the
functionality that you already have inborn
broader terms. Just so more people
can understand it and it is more
well put together. In code refactoring, There are some different processes that can be associated with
the factoring process. Intelligence has a lot of these processes that are
regarding the refactoring. For example, if you
are trying to refactor something related to a keyword, you can click on that keyword, then press Control
Alt, Shift Enter. As you can see, refactoring
context menu will pop up on the screen with
different alternatives of actions that you can
choose to furthermore, refactor something related to the object that you've selected. So in our case, I chose the building
the app desk, which is testing function. This whole Java Project
was an older project of mine where I used to explain
unit testing framework. But I just chose to refer to
it here is it has more than just one class with some objects and basically more code
that we can refactor. So don't worry if you see something that you
do not understand. That's not what it's about. You should just focus on the refractory process.
In this lecture. You can see the building
get test, as I said, it's testing glass, as
you can see right here. And we have some actions that we can do to it regarding
the refactoring of it. We can first of all rename it or we can type migration to it. Then we can move the members of this
class to somewhere else. We can copy the class or
we can safely believe it, meaning that it will delete
all the references to eat without compromising some
other parts of your code. You can do some stuff regarding extract or
introducing heat. And more specifically than that, you can introduce a constant
you need or a field. You can introduce a parameter
or a functional parameter, or you can even type of
parameter or in minus supremum unless of course you can also migrate
these two entries x, but that's not really
the case here. For example, let's say we want
to introduce a new field. Well, if we are
breaking down that, we are going to see that
we can initialize it in a current method or field
declaration or co-instructor. And if we do that, you
can see that we can initialize it in either
the current method, in the field declaration, in the constructor or into the setup function that
you see right here. Basically presents
all the options that are available to
you at that point. Now another very nice
functionality that it has is regarding the renaming
process of refactoring. So you can do this also
by clicking bond class, right-clicking on
it and you can see that it has the refactor option. Up to here. You can see a lot again of options
regarding refactoring. So for example, let's
say that we want to change the name of the
spelling drilling app best, let's say billing gap desk. And if we say refactor, it automatically changed
all the currencies of the billing gap best in our application with
the building gap tests. This way, not leaving behind some other functionality that would occur errors within it. Because if it would just
change the name of the class, then here it would
be without an S. And we would have
to deal with that as an error with brace here. And this way, when you are cold is getting
larger and larger. And your codebase will have
lot of source code in it. Refactoring of the
name of a class might actually relate to thousands of actual words that
needs to be changed. And this functionality, of
course saves us time in that regard and also prone to error factor that is
also avoided because you might miss name that was the
old one and not change it. And furthermore,
fail in that regard. Then another error
with race and so on, wasting a lot of
developing time. Now, also, if intelligent idea encounter some problems with the
refactor that you give it, it will open up at
least as conflicts and their brief description and you will have to deal
with each of those. Now additionally, we also
have in the file in settings, if we go to editor and
code editing section of settings regarding exclusively
to reflect the means. Here of course, we have some additional settings
that we can choose. We can specify the
options of a refactoring. More specifically than
that to be done either in the editor or in
model dialogues. We also have some checks regarding the current symbol
name for the new rename, refactoring whether that should be praised, selected or not. And also the inline showing off the dialogue for
local variables. Now, a few of the most popular
refactoring actions that are supported and also
done in the Intel GIT, our IPE, are the safe delete, which makes sure that
you do not delete files that are referenced
in your source code. And D for the RD, it will ask you to deal
with them in a conflict. As I said, the safety lead has the keyboard shortcut
Alt and then delete. You can also copy
or move an element which are also called
morph refactorings. And the copy is done with an
F5 to movies started in F6. Then we have the extraction
of a method that can reduce you the code duplication. And that refers to a process
where you have a sequence of code lines in more
than one place and that can be
extracted as a method. And that method can be
called in those areas where those same lines of code in
sequence would be present. This is the way the code
duplication would be. Actually reduce the lot. And that's a good
practice to not have very much
duplicate the code. So this can be done
with the Extract Method or with the Control M shortcut. For example, if
we were to select these two lines here
on the refactor, we could actually click
on the Extract Method. And as you can see, extracting a method
for us and making us enter the name for it. And as you can see, it just cost the methods that are implemented
by itself here. It did all debt
entirely by itself. Now, as I've said MY head, they extract constant,
parameter staff options. We also have the
introduced variable with the Control Alt V shortcut. Then the Rename of an element
which I have already showed you within the
building glass here. And these Rename also
has the shortcut, as I said, Shift F6. We also have the
control F6 shortcut, which refers to the change in the cost signature of
a method or a class. As you saw, a big portion of the processes that take part in code refactoring
Garvey meanings, or just the movement of some code where
it's not belonging, not duplicating it and
extracting int method, very intuitive and easy to understand naming
for variables. Things like that can be
done with refactoring that allows your code
to be much neater. Abate the general
good practices. This was about it for this lecture about the code
refactoring processing. The intelliJ IDE. As you saw, the code editor has lots of features regarding
exactly this process. So it should be more
easy to write codes. Debt is, as I've
said, well written. The next lecture. We're going to take a quick look at the debugging
process in Intel J. If that sounds
interesting to you, I look forward to
seeing you there. And once again, thank
you very much for sticking with me up to
the end of this lecture.
8. Debugging: Hello guys, and welcome back to this GID tutorial where
we understand how we can write better and more
optimized and efficient code in the programming language
Java using these ID. Of course, in this lecture
we are going to discuss the debugging feature that these code editor provides
for the programmers. And also discuss the concept
of debugging key general. I'm going to start by deleting the main two function that we created in one of
our last lectures. In order for me to show you that configuration feature
that the ID has. In order for you to
delete a function class, you can right-click on it
and then click on delete. You need to have checked the safety retweet usage
search option checked. We also need to search
for text currencies. As you can see, the main
two class has disappeared. If we check the configuration, its configuration is
still what's left here, but you can see that it has an x red mark to the
right top corner of it. And if we click on the Edit configuration and
click on misconfiguration, you can see that it
has a warning that specifies that no module
was found for the class. You can simply delete the
configuration if you set up specific configuration for one of the classes
that you want to do. We'll do that by default. Now, getting back to the
debugging part of the tutorial, as I said, you
have the option to debug your code using this IPE. Getting a bit into
the reason why you would want to debug your
code and what people eat. Well, basically it's a
process where you can stop the execution of your
code at a specific line. Where you can see there
is something not good is happening and checkout the
value of your variables. And furthermore, how your code is executing
from that point forward. You can create those points by actually making breakpoints. You can create the
breakpoint by clicking to the right of the line number where you want
your code to stop. For example, if we wanted to do create a breakpoint
on line seven, we can click here. And you can see the
whole line is going to be highlighted
with the red color. And this red point
will also appear, as I've said next line. Now, as I said, if, for example you write your code as normal programmer would
do it at some point. You obviously see that
something is not going on. After you build it
and execute it, you see that the wrong result is actually shown or the
wrong desk is executed. And you ask yourself
what's happening. You look at the
Coke then in order to try to debug it visually. And basically just look through the code and see if
you wrote something wrong. Line of code that can
be seen that is doing the sequence of steps wrong. But you cannot see that. And further more than
other option here would be to create some
logs into the code. For example, it is not
building properly. Or if you want to log
the value of a variable, you can also do that. You can lock variables, but this is not an S Good, a solution as debugging. And that is because you
need to actually build your code again to check
out what that value ease. And with debugging, you just create the breakpoint and
then when you debug it, as we will see, you can do that from this button right here. The execution is going to stop
while the code is running. And you are going to be able
to see all the variables, values at that point in time. If everything is local, that's not a huge
difference between just logging the variables
and actually debugging. But imagine if you are
writing code within your job and you actually have a product that is
deployed on the Cloud. Whole debugging process
is going to be a lot more complex and hard to do then
if you had everything local, yes, we have here some
integral variables. This is a very simple scenario, but you can't get very complex. And the execution can
take a long while. You may also need
to copy the output into another machine in this scenario can
get very complex. And that building with the log can take up a lot of time
instead of just working it. So that would be a
reason why you would want to debug your
code instead of just logging some variables
that you might think are not actually having
the right value that you want them to have. This I said, the most viable solution before
debugging, good. Looking at the code in just trying to understand
what's going on. In that case, there
is not working. But for most of the
cases you may not, just by looking
through the code, understands networking
because the execution steps might take weird waste. Again, can have a lot of functions that get called
within each other. And the whole workflow
and costs deck might get a lot
more complicated. Debugging would be
the best solution. You're going to see in just a second step into functions that get called and then the control will go over there and so on. So this is a very good
feature to have in your IDE. You're going to have
bugs in your code. And of course, you are going to have bugs because nobody
writes perfect code. But now getting
back into the IDE. And as you can see, I created this main
function where we have some integrals that
do some operations. It also have a
function called print example that gets
called and executed. It will just print something on the screen so it wants
you to current anything. But I just created this
simple flow in order to show you how debugging
works on the Delta G IDE. There are two ways you can start debugging one
of your classes. The first one is by right-clicking
on newer plastics you want to debug and then
click on this Debug Main. Or you can, of course, select you are wanting to configuration from
this drop-down and then click on these
bugs sign right here. That will do the same thing. Now, you need to keep
in mind that you will want to set your breakpoints before
starting, debug it. So the execution will stop at the point where
the breakpoint is set. For example, right here, I will set a
breakpoint at line 13, just at the start of
the main function. And we are going to click on the Debug button in order to start debugging
these application. You can see here, when you
click the debug button, Debug menu will
automatically trigger and get selected from
the bottom bar here. From this menu, you're going to have a lot of options that you can choose from when debugging. As you can see here, noticed us that we are
at the line 13 of Maine. And also notice is the
package, the conduct company. If we want to move
through the code, we have these buttons
that you see right here. So first of all,
we have the step over or the F8 shortcut for it, which what it does is advanced
align in the execution. Then we have the Step Into button or the shortcut
for these F7, which if you are on a line
where a function is called, if you press that button, it will get into the
function execution. So it will go a step
deeper into the cost step. And then complement would be the Step Up button or the
shift F8 shortcut for it, which what it will
do, we'll go a step lower into the
call stack cell wall. It will go backwards. Of course, we also have
the cursor button, which is pretty
self-explanatory. It will just run to the line
where the cursor's days. And then we can also
stop debugging. We can resume the program. So these would be the equivalent of the continuum
from Visual Studio. Or if you are not
familiar with that, it will just go on executing and stop the pausing
of the program. And it will hit the
next breakpoint if it exists or if not, it will just carry through with the execution to the
end of the program. Now we can also view
the breakpoints here. And if we click that, you can see that we have
a breakpoint online 13. It there ourselves. Now we can mute the
breakpoints and what this does eat
disables to break point. So they're still there,
but they were not yet hit. These ys. A safe solution
if you wanted to keep them, but actually run the
program one more time. You don't not have
to run through each breakpoint that to
setup and disabling. Because this would take a lot of time and you may also forget where the breakpoints
that you set up where in the first place. Here we have a few more buttons. We can get the thread
dump if that is the case. We can show some settings here that showed the
method return values. Auto variable modes, sort
values alphabetically and unmute breakpoints
on session finish. And this is the pin tab, which means the whole debug tab. Here. As I said, here we
have the frame. So where is the
execution at this point? Here we have the
variables that are set. Here will be shown all the
variables that we've declared. So a, B, C, D, and so on. I chose pretty simple
names for these variables in order for us not to
concentrated on that, but on the debugging process. Pretty much DCC itself. On the first line I
just declare a and B to integrate into also initialize
them with the values 1365. And if we want to go to the
next line, as I've said, we can click on the Step
Over button or click F8. If we do that, as you can see, the execution moved
on to line 15. You can see the line
where you are at with because these
Indian execution, because it is highlighted with this light blue color as
you can see on the screen. Now also the variables step got updated with the
values of a and B, which are variables that we have initialized by now
and also their values at this point in time. If you need to remember that these values are the
values that the variables have on the line of the code where they are at,
at that point. As you can see also here, the frame change because we
are online 15 right now. Here in this line we have a print example function
that is being called def. We want to step into it. As I've said, we
can click on these Step Into button
or just click F7. And if we click on this button, we are going to actually be
moved with the execution into the calling Of predict sample that just prints something
out on the screen. There are no variables here. Method. We can now either
click the Step out, which will resume the intro
to the calling method, which is main in our case. Or we can just step over to
the end of the function. Indeed, we'll do the same thing. This function got executed. At this point in time
of the execution, these languages
printed on the screen. You can see that at this point
right here in the console, so the example was
already printed. Now at this point, we moved with the execution at line 15 escaping
from the frames. And here again, it
is going to show that in the main function we have the variables a
and b with their values. Now, I introduce a
new variable data, I apply new value to it. And that is dependent
on both and B, so it's a times B minus 45. And now if we step over and
go to the next function, you can see that the
new variable that we introduced into the code also gets updated into
the variables window. And its value is 1905, which is the result of
30 times 65 minus 45. Now again, I declare
another variable b, which has the
failure of C plus a. Now, in order to help
us stay intelliJ, IDE will also give us the values of the variables
that are used into the instruction that we have
at the line where we are and also at the previous lines that we already
surpassed to that point. So you can see that the
values here are set for each line and each variables that is
referred into deadline. For example, in line 19, we are referring to C and a and the weekend see the
values that they have. And if we step over, you can see that again, D gets initialized and WTP
into the variables step. And each line value is 1935
SB expected from 1905, which is c plus a, which was 30. This is very useful
because you might not understand why by the
end of your program, the value of D is 1935. You can understand why
that is the case by actually iterating
through each line of the code with this debug. By taking you step-by-step
and easily understand why all the variables have the value that they have and why
the execution happens, as you wrote if you expected
something else to happen. These of course, are
pretty basic examples. But in production
code, it can get, as I said, a lot
more ugly than this. And it is going to be very useful for you to have
this type of stuff. We can see that here
I update the value for c by incremented
eat with that number. If we step over it,
you can see that the value for C GOT updated. And here it is shown
into this orange color. On the last line
we are printing C, which is pretty straightforward. And if we just step
over one more time, you can see that the build completed successfully
into seconds. So it actually built the
whole project for us. The debugging was stopped
and the example in 1915 was shown on the screen. In our case, everything
happened as we support it with. But you may never know
for your own project what can happen and what weird result
you may end up with. Not understanding why that is. And here is where
debugging steps. This was about, does it for
this lecture right here. I hope you guys really
got something out of it. In the next one, we're
going to talk about the code completion
feature that this has. That sounds interesting. I look forward to
see you guys then. Once again, I thank you
very much for sticking with me up to the end
of this lecture.
9. Code completion: Hello guys, symbol. Come back to these
intelligent idea tutorial, where we learn how we can write better and more efficient code in the programming
language of Java. In this lecture right here, we are going to discuss the code completion feature that is made available in this IDE, how it works, how it is useful, how many types of code completion
there are in this IDE. And of course, even though C is a pretty intuitive
evident feature, ID has, it can't be a good
aspect to know eating detail. Now, there are two types of code completion that are
available in the Intel GID. The first one is the
basic code completion, and this one just helps you complete the names that
you already start typing. Different stuff that
you can be writing. For example, purses, methods, or fields, even keywords. When you invoke this
code completion, even though disease by default triggered
in the most cases. Intelligent idea analyzes
the context that you use that code completion in and you want it triggered. And it suggests Mark
choices that are reachable from the current
character precision, and also choices that
would be a good match. For example, if we
start typing here, you can see that the first
thing that brands to us, the first suggestion that it
makes us is to type in done. Then of course there
are a bunch of other things that suggest to us, for example, verify
no more interactions, which is a method in this
unit testing framework. And the return to call
real method and so on. This is the basic code
completion that is available in the
IntelliJ idea IDE, and it will be turned
on by default. So you are going to notice
that if you install GID and you are going
to start writing stuff, you are going to see
that by default, when you start to
write something, That's something you are
going to constantly have suggestions on what
you write, on, what you may want to write off, what would be the
best thing to write, or even what you want to write. But with the simple
push up a tab button, it will autocomplete so
it is going to be faster. And of course there are
some other shortcuts. So as you see, for example, one of them is if you
write SO into press Tab, it will automatically
autocomplete system out. Print lm type, which basically It's
something on a screen. Now other than these
basic code completion that is made available, there is also the
type matching type of code completion that
is available here. This type matching
code completion is more smarter did the basic
point and what it does, it just filters the
suggestion list and down shows the types applicable
to the current context. And the type matching
completion is very useful in some
situations when it is possible to determine the
actual appropriate type for the variable you
want to do instantiate. For example, here, if we delete this initialization
of the object intense and rewrite New, and then click on space. It will by default, as you know, by parsing that object is
of type building that test. And by default it will prompt us to declare the
object of this type. And we just need to click on Tab and everything would
be okay at this point. Another cool stuff
about the intelliJ IDE. Instead you can copy
a lot of stuff. You can actually then look in the copy clipboard with the Control Shift
and F and C there, everything that you've copied. So for example, let's say you
want to copy some words out of Here in certain
occurrence sequence, and you want to paste
them somewhere else. Well, you can select the
keyword that you want to copy, Enter Control C, and then
another keyword Control C. Then another keyword Control C. If you press Control
Shift and you can see that all of the contents that you copied up to
this point are here. And you can paste any of these either or either
just pasting them. Just like that. This is another
very useful feature set that's available in the GID. Now, this was about the ETF for the code completion
feature of the IDE. As you saw, it is very well made and it can turn out
to be very useful in some situations where in a bigger project you would
have a lot of functions. And if you want to
instantiate an object, you may even get lost in
some of the similar naming ending that instead
this code completion would be a lifesaver for you. Trust me. Thank you very much
for staying with me up to the end of this lecture and I look forward to see you
guys in the next one.
10. Version control : Hello guys and welcome back
to this idea IDE tutorial, where we understand
how we can better write Java code using this IDE. In this lecture, we
are going to discuss it with the version
control system that made available into
the interior GDPR IDE. And more specifically than that, we are going to understand
exactly how this feature is integrated into the code editor and how we can use it
in our own project. Now getting started,
the first screen that we see when we open
our IntelliJ IDE. You can see that it directly prompt test
projects where we can search eventual projects that we already have on
our local machine. We can open a project if we do not want to
create a new one. But also we have the option to get it from the
version control system. What these guys is basically cloning repository that you have somewhere on your account. Now, I'm not going to get into deep as to what
cloning is pushing, committing and so on. Those are Version Control
System knowledge. But as you can see, if you click on the Get
from version control, you can select
GitHub and you can login your GitHub or use our token in order for you to just retrieve a repository without actually entering your password. You also have the
GitHub Enterprise. If you are working
for your company that has that kind of
feature activated. You can also get it from space or just the
repository URL. Alongside gate, we also have other version control systems like myocardial or subversion. And I don't have to have
currently a repository. So I'm not going to get my project from a
versioning control system. I am just going to
create a new project. And after creating it, I am going to show you
how you can activate the version control system
once you are in your project. Let's say the two, starting a new project from scratch on
your local machine. And you want to put it on your repository
somewhere in the Cloud. Either for the reason
of committing alongside with other team members that are contributing
to that project. Or just for you to have version
backed up in the Cloud. Variance of the project's
go to the chart working on do you want for these two obviously activator
versioning control system. And you can do that by clicking
on the VCS coming from Version Control System
option that will show all of these drop-down
from the top menu. Here we have some options we can enable the versioning
control integration is, I've said, here are some version control
system applications. We can apply batches. We can get from the versioning control
some other projects. We can browse, repositories, we can import, share, or we can even create a repository directly
from here without even needing to log into your teacup from the web browser
peaking dairy boy story. Then coming back here, you can directly create
a Git repository on your account directly
from the entire GI idea IDE. I'm not going to do that. But starting to work with the
versioning control system, you just need to hit the Enable Version
Control Integration. And you need to do system and version control system that
you need to associate with the project truth
in order for it to write some stuff in
some of the files here, for it to know that this is
the version control system, it is Southfield degreed. We're going to select
Git and then click OK. You can see here it
was enabling get. We created a Git repository that is only locally present on your local machine in
the Idea projects title. Here, as you can see, we had the sub menu that
has a lot of options here. Here you can see
the local changes. We can commit to view changes. We also see the details here and all the branches into the
right part of the screen. And you can see the brain
Situ or on writing code right at this moment in
the right bottom corner. So we are on the
Git branch master. And here you can
create a new branch to this branch checkout
and the debt, kind of good stuff. You can also rename your
branch and so on and so forth. Due to the fact
that I do not have a GitHub account momentarily, I will not get into that. But you see that main options that are
available into this JID. Furthermore, you can
see that next to the configuration
and training program sort of menu right here, up to the right of it. We also have a new menu that has some options that will be very handy for you if you want
to check in your work. You can update your project. You can commit your project. You can also push
the changes and these show history
button, which of course, the history of your file with all the
modifications made by different team members during the period of time that
you are repository was on. And you can also do a rollback on a checking just
in case you probably made a mistake on the code
that you've written or the built maybe did not trigger
or there was an error. There can be a lot of stuff
you may want to roll back. You were committed for him. But this is the
general implementation of versioning distance
control in intelligence. You can also see that here
the button is present, replacing the previous
VCS dropdown. Here of course we have
lots of options as well regarding the versioning
system control. Here goes in even more detail regarding the pool
may be the fetch, the March, rebase,
managing the branches, reset the head,
drawing the git log. You can clone another
repository and even click on the VCS operations to just have these floating
tab with again, all the options available
to you from gate. This was about it
for this lecture. I hope you guys really
got something out of it. And I really want
to thank you for staying with me up to the
end of this tutorial. If you have any questions, do not hesitate to
reach out to me. I will do my best to respond to you in the shortest
amount of time possible. And also do not hesitate to
leave the squares right here. That would do wonders for
me in the classifications of my course on the upwards
positions of these topics. Again, thank you for
sticking with me up to the end of this tutorial, and I really look
forward to seeing you guys in some future ones.