MOAR IntelliJ IDEA Tips and Tricks by Trisha Gee

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello hello good afternoon welcome standing-room-only again okay hi and yeah like I'm Trisha I work for IntelliJ for jetbrains I'm not at all nervous but if I I get really nervous giving this talk because I have like a million tips to tell you all of which are here I can't remember which ones come in which order and I want to show all of them so I get super excited but it doesn't mean I end up also being like super nervous about what am i doing what do you want what are you interested in and so hi I'm Trisha I work for JetBrains I am the IntelliJ IDEA advocate and Java advocates and this is one of those rare talks where I actually talked about the IDE specifically the tips on how to use IntelliJ IDEA and who is using IntelliJ IDEA well that's good okay that's a good stuff who's using eclipse okay watch and learn right so this is basically all the slides I have now we're going to go straight into into the tips like I say I've got a whole buncha tips I don't expect you to memorize all of these I expect you to know some of these I hope and I really would like you to come up with just like one or two tips that you didn't know before so if you'd like to snooze in the middle of this that's fine no problem just as long as you come away with like one tip and I'd like you to tweet that what that tip is that'll be amazing and then my work here is done and totally justified flying all the way here from Spain right let's get started this is IntelliJ IDEA it is an IDE for writing java code this is the kind of default way that it looks when you open when you open it so you usually get like obviously the editor window and the project window and you might have Li you've got tabs at the top and you've got a navigation window and NIT and as you can see I'm using the mouse right all of this is wrong don't use the mouse don't have the navigation window don't have tabs put the tab placement by the way amusing and oh yes so the shortcuts will appear at the bottom can you can everyone see the the bottom no can I put it I can put it to the top if that's easier yeah one person said yes okay who's for it who's for top who's for bottom it sounds a bit kinky I'm a bit worried I think I think top wins this talk is really not going the way I expected it to go presentation so this is a plug-in called presentation assistant which is usually the top tip that people take away from this is an able presentation assistant I'm gonna have it appearing at the top and then when I press the shortcut and you should see at the top so the main shortcut that I use when I don't know what I'm doing because I don't remember the shortcut is shift control and a this is the magic find action shortcut which will allow you to find a lot of things specifically actions but if even that is like too difficult to remember the only shortcut you need to remember is double tap shift search everywhere find anything so you're going to find classes files symbols action settings plugins whatever you want so what was I doing I was trying to turn the tabs off I wanted to tell I want to say tab placement none so we don't have any of those tabs and I'm going to use ctrl shift and f12 to maximize my my editor okay I've also turned off edit of bread at breadcrumbs which is sometimes there and there are two other things that you can use if you want to if you want to focus on just the code there is distraction theme distraction free mode and presentation mode and even though I spend most of my career giving presentations in IntelliJ IDEA I don't use presentation mode but the reason is that if we show this presentation mode and it all goes away and it's not the same as using IntelliJ IDEA as an IDE and what I want to do is I want to show you how to use IntelliJ IDEA the way that you'd work on it at home at home yeah at work and and and apparently find action doesn't work in I'll have a go so also that also makes everything else a bit bigger so I guess it's easier to see and there's distraction-free mode which is supposed to allow you to focus on just the code but I generally prefer to have my IDE in like normal mode anyway so let's exit distraction-free mode and go back to normal mode so yes so you should basically be using keyboard shortcuts for everything and you should be maximizing the use of the editor so that you can actually work on the Java because that's generally what we're doing and and then we're going to use all our navigation shortcuts so like I said if you don't remember any of these use double tap shift and you can search anywhere and but what I want to do is I usually use ctrl n so this is the this is Windows I'm using a Windows machine I use a Mac at home and you should be able to see both sets of shortcuts up here at the top so you can use ctrl n to get to a specific file you can use ctrl shift in sorry to get to a class you can use ctrl shift and to get to a file of any type and you can use ctrl alt shift and to get to a symbol so I don't know to string for example and then when you're doing those things it also supports camelcase so I can say something like where is it it's functional parameter so I can use EFP to navigate to extract functional parameter or I can use partial names as well so let's see is there something yeah strings or multi-line strings so if I kind of know something is in a file name I can navigate to it fairly easily so we shouldn't be using the project window and opening this folder and opening that folder navigating down there's no need for any of that we should just jump straight to it it's also particularly useful you know if you're working in code bases where there's always like this one method or this one file that needs changing you're just going to jump straight there right so go to symbol go to file so I do have a list I will have to check my notes and quick definition oh I don't even know what that is all right so let's go to customer repository one of the things that I found quite useful is you can navigate to implementations let's type declaration yes so Control Alt + B and if your if you add a interface or abstract class you can use that to drill down to specific implementation or you can use control B to navigate to the type that your cursor is on so that allows you to navigate backwards and forwards or drill in and step out or you can use ctrl alt arrows to go backwards and forwards between the files you just changed mostly I do use those things but mostly what I use is ctrl e to look at recent files and that allows me to show not only recent files which I can search for in pretty much any IntelliJ IDEA window you can type something and it will search like I'd been working with IntelliJ IDEA for about five years before I realized this you can just start typing and it will find the thing in the window for you and so I can search for something in here and I can also that's a new one and this is not working very well is it because it's all on top of each other recent files so recent files also has all of the windows at the side so I can use keyboard shortcuts to bring up the windows if I want so it's nine for local changes alt f12 for the terminal for example but often it either doesn't have a keyboard shortcut or I don't remember what it is so I go to control e and I type for example Gradle to open the Gradle window and then I can open it there so like control a is kind of your your go-to and I believe ctrl shift e can take you to recent locations so that's not just the files that you've opened but the snippets of code that you've recently been working in so you can see here I've got more two locations inside Java eight inspections and then I can just go directly to a specific place that I was in a file this is new this is new in 2018 point one twenty nineteen point one I think okay so that's navigation I talked a bit about search everywhere such everywhere like I said you can find specific files but also you can do things like there are commands as well so I can look for editor settings for example or I can look for what else have we got inspections which I can turn on or off as well so search everywhere is like super powerful lets you basically get to anything that you want to um this is not going to be a super cohesive talk this is just basically going to be firing stuff at you by the way search everywhere let's see where are we know navigating backwards and forwards I showed that bookmarks and favorites I never use that so I'm not going to show that and coding assistance alright so one of my favorite things is ctrl W which lets you expand and contract no selection of your code in a in a context-sensitive fashion oops not like that it's a different shortcut on map on the Mac because ctrl W will close the window for you which is not super useful and you can move code up and down which will move as a whole block into something more useful so this I'm actually pressing down it won't let me move it down because it won't let me move it outside of that method but I can also see oh no I've forgotten what the keyboard shortcuts are for the Windows machine quickly move on and no one will notice multi carrot right let's talk about multi cursor and HTML so O's using IntelliJ IDEA or webstorm to edit HTML quite a few of you one of the things I quite like about it because in the olden days when I was doing HTML editing when I was young and stupid more stupid uh-huh is that you'd do it in a text editor and it was kind of a bit of a pain in the neck if you do it an intelligent idea you can do things like when you edit one tag it will automatically edit the closing tag for you that's nice that's like obviously what an IDE is for and and you can do things like you can have things like column select mode which I can't remember the keyboard shortcut first so I find fine action and I turn that on and then I can do column select mode here and which is generally I find that useful not so much in Java because honestly your Java code shouldn't be written in a way where column select mode is a useful thing to do but for things like HTML files or XML files sometimes this is kind of useful like if for example I wanted to edit both of these at the same time I could do that at the same time and that will automatically edit the closing tag as well and there's also multi cursor so I could say control I could say I want to put my now it's not control Multi cursor alt shift and mouse to put my cursor in like three different places or however many places I want to and then just like write something there like the same stuff there so the multi cursor thing is is particularly useful again I have not used this in Java code because I don't think Java code you should be using things like multi-car so you should be using things like me factoring let's see should we look at some refraction course should we look at something else see if I do this here will it break all right so one of my favorite things is to do reformat code obviously this is totally down to personal style because you don't want to reformat every single file all the time because like your colleagues hate you when you check in white space changes but quite often good practice as your coding along you're going to want to reformat according to the the specs that you have so you can use ctrl shift L to know there we go ctrl alt and L you can do ctrl alt shift and L to change the settings of that so I want to change the whole file maybe optimize imports rearrange code and then it will reformat everything so everything is nice and neat which is what we like to see related to that organized for code am i in presentation mode yes that makes a lot of sense right oh yeah okay so one of my favorite features is the fact that IntelliJ IDEA will basically generate all of your code for you so you don't have to write anything so let's start by creating ourselves we have a new class so Walton insert on Windows but the Microsoft Surface laptop does not have an insert key so old and insolate doesn't work unless you map one of the other kids to be insert top tip and so new Java class so obviously I'm going to call it I'm my name let's call it main we'll create our new class which we can't see because of the tips let's hide all the windows we're going to use live templates so who knows about the live template public static public static void main hands up if you use that good excellent you are a good audience have a biscuit sorry that's very patronizing sorry this is like my super favorite live template because you know you don't you're not writing main methods all the time but when you are writing a main method you don't want to type public static void main you just type PS VM and obviously similarly for system out you can press out and then you can do whatever you want to here hello so you get cogeneration through things like and cogeneration through things like live templates you can get cogeneration through things like why don't we have a private string name for example and we say IntelliJ goes oh well you're not really using this fine so I'm gonna alt enter because you all know alternative just fixes everything for you right good if there's one thing you can take away from this dear Eclipse users is use alt enter if in doubt so um what is the error here so private field name is never used so IntelliJ goes okay what can we do about that we can add a constructor parameter so that's fine that will generate my constructor parameter and assign it to the field I didn't have to write any of that that's great and it's still not being used so we're going to create a getter for our name as well great so a great wall of crate all of those things what else do we need we're going to generate a equals and hashcode method we'll just use the default template there's a bunch of different ways to generate equals and hashcode I'll just use the default and I only have one field in here so we'll just select that do all of that mmm so pretty I don't see what's wrong with Java and all the boilerplate that's in it and a two string we generate our two string as well and now obviously this is kind of generating there's a bunch of generated code it's generally generated at the place where you have the cursor so there's not always in the in the best possible location you can then if you want you can rearrange code and then that should rearrange code in a useful way so now we have fields at the top constructors at the top methods here and then the overridden methods right at the bottom and our private methods right at the very bottom you can set those settings however you want but I found this like a super useful way so that your class files particularly if you've got generated methods your class files are structured in some kind of useful fashion you can also do that let's undo that if you are doing the reformat code which I did earlier so alt shift and L oops sorry some do that you can say rearrange code when you reformatting so you can rearrange the whole file optimize your imports rearrange your code and code cleanup is have IntelliJ like fix all of your inspection warnings for you I think that's probably something you should go through and check automatically rather than just check individually rather than do it automatically so run all of that so now you've got a file which is beautifully formatted you've got all of the imports optimized and you've got everything in exactly the right order and you know you've only got 45 lines of code and you only have to write like that you know three bits of three names you have to write the your name here and here to write this here and IntelliJ wrote everything else for you if that's not boilerplate if I don't know what is alright so we've got different types of completion as well so let's see what I've forgotten here we've got a good thing first completion this all this these examples are all available in in github there'll be a link oh they'll be a link at the end I don't have a link at the end it's under the JetBrains account on github code samples and so you can use all of these code samples to try stuff out if you want to so what have we got we have have normal completion so obviously when you type a dot you get all the stuff that you can you can use for completion and if you are doing something like a lot smart completion hmm so let's do something like int I and then we do something like this dot I equals this dot now by default you'll just get any of the options here if you do smart completion you will end up with no that's not that's right smart completion is shift control in space and it will either give you a sub list of everything which returns the correct type in this case an integer or in this case if you do smart completion it just finds the only value which returns the correct type and just assigns it automatically in a related related tip control shift and enter will complete the current statement this is one of my favorite keyboard shortcuts so here it just added a semicolon so I didn't have to type it fine so I pressed three keys instead of one win but an if I'm doing something like if something and then a complete current statement it will give me the curly braces or yeah there's a bunch of other things so a complete current statement would just basically add all of the stuff around around the statement that you're currently in I use it all the time a hippy completion demo kippie completion all the time and I still don't really know who would use it does anyone use hippy completion okay I was really hoping someone would tell me what they use it for right fine so what you can do is you do let's see so if I start this obviously if I type something it gives me the drop-down for normal completion and if I do oh and alt and forward k forward slash it will cycle through all of the relevant things that it could be and so that's fine or I can do I can even do this with if I say t I can do it with text values as well so just cycle through and give me something so it just allows you to automatically pick some different types it's kind of interesting I feel like it's something I should use but I haven't I haven't really used it and that's just interesting postfix completion this so I tweeted about this this week so perhaps a bunch of you have already seen this the postfix completion is one of my one of my favorite things yeah like it's got 352 tips and like 75 of them and my favorite thing ever I suppose fix completion you can do something like so obviously when you press the dot you get all the methods that you can call on a particular on a particular symbol but if you press up you have you have nothing amazing oast cuz I said string what strings if you press up and then you have all of these weird things and these are your postfix completion it's a bit like live templates but it's it's done after the fact of typing something so for example I might want to do so I have a list of strings so I might want to itter over that and postfix completion will allow me to iterate over those it's the same we can do live templates for this as well so I can it a over that that way that's fine or I can use postfix completion the the point about postfix completion is to be always typing forwards so it's very useful for just continuing on that's great one of the other things I really like postfix completion for is is casting so strings and then you can cast and it will automatically do that tedious thing with all the brackets that you need to have for casting okay so I'm going to cast this to an object because you know I hate the person who's going to read the code afterwards and you press ENTER and it will take you to the right place to start doing something on on objects and so yeah postfix completion do every time you like press have a look up to see if there's something interesting you can do all sorts of things like and strings dote so let's do it and then let's do string and not and that will do a check to see if the string it's not or not and then you can do a string dot so no I can't do that I'll do the other way I do with this so you'll notice if you type s out you have a bunch of different options here and if I type s out V it should give me the option of outputting string like that so then it will just say what the variable name is you can do it with parameters you can do it with variables or you can just do it so if you want to okay parameter hints you probably know this now because it's been around for a little while now and people you has anyone turned off parameter hints in their code base one person or people using parameter hints okay that's cool I know a few people who really hate it I I really like parameter hints for the primitive types and strings and nulls particularly I think for nulls because I've worked on code bases where you have something like this let's turn off the parameter hints for a bit disabled hints and you look at a method call like this and you're like ah I don't know what that is okay I don't know what those nulls are and you can press ctrl and P to find out what the what the parameters are that's useful but parameter hints is more useful can i rien a birth at now probably not parameter oops oh no around mid hints okay um and I've just turned it off so parameter name hints are also now available and enums which they didn't used to be all language injections I get so excited about all of these things I'm so sorry J so I've forgotten jek shion's all right so this is not like super unusual particularly I think in in test code but also in production code you might have a bunch of text which has it has contacts in its own right so here we have a bunch of JSON string we have a JSON string and here we have a sequel string and if you use if you use alt enter because obviously this is our magic incantation for everything we can say inject language or reference and I'd like to inject JSON and then it should ignore me utterly hmm okay usually it then does some useful text highlighting some JSON star text highlighting let's do it with sequel and see if that works better I'll enter inject sequel yes and then we get text highlighting and we should also get some code completion so that actually allows us to even if we are even if we're working inside strings which obviously in Java has like no type we are we can get like code completion and things oh look now what code completion and some error checking and things inside our text values so this is particularly useful if we have strings which represent other languages like JSON or JavaScript or sequel or whatever let's see if we can get an error so what happens if I put a space in there so then it will give me an error and it'll say this needs to this needs to be key value types Oh regular expressions we all love regular expressions right so we want to we can use this to inject regular expressions and that will give us again some highlighting and we can also we should be able to we should be able to I don't remember how to do this because I try not to use regular expressions like ever oh it's got code completion that's right so if I make this a regular expression and then it should be able to give me some errors like saying you need a good you need a group name here so for working with things like this this is like super helpful because especially regular expressions right because it's just like I mean obviously you're way more experienced than me but every time I look at one I'm like no I don't know what that means and IntelliJ can help us with that and right oh and apparently you can have emoji in the editor oh I didn't put it in here oh that's a shame oh I'm kind of sad about that I wanted to show the emoji oh no it's in multi-line strings Alec see apparently you can use emoji everywhere in IntelliJ IDEA including in commit messages and like probably I don't know folder names I'm not I really don't know I'm sure your operating system is gonna have something to say about that but but it supports emoji everywhere I mean I think maybe I'm a bit old for that I said but it's fun especially because I like the idea of using emoji to like say nice things instead of being like this is a piece of you're like well done this is really lovely right invert let's look at refactoring because refactoring is my favorite thing so you can use refactorings like again using alt enter on everything we can invert if conditions so here we say if is if not is valid print something this might be a bit easier if I say something a bit more obviously different and if I want to I cannot enter and invert that condition and it will flip everything around so this can be useful for readability obviously obviously it's generally more difficult to read statements that have not in so if you come across a knot you might want to flip that so it's it's a more positive more readable thing and obviously if it's a boolean flag it's it's a bit of a silly example but when you've got something a bit more complicated you might want to get IntelliJ IDEA to invert that for you so that it's it's more readable and still does the same thing it can be quite smart as well so for example in a recent version of Java I think it was 11 they add so optional dot is present has been there obviously since Java 8 but you can actually now flip this if you invert this IntelliJ IDEA will pick the new method is empty which is from Java 11 so in so simply nothing is present it will use an inverse operation if one is available let's look at I won't show all of these because a lot of these in my favorite a lot of this of my favorite I work at the right company because I really like what IntelliJ does so I've got loads and loads of Java 8 inspections every time we add a new inspection I add code into this file to show or like how to use them a lot of them are things which you've probably used who's using Java 8 who's using something before Java 8 ok so that's cool actually and so for the poor people who are not using Java 8 these are kind of useful for you because when you migrate you'll be able to automatically turn things like this into stream operations like this so this is quite a complicated one it had a for and ear for for and if and some concatenation counting basically and it figured out that actually that's the same as this I do highly recommend that you have automated tests by the way just in case refactoring is not a magic bullet be careful but that's apparently the same thing I mean that's like super cool and probably not a stream operation that I would have come up with and so it does this for a bunch of these different things so basically you can just alt enter your way through your code base to like stream FI everything do do performance testing because it's not the same thing but it's kind of interesting oh look at this one I'm just gonna get so carried away what does this do Oh I don't even know what that is Oh also look at this as well I love this the fact that it puts the types on on each stream operation so you know where you are the stream is you've got we have one I don't even know that is a set of entries of strings of lists of strings it becomes the stream of strings comes at all very cool I hope that's not real code that lived somewhere because I really pity the person who had to read that look at the original code like I do not know what that means anyway yes carry on so there's loads of Java 8 stuff which would just automatically turn your code into stream operations which if you're using Java 8 you will have seen this in IntelliJ anyway so I don't really need to show you we just continually keep adding these things to it when I was doing a live demo on how to migrate to Java 8 about 2 3 years ago hi I created the live demo at the beginning of the year for Q Khan London and DevOps DevOps UK and it was all great and then every time I gave that talk our development team were like adding new inspections every time just to just to mess with me so every time I was like oh this doesn't oh it's this totally refractors in a completely new way that's kind of cool it was a living dangerously and and then there's a bunch of stuff around around optional as well for Java 8 let's not get carried away because I already have a whole talk on this from two three years ago and we've got a bunch of stuff so specifically optional inspections these are really useful because I'm every version of Java since Java 8 some 9 10 11 have all added new methods - optional and IntelliJ IDEA is generally keeping up with how to how to simplify a lot of these optional things so that it so it looks a lot simpler than it was well what does that do and then we've got dataflow analysis as well which says like you don't need this this is silly and then it goes oh you don't need that either just press alt enter until everything goes away and what else we got anything interesting on Java 11 I think I showed this this morning anyway so we got predicate not we have some stuff around yeah like the Java 11 stuff is not super exciting Java 12 I showed this is this morning as well so Java 12 we can turn this into a switch expression and but basically all of this is IntelliJ right so your code for you know you write code IntelliJ makes it prettier not necessary better because you did a great job first time around it's just you know sometimes things can be prettier refactoring extract functional parameter abstract functional parameter this is one of the cool things I found when I was learning how to do a Java 8 because it's one thing to use under expressions is another thing to create methods that take lambda expressions because use functional interfaces to provide lambda expressions which is kind of a bit a bit weird so let's say I want to I want to turn this into a lambda expression that gets passed into this method so I use the handy incantation of ctrl shift o P extract functional parameter it will automatically say look you can use any of these functional interfaces to represent this functional parameter so I'm going to use the standard C let's use buy function from Java this is actually updated recently so then I get a method which takes a bi function and and then I get a lambda expression to put in here so that's I think that's kind of cool because the way we represent lambda expressions for functional parameters it's just sometimes you'll do this and go no I didn't want to do that in the first place and can we actually inline this no oh I don't think I wanted to do that refactoring is not a magic bullet people right and so we've got X Oh extract delegate stretch delegate so refactoring you've probably already used like extract variable extract field extract method because those things I like super useful and we can also this is a weird place to do it hmm this is not how I would have chosen to do it and not my code obviously my code would be much better and so I'm going to no I'm going to replace inheritance instead so one of the things that I I don't really like using inheritance to share code because it's just not a good way of doing stuff so I like to to replace inheritance with replace inheritance with delegation so you can get IntelliJ IDEA to replace the superclass with instead of inheriting from the superclass you have a delegate instead and then it will delegate down to that so it automatically reshape your code view so it's not just like a single variable that you can refer to but you can do much bigger refactorings around extracting interfaces or or replacing inheritance with delegation etc moving on I've got loads of examples a dataflow analysis you've seen these probably in your code as well where IntelliJ IDEA says you like these these calls don't make any sense you've got the values that you have are always particular values and one of the things don't know that I want such a flow analysis for a raise so you can actually so here we have an array which is got days in months you kind of know what that means and what we what the dataflow analysis is figuring out what these values are as you get to various complicated bits of your of your if statements let me see if I can remember what the handy incantation is for Oh control ship people so press control shift P twice Oh control shift P oh it doesn't work mmm shift control P no oh I know talk amongst yourself that's fine okay Frank yes so let's do here so we can do things like we can IntelliJ IDEA is figuring out what values certain things can be at certain points in your code and you can have a look at this so you can use ctrl shift + P + twice and it will show you the results of the dataflow analysis at this point in time date get day can return any int at this point in time can return any in Oh No Oh cuz its month yeah okay that would be a lot more sense yeah that's better so at this point in time date get month can be 1 or 3 to 12 and then down here it can be it can only be two so it's doing some analysis about the values that are available there now it will give you it can give you suggestions and warnings based on that or you can use that information to make to make decisions around like how can I simplify this code like if this is always 2 then I don't need to make certain checks for example and the data flow analysis is there's loads of different features there so I just want to point out that it's there and it can be very useful for helping you to simplify your code for example I use it all the time to go when it tells me this can't mean ol or this can be nil then I'm like I believe you if you say it can't mean oh I don't have to do a non check and right 12 minutes left what's really interesting to work with but working with tests we got the debugger and we've got working with databases working with version control oh my goodness like I could do like three hours and version control alone right I will do a little bit on version control because this is one of my favorite pet peeves and oh and so you all know about the local changes tab we mostly using git okay everyone's using it who's not using it CVS really the people who aren't using it you are using version control pipe because I've seen that too and so yes so you see in local changes that's fine and you can use control okay to commit and that will bring up your commit dialog which obviously shows you all the stuff you know all the files you can commit and you get to use your commit messages let's hide the diff and you know I hope that there's a history of all your commit messages so you can reuse past commit messages if you want and you can also do I quite often do find myself occasionally doing amend commit which is a little bit naughty but you know it is possible to do and see if quite often especially because if I'm doing changes to to the demo code I'll sometimes forget to check in one particular file so then I'll use a mend commit to add that to the previous commit and and of course you can do stuff automatically like reformat your code rearrange your code optimizer imports and stuff as you as you check in and fairly recently new in IntelliJ IDEA some version I can't remember we have added partial commits the support for partial commits so you don't have to commit that bit if you don't want to I I was like horrified by this because I'm a firm believer in making sure you commit frequently these small commits everything has to compile all the tests have to pass partial commits just sound like something which allow you to check in something which is not going to compile and but there are cases where you're going to be like no actually those changes aren't supposed to go in so I will just not check in those changes for example so I'm that's like new and super useful my favorite feature about version control is the log view because I kind of I sort see things in a very what you mean I don't have any commits oh I'm a very visual person so I kind of like to see things visually so the log view is quite useful for that so I can see my I can see my branches this is not the best project to demonstrate this stuff because it's mostly me just doing small commits like adding emojis and and obviously you can see the branches here you can filter things by you can select which branches you want to see you can filter by user and I use this view quite a lot to figure out how to how and where to branch how and where to merge so if I have a branch should we try and do a branch let's create a branch here well this is not really going to work it's not great demo for this so I can do new branch I don't have to check oh look at new new branch you like it fixed and I can create that branch and I can check out that branch or I don't have to I can just create it there and it should pop up here in a minute there we go new new branch and and I can do things like let's let's put any branch here I'm using the mouse actually I don't actually know what shortcuts for this don't tell anyone changes let's commit the changes everything oh my goodness don't do code analysis because it slows everything down for demos especially when this code is specifically designed to fail code analysis now I would like to commit my 61 warnings yes and then let's say I want to let's switch to the new branch so I'm going to so I this is very mousy and very like visual but I find this useful kind of figuring out where on earth I am obviously my yellow sticker will tell me where I am I'm on a new new branch so I can do things like if I want to I can cherry-pick this branch and it will allow me to do this let's see cherry pick I'm still doing the code analysis yes I would like to commit my 61 mornings there we go so then I can I can do cherry picking and I can do merging and rebasing and things like that so I like to use the log view a lot just to make sure that I haven't really messed up something generally speaking so I do kind of complicated stuff around version control because I often do workshops where I'm specifically trying things in a particular order I think when you're doing like real development I don't think you should be messing with your branches I don't think you should be like deleting commits of reordering commits I think that's a terrifying frightening thing to do and because I have seen that when you start then trying to find out who introduced this change that broke this thing in five years time it doesn't work right what else should we see should we see a bit of debugging and running got seven minutes left let's look for alphabet test so I took away the navigation bar so obviously you can't run anything anymore well that's not true obviously control shifts every time I end up with replacing path control shift f10 in Windows No all right I'm gonna use the mouse fine except ctrl shift f10 I just pressed that you're not listening to me and right so I quite often use the Run Run in context what are you doing to run a test these things allow you to run either the whole class or a particular method obviously I'm gonna have some errors because I purposefully wrote some errors and things I can rerun tests using ctrl f5 oh please don't fail me now rerun alt shift are alt shift I'll rerun tests are you not listening to me oh my goodness it was all going so well fine let's go back to our test let's rerun our test a bit confused about the fact that I seem to still be in presentation mode exit oh the legs everything hard my goodness right oh my goodness whoever did that was trying to give me a heart attack right fine so I've run it obviously you you've seen this before you got your run window and stuff at that and what I wanted to show is that you can you can run with coverage and and that allows that will put in your gutter like whether certain parts of your test classes are covered by whether certain parts of your production code are covered by tests or not and and you can do I've got another test which is better and you can obviously break point and debug etc ctrl shift D okay and then in your a debug thing which now I've taken us out of presentation mode you can't really see you can obviously you can see the variables there aren't that many you get your inline comment style display of what's going on you can add watch expressions so I can say this dot I don't know there's nothing in here so I have to say let this dot to string yeah that's fine you get code completion that's not available let's remove that add a new watch expression and stop spit so you can put any I'll watch expression in there and it will give you an illegal argument exception and and you can use obviously you can step over and step in and you kind of know that stuff so that's kind of fine what did I really want to show you with debugging oh yeah drop frame oh this is not a great example but um I can if I'm in the middle of debugging let's say and I've made a few steps and I'm like well I don't really want to be here I've made some changes and this is not what I want then I can easily just drop frame to go back to where I was huh please tell me I'm using the demo version of IntelliJ IDEA I'm quite often using this is my excuse I'm quite often using the EAP version so very occasionally you get some strange behavior that wasn't really working but the idea about did work though I did drop the frame so drop frame took me back where I was and allows me to go back in and rerun the stuff again so it allows me to kind of play with staff and set different state you can also do evaluate expression to let me do things like what could I do I can do count constants for example and this will this will give me the result of evaluating a specific expression as well so this is really useful when you stop debugging on the fly right two minutes left so and that allows I would say 20 questions have one second each and I do have a few more tips but I really want to give the opportunity to say like are there any questions or any things at this point in time that people want to see yes yep is there a shortcut I knew you were gonna ask me that someone was and my husband asked me that like last week and I was like I actually don't know the answer to that question and then he came back to me and tell me what the shortcut was and I can't remember what it was it involves a tab somewhere shift tab control shirts control - I don't know there is one and and and I suggest you google it because yeah I use the mouse all the time to get there and and I shouldn't I would like a keyboard shortcut that takes me directly to there so you can assign keyboard shortcuts for specific things that you do as well Oh which reminds me no I'll take some more questions before something else any more questions or things is that question is there ways to check the code complexity I'm gonna say yes but I don't really know specifically what you need if you're come up to me in the booth after this and we can talk about it because we've got some of the other experts in the booth okay and I wanted to show that in so if there's one shortcut that I want you to take out this if you didn't already know it it's the DoubleTap shift to search everywhere which allows you to search all these different types of things you can actually do things like so if for example you're always searching for one particular thing you can add what's it called abbreviations let's go to settings and look for abbreviations keymap abbreviations um and you can look for something like Gradle I can add an abbreviation to the Gradle tool window I added one it's the grd and then when I searched everywhere I can type grd and it will give me a top hit for Gradle so as well as assigning keyboard shortcuts to stuff you can also assign abbreviations so you can easily find it if it's something you do quite a lot and that's all that's not all I've got but that's all the time I've got they're gonna keep me off the stage thank you very much [Applause] [Music]
Info
Channel: Devoxx
Views: 3,566
Rating: 4.8805971 out of 5
Keywords: DevoxxUK, DevoxxUK2019
Id: uu7j1_jhiU4
Channel Id: undefined
Length: 50min 56sec (3056 seconds)
Published: Thu May 16 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.