{"id":25388,"date":"2016-07-22T11:49:34","date_gmt":"2016-07-22T11:49:34","guid":{"rendered":"https:\/\/blog.jetbrains.com\/idea\/?p=14432"},"modified":"2016-08-04T10:14:28","modified_gmt":"2016-08-04T10:14:28","slug":"java-8-top-tips","status":"publish","type":"idea","link":"https:\/\/blog.jetbrains.com\/ja\/idea\/2016\/07\/java-8-top-tips","title":{"rendered":"Java 8 Top Tips"},"content":{"rendered":"<p>I\u2019ve been working a lot with Java 8 code over the last couple of years, for both <a href=\"http:\/\/trishagee.github.io\/presentation\/java8_in_anger\/\" target=\"_blank\" rel=\"noopener\">new applications<\/a>\u00a0and <a href=\"http:\/\/trishagee.github.io\/presentation\/refactoring_to_java_8\/\" target=\"_blank\" rel=\"noopener\">migrating existing\u00a0ones<\/a>, and it feels like the right time to write down some of the \u201cbest practices\u201d I\u2019ve found useful. I personally dislike the term \u201cbest practices\u201d as it implies a \u201cone size fits all\u201d solution, and of course coding doesn\u2019t work that way &#8211; it\u2019s down to us as developers to figure out what will work in our situation. But I have discovered I have particular preferences for Java 8 code that I find makes my life a little easier, and I thought I&#8217;d start a discussion on this topic.<\/p>\n<h3>Optional<\/h3>\n<p><a href=\"http:\/\/www.oracle.com\/technetwork\/articles\/java\/java8-optional-2175753.html\" target=\"_blank\" rel=\"noopener\"><code>Optional<\/code><\/a> is a highly underrated feature, and one that has the potential to remove a lot of those <code>NullPointerExceptions<\/code>\u00a0that can plague us. It\u2019s particularly useful at the boundaries of code (either APIs you\u2019re using or APIs you\u2019re exposing) as it allows you and your calling code to reason about what to expect.<\/p>\n<p>However, applying it without some thought and design can lead to one small change impacting a large number of classes, and can lead to poorer readability.\u00a0Here are some tips on how to use Optional effectively.<\/p>\n<p><em>Optional should only be used for return types<\/em><br \/>\n&#8230;not parameters and not fields. <a href=\"http:\/\/blog.joda.org\/2015\/08\/java-se-8-optional-pragmatic-approach.html\" target=\"_blank\" rel=\"noopener\">Read this blog post<\/a> to see a pragmatic approach to using Optional. Fortunately, IntelliJ IDEA lets you turn on an <a href=\"https:\/\/www.jetbrains.com\/help\/idea\/2016.2\/code-inspection.html\" target=\"_blank\" rel=\"noopener\">inspection<\/a> to check you\u2019re following these recommendations<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-OptionalParamWarning.png\" rel=\"attachment wp-att-14434\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14434\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-OptionalParamWarning.png\" alt=\"Optional Parameter Warning\" width=\"558\" height=\"106\" \/><\/a><\/p>\n<p>Optional values should be dealt with in the place they\u2019re encountered. \u00a0IntelliJ IDEA\u2019s suggestions\u00a0will prevent Optional leaking all over your code, so remember you\u00a0should deal with Optional where you found it and move swiftly on.<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-OptionalUseImmediately.png\" rel=\"attachment wp-att-14435\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14435\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-OptionalUseImmediately.png\" alt=\"Deal with Optional immediately\" width=\"730\" height=\"81\" \/><\/a><\/p>\n<p><em>You should\u00a0not simply call get()<\/em><br \/>\nThe strength of Optional is to express that this value might be empty, and allow you to cater for that case. Therefore, it&#8217;s important\u00a0to check if\u00a0there is a value before doing anything with it. \u00a0Simply calling <code>get()<\/code> without checking <code>isPresent()<\/code> first\u00a0is likely to lead to a null pointer at some point.\u00a0Fortunately, once again IntelliJ IDEA has an inspection to warn you\u00a0to stick to this.<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-OptionalGetWithoutIsPresent.png\" rel=\"attachment wp-att-14436\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14436\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-OptionalGetWithoutIsPresent.png\" alt=\"Get without isPresent\" width=\"732\" height=\"80\" \/><\/a><\/p>\n<p><em>There is probably a more elegant way<\/em><br \/>\nThe <code>isPresent()<\/code> combined with <code>get()<\/code> certainly does the trick&#8230;<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-OptionalSimple.png\" rel=\"attachment wp-att-14439\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14439\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-OptionalSimple.png\" alt=\"Simplest use of Optional\" width=\"725\" height=\"131\" \/><\/a><\/p>\n<p>&#8230;but there are more elegant solutions. You can use <code>orElse<\/code> to give an alternative value in the case that it&#8217;s null<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-OptionalOrElse.png\" rel=\"attachment wp-att-14437\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14437\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-OptionalOrElse.png\" alt=\"Using Optional orElse\" width=\"724\" height=\"48\" \/><\/a><\/p>\n<p>&#8230;or\u00a0you can use <code>orElseGet<\/code> to tell it which method to call in the case that the value is null. This might seem the same as the above example, but the supplier method will be called only if needed, so if it&#8217;s an expensive method, using the lambda will give you better performance.<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-OptionalOrElseGet.png\" rel=\"attachment wp-att-14438\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14438\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-OptionalOrElseGet.png\" alt=\"Using Optional orElseGet\" width=\"728\" height=\"51\" \/><\/a><\/p>\n<h3>Using Lambda Expressions<\/h3>\n<p><a href=\"http:\/\/docs.oracle.com\/javase\/tutorial\/java\/javaOO\/lambdaexpressions.html\" target=\"_blank\" rel=\"noopener\">Lambda expressions<\/a> were one of the main selling points of Java 8. \u00a0Even if you&#8217;re not using Java 8 yet, you&#8217;ve probably got basic understanding of them by now. But they are a new way of programming within Java, and\u00a0it&#8217;s not yet obvious what is &#8220;best practice&#8221;. Here\u00a0are some guidelines I like to follow.<\/p>\n<p><em>Keep it Short<\/em><br \/>\nFunctional programmers may be happy with longer lambda expressions, but those of us who&#8217;ve been using only\u00a0Java for many years might find it easier to keep lambda expressions to a small number of lines. You might even prefer to limit them to just a single line, and you can easily refactor longer expressions into a method.<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaExtractMethod.png\" rel=\"attachment wp-att-14441\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14441\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaExtractMethod.png\" alt=\"Extract longer lambda expressions into methods\" width=\"548\" height=\"164\" \/><\/a><\/p>\n<p>These may even collapse down into method references. Method references may seem a bit alien at first, but it\u2019s worth persevering with them as they can actually aid readability in some cases, which I&#8217;ll talk about later.<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaCollapseToMethodRef.png\" rel=\"attachment wp-att-14442\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14442\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaCollapseToMethodRef.png\" alt=\"Collapse Lambda to Method Reference\" width=\"390\" height=\"71\" \/><\/a><\/p>\n<p><em>Be Explicit<\/em><br \/>\nType information is missing for lambda expressions, so you may find it useful to include the type information for the parameter.<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaExplicitParamTypes.png\" rel=\"attachment wp-att-14445\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14445\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaExplicitParamTypes.png\" alt=\"Explicit parameter types for lambda expressions\" width=\"963\" height=\"36\" \/><\/a>As you can see, this can get quite unwieldy. \u00a0So I prefer to give my parameters a useful name. Of course, whether you do this or not, IntelliJ IDEA lets you see type information of parameters.<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaParamTypes.png\" rel=\"attachment wp-att-14444\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14444\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaParamTypes.png\" alt=\"See the parameter types of the lambda\" width=\"663\" height=\"70\" \/><\/a><\/p>\n<p>and even the Functional Interface the lambda represents<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaFunctionalInterface.png\" rel=\"attachment wp-att-14443\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14443\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaFunctionalInterface.png\" alt=\"See the lambda's functional interface\" width=\"806\" height=\"56\" \/><\/a><\/p>\n<h3>Designing for Lambda Expressions<\/h3>\n<p>I think of lambda expressions as being a little like <a href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/extra\/generics\/index.html\" target=\"_blank\" rel=\"noopener\">Generics <\/a>&#8211; with Generics, we use them regularly\u00a0(for example, adding type information to <code>List&lt;&gt;<\/code>\u00a0), but it\u2019s much more rare that we\u2019ll design a method or a class that has a Generic type (like a\u00a0<code>Person&lt;T&gt;<\/code>). Similarly, it feels like we\u2019ll pass lambdas around when using\u00a0things like the Streams API, but it\u2019ll be much more rare for us to create a method that requires a lambda parameter.<\/p>\n<p>However, if you do find yourself in this situation, here are some top tips.<\/p>\n<p><em>IntelliJ IDEA can help you introduce a functional parameter<\/em><br \/>\nThis lets you <a href=\"https:\/\/www.jetbrains.com\/help\/idea\/2016.1\/extract-functional-parameter.html\" target=\"_blank\" rel=\"noopener\">create a parameter<\/a>\u00a0where someone will pass in a lambda rather than an Object. The nice thing about this feature is that it suggests an existing <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/lang\/FunctionalInterface.html\" target=\"_blank\" rel=\"noopener\">functional interface<\/a> that matches the specification.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14446\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaExtractFunctionalParameter.png\" alt=\"Extract functional parameter\" width=\"634\" height=\"128\" \/><\/p>\n<p>Which leads to&#8230;<\/p>\n<p><em>Use existing functional\u00a0interfaces<\/em><br \/>\nAs developers become more familiar with Java 8 code, we\u2019ll know what to expect when using interfaces like <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/util\/function\/Supplier.html\" target=\"_blank\" rel=\"noopener\"><code>Supplier<\/code><\/a> and <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/util\/function\/Consumer.html\" target=\"_blank\" rel=\"noopener\"><code>Consumer<\/code><\/a>, and creating a home-grown <code>ErrorMessageCreator<\/code> (for example) could be confusing, and wasteful. Take a look at the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/util\/function\/package-summary.html\" target=\"_blank\" rel=\"noopener\">function package<\/a> to see what&#8217;s already available.<\/p>\n<p><em>Add @FunctionalInterface to your functional interface<\/em><br \/>\nIf you really do need to create your own functional interface, then tag it as such with this annotation. \u00a0It might not seem to do much, but IntelliJ IDEA will show you\u00a0if your interface doesn\u2019t match the exceptions for a functional interface. It flags when you haven\u2019t specified a method to override:<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaFunctionalInterfaceNoMethod.png\" rel=\"attachment wp-att-14447\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14447\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaFunctionalInterfaceNoMethod.png\" alt=\"Functional interface without a method\" width=\"346\" height=\"94\" \/><\/a><\/p>\n<p>it flags when you\u2019ve specified too many:<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaFunctionalInterfaceTooManyMethods.png\" rel=\"attachment wp-att-14449\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14449\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaFunctionalInterfaceTooManyMethods.png\" alt=\"Functional interface with too many methods\" width=\"732\" height=\"147\" \/><\/a><\/p>\n<p>and it\u00a0warns you if you\u2019ve applied it to a class rather than an interface:<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaFunctionalInterfaceNotInterface.png\" rel=\"attachment wp-att-14448\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14448\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-LambdaFunctionalInterfaceNotInterface.png\" alt=\"Functional interface that's actually a class\" width=\"393\" height=\"88\" \/><\/a><\/p>\n<p>Lambda expressions can be used for any interface with a Single Abstract Method, but they can&#8217;t be used for abstract classes that meet the same criteria. \u00a0Seems illogical, but it is what it is.<\/p>\n<h3>Streams<\/h3>\n<p>The <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/util\/stream\/Stream.html\" target=\"_blank\" rel=\"noopener\">Stream API<\/a> is another one of the big selling points of Java 8, and I think we still don&#8217;t really know how much this is going to change (or not) the way we code. Here&#8217;s a mixed bag of things I&#8217;ve found useful.<\/p>\n<p><em>Line up the dots<\/em><br \/>\nI personally prefer to line up my stream operations. You don\u2019t have to, of course, but I\u2019ve found this\u00a0helps me:<\/p>\n<ul>\n<li>see which operations I have, in order, at a glance<\/li>\n<li>debug more easily (although IntelliJ IDEA\u00a0does offer the ability to <a href=\"https:\/\/youtu.be\/rimzOolGguo?t=3s\" target=\"_blank\" rel=\"noopener\">set breakpoints on any of multiple lambda expressions on a line<\/a>, splitting them onto separate lines does make it simpler)<\/li>\n<li>comment out an operation while I\u2019m testing things<\/li>\n<li>easily insert a <code>peek()<\/code> for debugging \/ testing<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14451\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamWrappingExample.png\" alt=\"Line up your dots\" width=\"390\" height=\"149\" \/><\/p>\n<p>Also it\u2019s neater, in my opinion. But we don\u2019t gain a lot in terms of reducing lines of code if we follow this pattern.<\/p>\n<p>You may need to adjust your formatting settings to get the dots lined up.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14450\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamWrapping.png\" alt=\"Formatting Stream method chaining\" width=\"615\" height=\"200\" \/><\/p>\n<p><em>Use Method References<\/em><br \/>\nYes, it does take a while to get used to this weird syntax. But when used correctly, it really adds to the readability. Consider<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamSimpleFilter.png\" rel=\"attachment wp-att-14453\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14453\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamSimpleFilter.png\" alt=\"Stream using a simple logical filter\" width=\"542\" height=\"67\" \/><\/a><\/p>\n<p>verses the use of the helper methods on the (fairly) new <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/util\/Objects.html\" target=\"_blank\" rel=\"noopener\"><code>Objects<\/code><\/a> class:<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamMethodRefFilter.png\" rel=\"attachment wp-att-14452\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14452\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamMethodRefFilter.png\" alt=\"Stream with method reference\" width=\"546\" height=\"72\" \/><\/a><\/p>\n<p>This latter code is much more explicit about which values it wants to keep. \u00a0IntelliJ IDEA\u00a0will\u00a0usually let you know when a lambda can be collapsed to a method reference.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14454\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamLambdaCanBeMethodRef.png\" alt=\"Use method reference instead of lambda expression\" width=\"539\" height=\"81\" \/><\/p>\n<p><em>When iterating over a Collection, use the Streams API where possible<\/em><br \/>\n&#8230;or the new collections methods like <code>forEach<\/code>. \u00a0IntelliJ IDEA can suggest this to you:<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamRepalceForWithForEach.png\" rel=\"attachment wp-att-14455\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14455\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamRepalceForWithForEach.png\" alt=\"Replace iteration with forEach\" width=\"498\" height=\"96\" \/><\/a><\/p>\n<p>Generally using the Streams API is more explicit than a combination of for loops and if statements. \u00a0For example:<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamBefore.png\" rel=\"attachment wp-att-14457\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14457\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamBefore.png\" alt=\"Using traditional iteration\" width=\"524\" height=\"132\" \/><\/a><\/p>\n<p>IntelliJ IDEA suggests this can be refactored to:<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamAfter.png\" rel=\"attachment wp-att-14456\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14456\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamAfter.png\" alt=\"Using the Streams API\" width=\"645\" height=\"76\" \/><\/a><\/p>\n<p>The performance tests I&#8217;ve done show that this sort of refactoring can be surprising &#8211;\u00a0it&#8217;s not always predictable whether performance will stay the same, improve, or get worse.\u00a0As always,\u00a0if performance is critical in your application, measure it\u00a0before committing to one style over another.<\/p>\n<p><em>Use for loops when looping over\u00a0arrays<\/em><br \/>\nHowever, using\u00a0Java 8 doesn\u2019t necessarily mean you have to use streams and new collections methods everywhere. IntelliJ IDEA will suggest things that can be converted to streams, but that doesn\u2019t mean you have to say \u201cyes\u201d (remember <a href=\"https:\/\/www.jetbrains.com\/help\/idea\/2016.2\/suppressing-inspections.html\" target=\"_blank\" rel=\"noopener\">inspections can be suppressed<\/a> or <a href=\"https:\/\/www.jetbrains.com\/help\/idea\/2016.2\/disabling-and-enabling-inspections.html\" target=\"_blank\" rel=\"noopener\">turned off<\/a>).<\/p>\n<p>In particular, iterating over a small array of primitive types is almost definitely going to be better performance with a for loop, and probably (at least while Java developers are new to streams) more readable.<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamPreferArrayLoop.png\" rel=\"attachment wp-att-14458\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14458\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2016\/07\/idea-StreamPreferArrayLoop.png\" alt=\"For loops are faster over arrays\" width=\"360\" height=\"100\" \/><\/a><\/p>\n<p>As with any of the tips, this rule is not set in stone, but you should decide whether you are going to prefer using the Streams API where you can,\u00a0or whether you\u2019re still going to use loops for some operations. \u00a0Above all,\u00a0be consistent.<\/p>\n<h3>Finally<\/h3>\n<p>I&#8217;ve written\u00a0a <a href=\"https:\/\/blog.jetbrains.com\/upsource\/2016\/08\/03\/what-to-look-for-in-java-8-code\/\">similar but complimentary post on this topic<\/a>\u00a0for the Upsource blog, containing these\u00a0tips and more things to look out for in Java 8 code when you&#8217;re performing a code review.<\/p>\n<p>I\u2019m discovering new things every day, and sometimes my preferences change &#8211; method references, for example, I used to hate, and avoided having them in my code. I\u2019d love to hear your top tips!<\/p>\n","protected":false},"author":360,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","categories":[601],"tags":[756,2993],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/idea\/25388"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/idea"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/types\/idea"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/users\/360"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/comments?post=25388"}],"version-history":[{"count":0,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/idea\/25388\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/media?parent=25388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/categories?post=25388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/tags?post=25388"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/ja\/wp-json\/wp\/v2\/cross-post-tag?post=25388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}