Successfully reported this slideshow.
Your SlideShare is downloading. ×

Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 19 Ad

Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java

Download to read offline

Here is the presentation: Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java which Georgia Ingham and Sophia Matarazzo presented at Javaone2015

Here is the presentation: Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java which Georgia Ingham and Sophia Matarazzo presented at Javaone2015

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Viewers also liked (20)

Advertisement

Similar to Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java (20)

Recently uploaded (20)

Advertisement

Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java

  1. 1. Writing Better Code: How the NetBeans IDE Helps You Write, Test, and Debug Java Sophia Matarazzo Georgia Ingham
  2. 2. About Us • Who are we? • What do we do? • Who are you?
  3. 3. What will our talk cover? • What is NetBeans? • Our favourite features and options • Hands on demonstration • Why switch to NetBeans? • Recommendations • Questions
  4. 4. What is NetBeans? NetBeans Time Line Xelfi created by students from Charles University in Prague Sun Microsystems purchased NetBeans 1996 1999 2015 2000 NetBeans became open source NetBeans is on Version 8.0.2 2010 Oracle acquired Sun Microsystems
  5. 5. Why Switch to NetBeans? The top reason people are switching: • NetBeans works straight out of the box • Powerful GUI Builder • Dedicated Support - Developer Support Packages • Support for Java Standards and Platforms - Java Mobility Support - Java Standard Edition - Java Enterprise Edition
  6. 6. Our Favourite Features and Demo • NetCAT • Start-up and sample projects • Plugin manager • Customise and import shortcuts • Code Completion • Built in testing • Formatting options • Free Profiler • Version Control • Never leave NetBeans
  7. 7. 1. NetCAT • Voluntary Testing Program • Run before every new release • Divided into NetCAT Tribes • Leader's additional duties include: - Primary point of contact - Gathering feedback from tribe members - Co-ordinating tests - Updating wiki status • Completed by users for users
  8. 8. 2. Start up and sample projects • Learn and Discover - Try a sample Project • My NetBeans - Quick access to recent projects • What's new - Updated regularly - Contains the latest NetBeans news and community blogs. NetBeans Start up Page:
  9. 9. 2. Start up and sample projects • Click on the sample project button on the start up page. • Select the type of project you would like to sample. • Amend your project properties • Click Run and it will execute your sample project Quick Steps to creating a sample project:
  10. 10. 3. Customise and import shortcuts • Profile management • Customise keyboard shortcuts • Import shortcuts - Can from another version of NetBeans - Can create your own - Can be from another IDE • Keep settings consistent for a team Fully customise your NetBeans with your own i
  11. 11. 4. Plugin Manager • Allows you add extra functionality to NetBeans • Displays plugin details in dialog box • Plugins can be by NetBeans or third party • Search feature • Can install, activate and disable plugins NetBeans Plugin Manager:
  12. 12. 5. Code completion • “Smart” Code Completion - Context Sensitive • Generate Code - Keywords, variable names • Working with JavaDoc • Managing Imports - Automatic imports when class dynamically imported You can use NetBeans Code Completion tool fo
  13. 13. 6. Built in testing • Testing tools - JUnit - TestNG • Code analysers - PMD - FindBugs NetBeans has a range of tools to help test and
  14. 14. 7. Formatting options • Imports and the order they are written - Only import specific package files • Easy naming conventions - Local variable Prefixes and Suffixes • Braces - Helping keep code consistent • Spaces - NetBeans will sort this out for me NetBeans offers a range of Formatting Options:
  15. 15. 8. Free Profiler • Monitoring Applications - JVM properties, thread activity and memory allocations. • Analyse CPU Performance - Count method duration and number of times method is invoked • Analyse memory performance - Object allocation and garbage collection details Free built-in profiler:
  16. 16. 9. Version Control - CVS - SubVersion - Mercurial - ClearCase • Stores login credentials • Provides buttons for version control actions NetBeans supports different versioning systems:
  17. 17. 10. Never leave NetBeans • Built in browser • Hudson and Jenkins - View job status - Receive alerts • Terminal Emulator Built-in facilities means users never have to lea
  18. 18. Recommendations Beginning NetBeans IDE is your authoritative guide for getting started learning and using the free and open source NetBeans IDE. Written by Geertjan Wielenga, who has worked on the NetBeans Team since 2004, it shows you what the IDE is all about and how to use it with real-world case studies built from the ground up as you learn all about the IDE. http://www.amazon.com/JavaFX-Client-Programming-NetBeans-Platform/dp/0321927710 JavaFX is a state-of-the-art graphics toolkit that is now built into Java and can be easily integrated with the NetBeans Platform. With JavaFX, you can create advanced user interfaces, manipulate media, generate graphical effects and animations, and much more. The NetBeans Platform provides a framework for building robust, modular applications with long life expectancies. Together, JavaFX and the NetBeans Platform provide the basis for creating visually appealing, industrial-strength applications. http://www.apress.com/9781484212585
  19. 19. Questions Thank you for listening. Please feel free to ask us any questions

Editor's Notes

  • Intro:
    Hi I'm Sophia And my name is Georgia.

    Welcome to our presentation today .

    Today we are are going to talk about how the NetBeans IDE helps you to write, test and debug java. we're also going to demonstrate and explain to you how you can use all of these cool and helpful tools to help you write better code.

    We're both really excited to have been given this awesome opportunity and to be here today to share all of our Netbeans hints and tips.

    So before we begin we're going to give you little bit of background history on who we are
  • We're both really excited to have been given this awesome opportunity and to be here today to share all of our Netbeans hints and tips.

    So before we begin we're going to give you little bit of background history on who we are:

    Ok, so who am I? Okay so my name is Georgia. I have studied at Computer Science at De Montfort University and my hobbies include reading and cycling. This opportunity to speak to you all represents a lot of firsts for me. This is my first time at Java one and my first time in America actually. We both came a couple of days early just to site see. This is also my first time giving a presentation in front of so many people so you will have to forgive me if I am a bit nervous.

    I am sophia as i mentioned previously, and I have recently finished my Software Engineering Degree at De Montfort university. I am now working towards a whole new chapter in my life. And this talk is just the beginning of it all.
    What do we do:
    so what do we do? Together we both work at IDR Solutions which is a small, dynamic company based in the UK who specialize in Java, PDF and HTML5 solutions. We have a large customer database which is composed of customers who are based all around the world.

    It is when we are working on the development of our java pdf library, we utilize the vast amount of features which netbeans contains. We love how Netbeans works and how we individually and as a team work with netbeans, this is why we want to share our knowledge with you today.


    who are you?
    So who are you? We both know that everyone here has different backgrounds.

    You may have worked with different languages both on and off the screen, worked with different IDE's and have varying levels of experience.

    We're hoping that no matter where you've come from, that by the end of this presentation, you can all walk away with having learnt something new about how the netbeans IDE can also help you.
  • What is netbeans?
    Before we try and convince you that the sun shines brighter with the NetBeans IDE we should probably fill you guys in with what Netbeans is and how we found it to be the most helpful and useful IDE.
    Why Switch to netbeans?
    Why should you switch to netbeans you ask? well We've put together a list of reasons as to why we think you should switch and why people are already switching
    Our favourite features and options
    We're going to show you our favourite features and options. We use a lot of these on a day to day basis and they save a lot of time and it allows us to write better quality code. This work ethic goes nicely with our company motto 'If you can keep it simple, then do'.
    Hands on demo
    We will also be giving a hands on demonstration to highlight more features.
    While hoping the I.T gods will be on our side.
    If not then we have plenty cat pictures to show you as a back up.


    Recommendations
    We have a list of different recommendations, this includes a few books, websites and other learning material.
    Questions
    if you have any question then please ask them at the end of the presentation.
  • It is an Independent Developer Environment that is written in Java and is used to aid in the development of Java code. It has a modular structure making it easy to add or remove software components or as they are more commonly known as modules.

    Netbeans began in 1996 as xelfi which was a student project under the guidance of the mathematics and physics department at Charles university in Prague.

    In 1999 Sun microsystems brought the NetBEans IDE which they turned into an open source project in June 2000.
    In 2010 Oracle acquired sun microsystems and therefore acquired NetBeans

    Now in 2015 netbeans are on version 8.0.2 with the next version just finished testing by the NetCAT team.

    We will explain a little more about NetCAT little later on

  • Ok so now you're probably asking your self, why switch to netbeans? Here are a few of the top reasons that people are already switching:
    Works out of the box Firstly it works out of the box. So by this we mean it literally does what it says on the tin, you can download netbeans and you can have your first or existing projects up and running within minutes.

    Yep thats right, all of the netbeans tools and features are fully integrated as per the options you choose to download. That means no hunting around for plugins, they work together automatically when you launch the IDE. Powerful GUI Builder NetBeans has it's own Graphical User Interface Swing builder formally named Project Mattisse. Its aim? To simplify the daunting task of having to create your applications user interface and lessen the time you have to spend fiddling around the small details like positioning. Dedicated Support available Not only have you got the community to help answer your problems but you can consider getting Developer Support Packages. You can get programming advice, software support and training credits. The training credits can be used on courses to help you prepare for Java certifications if you ever wish to aim for them. Support for Java Standards and Platforms Netbeans provides a range of end to end solutions for all java development platforms which incorporates latest java standards. They have different support packages and editions including:

    Java Mobility support -
    The first thing that it incorporates is Java Mobility support : This is a complete environment that netbeans creates. It allows you to create, test and run applications for mobile devices. With the use of pre-processor blocks you can readily handle fragmentation issues.

    Java Standard Edition -
    Secondly, it also supports the java standard edition. Which consists of a virtual machine, development tools, deployment technologies, and other class libraries and toolkits. It contains the core components needed to develop Java applications.

    Java Enterprise Edition -
    Finally it supports the Java Enterprise edition Netbeans was the first free open-source ide to support Java EE 6 specification. The current version supports Java EE 7. Java EE is built on top of Java SE

    When you go to the downloads page on netbeans you can see that it is kept simple and clear. You get to download the version of netbeans that YOU want to download. It doesn't force you to downland a full version if thats not what you want.The modular structure allows you to choose which modules you want now and then easily add the others later if you need them.
  • READ items.
  • 1. NetCAT
    Ok so earlier on you heard us mentioning NetCAT, you're probably thinking what is it is, well technically NetCAT isn't really a feature but it is a big part of the NetBeans community. NetCat is a program that runs before every new release of the NetBeans IDE. It is a voluntary program where developers test specific parts of the NetBeans IDE. When you sign up to NetCAT you belong to a tribe.


    What is a NETCat Tribe?
    A NetCAT Tribe is a group of participants who focus on testing one particular functionality area of the NetBeans IDE. Tribe members test functionality according to a test specification and provide a Go or NoGo recommendation for that feature.

    Every tribe has a leader who has additional duties including:
    being a primary point of contact for the NetBeans engineering team,
    gathering feedback from other tribe members
    coordinating tests on different operating systems
    updating tribe status on their Wiki

    The beauty of NetCAT is that not only are you helping to perfect the tool you will be working with but you can also gain experience. For example you might have to test functionality you have never used before.
  • So now were going to go into the fun part, Which is the demo and show you some of our favourite features.

    1)START UP PAGE ok so if we open up the netbeans ide, from here you get greeted with the following start up page.This page is updated on a daily basis.

    You can see that there are three different tabs to choose from:
    Learn and discover
    My Netbeans
    What's new
    The learn and discover tab contains quick links to things such as tutorials, demos and Sample projects. This can come in really handy if you need to learn something quickly. It can also be quite nice to learn something new just because you can.

    The my netbeans tab is your recent projects page, that means that it gives you quick access to see what previous projects you have been working on so you can quickly open them again if you've previously closed them.

    This is my favourite tab, this is because firstly: it is updated on a a regular basis. It contains all of the latest news and blog articles which have been written by people from within the NetBeans Community.

    From previous experience its also really nice to be able to have one of your blog posts published here, its like your five minutes of fame.

    And of course if you don't wish to have this open everytime you open netbeans you don't have to. You can turn that off by clicking the show on start up checkbox.
  • ok so as I mentioned on start up screen and on the the learn and discover tab there was a link to be able to 'try a sample project'. This gives you the opportunity to be able to take a look into other types of projects you may or may not have done before.

    So For example, if we click onto that link it opens a new dialouge box. From here you can see all of the samples that netbeans provides. You can see it ranges form Java projects to NetBeans module projects.

    If we click on to the javaFX folder and choose Fireworks we get to choose the project name and where we want to save it to. It looks like were both happy with all of that so were going to go ahead and select the finish button.

    When we have created the project you can see it under the projects tab in the left hand side of the screen. I like this feature in netbeans becuase it allows you to view your projects in different file structures. For example if i expand the project you can see the project source files and the package name. If we click on to the files tab the layout of the file structure changes. If we expand that you can see other files such as the build.xml file and the manifest file. Personally i like to work with my projects under this tab because i can see where everything is quickly and clearly.

    <<run the file.>>

    You can see from the output that the application has been created and there we go we have a project up and running in minutes.

    43 Customise and import shortcuts Ok so this is my favourite feature in Netbeans, if you want to fully customise netbeans you can, why... because Netbeans gives you the functionality to be able to do so. So if you go to Tools > options> Key map.

    From here you can change the profile which netbeans uses. If we click on to the drop down list you can see that there are some other IDE shortcuts in there, so if your used to a specific IDE you can still use these shortcuts.

    For now were going to leave it on the Netbeans profile and amend the settings that are there.

    If i click in the search text field. Im going to change the short cut for running a project so if i type in the word "run" you can see that currently to run the main project you press f6 key I'm going to change that just because i like to have things the way i want them to be set up so if you double click run and then press ctrl and j this will create my new shortcut.

    Another reason that i like to be able to customise my shortcuts is to keep my work consistent when im working in a team, for example some one is new, you might want to share your shortcuts and profile with them. What seems like a daunghting task of going through and individually adding each short cut you can export your profile. Once the profile has been exported from your netbeans IDE it can be imported into the new team member version of netbeans and your done.

    RUN MAIN PROJECT

    One last thing lets check to see if the shortcut ive just created has worked.... (georgia to press ctrl and j to run the project) wooo :)
  • 3 Customise and import shortcuts Ok so this is my favourite feature in Netbeans, if you want to fully customise netbeans you can, why... because Netbeans gives you the functionality to be able to do so. So if you go to Tools > options> Key map.

    From here you can change the profile which netbeans uses. If we click on to the drop down list you can see that there are some other IDE shortcuts in there, so if your used to a specific IDE you can still use these shortcuts.

    For now were going to leave it on the Netbeans profile and amend the settings that are there.

    If i click in the search text field. Im going to change the short cut for running a project so if i type in the word "run" you can see that currently to run the main project you press f6 key I'm going to change that just because i like to have things the way i want them to be set up so if you double click run and then press ctrl and j this will create my new shortcut.

    Another reason that i like to be able to customise my shortcuts is to keep my work consistent when im working in a team, for example some one is new, you might want to share your shortcuts and profile with them. What seems like a daunghting task of going through and individually adding each short cut you can export your profile. Once the profile has been exported from your netbeans IDE it can be imported into the new team member version of netbeans and your done.

    RUN MAIN PROJECT

    One last thing lets check to see if the shortcut ive just created has worked.... (georgia to press ctrl and j to run the project) wooo :)
  • We have a project set up but lets say we need to add some extra functionality to the IDE.

    If we go to the Tools tab and down to the Plugins option we can see a list of available plugins. Plugins can have different sources. They can be certified by NetBeans or can be a community contributed plugin. Not every plugin will be shown here. If you find a third party plugin that you wish to use then you can download it on this tab.
    Ok so lets have a gander through the list. You can see what each of the plugins do by the description on the right hand side of the dialog box. there is useful information including the version number and a home page that will give some more information about the plugin. There are plugins for a wide range of uses. There is a plugin here that is a clipboard that keeps a history of what you're cutting and pasting. That can be quite handy. You can use the search feature if you are not too sure if there is a plugin for what you want. For example you can search for a Maven plugin or the polite netbeans plugin which just adds a little bit of love when you open and close netbeans. Ok so now that we have chosen a couple of different plugins lets install them. Once all of that has been completed and you have ticked all of the boxes, signed of your soul etc. you can view all of your downloaded and installed plugins on the Installed tab. So as you can see we have added pluggins quickly and easily with out having to exit the IDE.
  • Lets jump back into the code with the code completion tool. You can use this tool for a variety of tasks including:
    smart code completion - after you begin typing code completion can be kicked into gear by pressing ctrl + space. NetBeans will supply a list of possible suggestions for you to choose from. The reason it's called 'smart' is because the most relevant suggestions based on the context of your code are placed at the top, above the black line. You can also quickly generate code for Key words, variable names and suggested parameters. generating code - This is accomplished using alt insert. It will let you generate constructors and specify which fields to initialise within that constructor. working with Java documentation - suggestions are generated with ctrl space for java doc tags managing imports - If you add a class with a code completion tool it is automatically added as an import. If a non-imported class is found then a helpful hint will appear in the margin as a little light bulb which will add the missing import for you. Not only does it add missing imports but it gets rid of any that are unused, either one at a time or all at once. hints - These appear in the margin and inform you of any coding errors. They can detect missing fields, imports and so on. Hints can also suggest possible fixes and implement them with just a click. If needed you can disable certain hints or all hints in the options menu. using code templates - lets you create your own predefined code to quickly insert

    And last but not least: navigation - ctrl click on class for quick navigation. This will open up the class in a new tab so you don't have to search for it.
  • NetBeans comes equipped with different testing tools like JUnit and TestNG. The supplied framework lets you create tests using wizards and templates. There are also different code analysers like FindBugs and PMD that can be integrated with NetBeans. If I just open this class that I created earlier then I will show you how to use findbugs. You can open it by going up to the source tab and selecting 'inspect'. From there you can choose which tool you want to use and can customise what you want to search for. For example ... Click inspect
    So we told the tool to search for ... The tool uses code patterns which your code base is ran against to find syntax errors, old code constructs and other problems. The results are shown down here. You can sort the results by project or by the particular problem by clicking this button. If you expand the section. You are shown what the problem is, which class it occurs in and at what line number it is. A description of the problem is shown in the dialog box here. If you want anymore details about a problem then you can go to associated website.
  • 7) Formatting options
    Netbeans offers a range of formatting like:
    - Import and the order they are written in
    With netbeans you get full control on things like your imports. You can modify the settings so that netbeans will only import the specific package needed and not the whole package. A good example of this is if you wanted to install a Hashmap by modifying the setting you are able to just import the Hashmap package and not the whole java io package. As you can see from the tool it gives you a nice example of the formatting options which you want to ammend.

    - Easy naming Conventions
    Some developers like their variables to have prefixes and suffixes for clarification. NetBeans has a whole menu section for you guys! And a really nice touch is that it will add them to the actual variables and remove them when creating Getters and Setters.

    - Braces
    It is important to keep your code consistent between you and your team. Netbeans lets you choose when braces appear and if they appear on a new line. It also lets you choose whether to have a merged else if or separate it out.

    - Space
    Adding consistent spacing for your code makes it much easier to read but it can be fiddly to add and consistently enforce. So I get NetBeans to worry about it. All the formatting and any auto-completion will use your settings so it is very easy to have consistent spacing across all your code with minimal effort.
  • ) Free profiler This leads on to another feature which is built into Netbeans. Not many IDE's offer a free profiler already installed and ready to use. The Netbeans Profiler has 3 main tasks:

    Monitoring Applications - Used to gather high level information about the application including JVM properties, thread activity and memory allocations.
    Analyse CPU Performance - This provides information about the time it takes to execute a method and the number of times the method is invoked
    Analyse memory performance - which will tell you about object allocation and garbage collection. These tasks can be fine tuned to suit your needs. You can also create multiple custom profiling tasks

    By using the profiler it allows you to increase your productivity by helping solve memory or performance base issues. It also helps create reliable and scalable applications. An advantage of the profiler is that once you know how to profile one application you know how to do it for them all. The process is the same whether it is for a small application or an enterprise application.

    //perform profiling task? check how long this section takes then decide. https://netbeans.org/kb/docs/java/profiler-intro.html#create
    You can learn more about the profiler by going to the netBeans website. We have put the website at the end of this presentation. The website tells you indepth information about how to use the profiler and gives you a tutorial on how to use it correctly with one of the sample projects NetBeans comes preloaded with.
  • 9) Version control NetBeans currently supports 4 different versioning systems:
    CVS, Subversion, Mercurial and Clearcase. The first three are already included with the IDE and ClearCase being an optional addition from the update center.

    Because netbeans is the peoples IDE it provides menu items that can quickly and easily perform your version control actions like
    pushing, committing and pulling.

    It also allows you to be able to store your credentials so that every time you push and pull you do not have to log in. Don't worry the login details are easy to change by right clicking your project, going to the mercurial menu and clicking .... You can also set the default name so that you know who has made the commit. There are different methods of calling the version control commands.

    **Georgia to do the demo**
    You can either select the commands from the menu when you have selected a project like this [] or you can personalise your NetBeans menu bar by [].

    You can add the buttons you want and which ever order you want. On our machines we each use the tools slightly differently. I prefer pulling my projects while I know some of the other member prefer fetching from the repositories so this customisable option is a bonus for us.
  • 10) Never leave NetBeans The real and true beauty of netbeans is that you dont ever have to leave the IDE. Everything we have demonstrated today shows that it is possible to perform all the various programming and performance tasks whilst inside of netbeans. What we have shown you isn't everything of course. We barely even covered the resources at your disposal like the Team Servers, ...

    For anybody who would like to continue learning about any of the features we have covered and more, we have put together a page of recommendations.

×