Quantcast
Channel: JetBrains Developer Community : Thread List - IntelliJ IDEA Users
Viewing all articles
Browse latest Browse all 5661

Improving readability of code

$
0
0

Hi, I was wondering if it was possible to do the following in IntelliJ:

 

I'm currently writing up a bunch of code, but my code is pretty difficult to read. An excerpt of a piece of a method that I have is as follows:

 

ArrayList<EnumMap<ComponentType,Component>> getComponentsFromKey(long key){

        Set<Map.Entry<Thing,EnumMap<ComponentType,Component>>> entries = components.entrySet();

        ArrayList<EnumMap<ComponentType,Component>> components = new ArrayList<EnumMap<ComponentType, Component>>();

        ...

        int heuristic = ((a+b/c)*2;

        ...

}

 

While everything seems to work as it should, the nested expressions make the code difficult to read at a glance, at least to me. Is it possible to format a block of code to insert spaces and/or line breaks in order to make long stretches of code more easier to read? Ie. something like the following:

 

ArrayList< EnumMap< ComponentType, Component> > getComponentsFromKey( long key ){

        Set<

               Map.Entry<Thing, EnumMap<ComponentType, Component> > > entries = components.entrySet();

        ArrayList< EnumMap<ComponentType, Component> > components = new ArrayList< EnumMap<ComponentType, Component> >();

        ...

        int heuristic = ((a + b) / c) * 2;

        ...

}

 

(maybe not exactly like this; there could be better ways to insert spaces/line breaks that make the code even more readable, but hopefully the idea comes through)

 

Naturally, I could insert the spaces/breaks myself if necessary. But I was wondering if IntelliJ had this feature to save time.on my part.


Viewing all articles
Browse latest Browse all 5661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>