IntelliJ IDEA 8 Refactorings: Introduce Parameter Object
As you might already have noticed from the Features list, IntelliJ IDEA 8 brings you 7 new refactorings to ease the daily coding routine. One of these refactorings is Introduce Parameter Object. Its name speaks for itself: when you have a large group of parameters which go a long way through a chain of delegating method calls, it lets you create a wrapper class that you can then use instead. Another case is when you have a group of method parameters semantically tied one to another – a wrapper class comes handy as well.
Look at how many parameters are passed to drawEdge method – six! Imagine how lengthy the calls to this method are and how it all swamps the code. No worries – IntelliJ IDEA can help us. As we can see, the X and Y coordinates and the edgeWidth naturally go together, so we can move them to their own object.
Right-click the method name and select Refactor | Introduce Parameter Object from the context menu.In the Introduce Parameter Object dialog, we can select whether we want to create a new class, inner class, or use an existing one to wrap the parameters. For this case, we opt to the first choice. Then, select the parameters to be extracted. As we decided, these are edgeWidth, x1, x2, y1, and y2. Click OK, and voila – the things are a lot easier now!
Subscribe to Blog updates
The Best of IntelliJ IDEA’s HTTP Client
In today's fast-paced tech world, easy and efficient management of web services and APIs is crucial. That's where IntelliJ IDEA's HTTP Client steps in, turning complex HTTP requests into a walk in the park. The HTTP Client is a feature-rich, text-based tool in IntelliJ IDEA Ultimate. It seamlessl…
Profile Java and Kotlin Code with the IntelliJ Profiler
At JetBrains, we believe that profiling Java and Kotlin code should be simple and accessible to all developers, regardless of their level of expertise. That’s why the IntelliJ Profiler puts ease of use and seamless integration at the forefront of its mission. In previous releases, we introduced a r…
History of Gradle Delegation Process in IntelliJ IDEA
Nowadays, a build tool is an essential part of any project, and IntelliJ IDEA integrates with the majority of them. Among the most popular build tools is Gradle. We’d like to give a brief historical overview of its integration with IntelliJ IDEA and the delegation process implemented inside the I…
How to Work With Protobuf-Maven Projects in IntelliJ IDEA
Protobuf, short for Protocol Buffers, is a language-agnostic data serialization format developed by Google. It is designed to efficiently and reliably serialize structured data to communicate between different systems and programming languages. Protobuf offers a compact binary representation of data…