
{"id":768,"date":"2014-12-08T20:26:45","date_gmt":"2014-12-08T20:26:45","guid":{"rendered":"http:\/\/www.codergears.com\/Blog\/?p=768"},"modified":"2014-12-10T12:36:01","modified_gmt":"2014-12-10T12:36:01","slug":"intellij-idea-internal-design","status":"publish","type":"post","link":"https:\/\/codergears.com\/Blog\/?p=768","title":{"rendered":"IntelliJ IDEA internal design"},"content":{"rendered":"<p>The first version of IntelliJ IDEA was released in January 2001, and at that\u00a0time it was one of the first available Java IDE with advanced code navigation and\u00a0code refactoring\u00a0capabilities integrated.<\/p>\n<p>In 2009 JetBrains open sourced its <a href=\"https:\/\/github.com\/JetBrains\/intellij-community\">community version<\/a>.\u00a0And since then, many IDEs based on it were created, like Android Studio from Google.<!--more--><\/p>\n<p>Let&#8217;s go inside the community version of Intellij IDEA using <a href=\"http:\/\/www.jarchitect.com\">JArchitect<\/a>, and discover some internal design choices.<\/p>\n<p><strong>1- Modularity<\/strong><\/p>\n<p>Intellij IDEA is modularized using many projects; the main one is &#8220;idea&#8221;. The utility classes are implemented in the &#8220;util&#8221; project and the &#8220;openapi&#8221; jar contains the types needed to develop the Intellij IDEA plugins.<\/p>\n<p>Here&#8217;s the list of the Intellij IDEA projects, and some statistics about their types:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1167\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij4.png\" alt=\"intellij4\" width=\"705\" height=\"301\" \/><\/a><\/p>\n<p>Each project contains many packages to modularize its code base and the <span style=\"color: #555555;\">Package-by-feature approach is adopted.<\/span><\/p>\n<p>Package-by-feature uses packages to reflect the feature set. It places all items related to a single feature (and only that feature) into a single directory\/package. This results in packages with high cohesion and high modularity, and with minimal coupling between packages. Items that work closely together are placed next to each other.<\/p>\n<p>Here are for example some packages from the idea project, which show that the types are grouped by feature.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-775\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij1.png\" alt=\"intellij1\" width=\"371\" height=\"516\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>2-The Intellij IDEA developers use widely the GoF Design Patterns<\/strong><\/p>\n<p>Design Patterns are a software engineering concept describing recurring solutions to common problems in software design. GoF patterns are the most popular ones.<\/p>\n<p>The Intellij IDEA\u00a0developers use extensively\u00a0the GOF patterns; here are\u00a0some of them used in the source code.<\/p>\n<p><em>2-1 Factory<\/em><\/p>\n<p>Using factory is interesting to isolate the instantiation logic and enforce the cohesion; here is the list of factories defined in the source code:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-777\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij3.png\" alt=\"intellij3\" width=\"380\" height=\"394\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Many factories are implemented; here are some of them inheriting from the TextEditorHighlihtingPassFactory.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-776\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij2.png\" alt=\"intellij2\" width=\"707\" height=\"336\" \/><\/a><\/p>\n<p><em>2-2 Adapter<\/em><\/p>\n<p>Adapter pattern works as a bridge between two incompatible interfaces. This type of design pattern comes under structural pattern as this pattern combines the capability of two independent interfaces.<\/p>\n<p>Many adapters are implemented in the Intellij IDEA source code:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/idea8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-891\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/idea8.png\" alt=\"idea8\" width=\"376\" height=\"409\" \/><\/a><\/p>\n<p><em>2-3 Decorator<\/em><\/p>\n<p><span style=\"color: #252525;\">The decorator pattern can be used to extend (decorate) the functionality of a certain object<\/span>\u00a0without altering its structure. Many decorators are implemented in Intellij IDEA.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/idea9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-893\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/idea9.png\" alt=\"idea9\" width=\"379\" height=\"408\" \/><\/a><\/p>\n<p><em>2-4 Proxy<\/em><\/p>\n<p>A proxy, in its most general form, is a class functioning as an interface to something else.<\/p>\n<p>Here&#8217;s for example the use of two proxies VirtualMachineProxy and StackFrameProxy by the classes FieldBreakpoint and FrameVariablesTree. The VirtualMachineProxy interface is used instead of the implementation. However, it&#8217;s not the case of the StackFrameProxyImpl which is coupled to FrameVariablesTree. Maybe a refactoring to remove this dependency is suitable.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1169\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij5.png\" alt=\"intellij5\" width=\"665\" height=\"233\" \/><\/a><\/p>\n<p><em>2-5 Facade<\/em><\/p>\n<p>Facade pattern hides the complexities of the system and provides an interface to the client using which the client can access the system. Here&#8217;s an\u00a0example of the CodeStyle facade implemented in Intellij IDEA.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1170\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij6.png\" alt=\"intellij6\" width=\"652\" height=\"327\" \/><\/a><\/p>\n<p><em>2-6 Visitor<\/em><\/p>\n<p>The\u00a0visitor design pattern\u00a0is a way of separating an\u00a0algorithm\u00a0from an object structure on which it operates.<\/p>\n<p>The highlighting feature is implemented using a visitor pattern.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1171\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij7.png\" alt=\"intellij7\" width=\"715\" height=\"218\" \/><\/a><\/p>\n<p><em>2-7 Strategy<\/em><\/p>\n<p>There are common situations when classes differ only in their behavior. In these\u00a0cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime.<\/p>\n<p>Many classes implement the strategy pattern in the Intellij IDEA source code:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1172\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij8.png\" alt=\"intellij8\" width=\"360\" height=\"412\" \/><\/a><\/p>\n<p><em>2-8 Builder<\/em><\/p>\n<p>This pattern allows a client object to construct a complex object; The ConrtolFlowBuilder is one of the builders implemented in Intellij IDEA source code.<\/p>\n<p>Here are the methods called by the ControlFlowBuilder.build method:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1173\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij9.png\" alt=\"intellij9\" width=\"482\" height=\"520\" \/><\/a><\/p>\n<p><strong>3- Coupling\u00a0<\/strong><\/p>\n<p>Low coupling is desirable because a change in one area of an application will require fewer changes throughout the entire application. In the long run, this could alleviate a lot of time, effort, and cost associated with modifying and adding new features to an application.<br \/>\nHere are three key benefits derived from using interfaces:<\/p>\n<ul>\n<li>An interface provides a way to define a contract that promotes reuse. If an object implements an interface then that object is to conform to a standard. An object that uses another object is called a consumer. An interface is a contract between an object and its consumer.<\/li>\n<li>An interface also provides a level of abstraction that makes programs easier to understand. Interfaces allow developers to start talking about the general way that code behaves without having to get in to a lot of detailed specifics.<\/li>\n<li>An interface enforces low coupling between components, what\u2019s make easy to protect the interface consumer from any implementation changes in the classes implementing the interfaces.<\/li>\n<\/ul>\n<p>Many interfaces and abstract classes are defined in Intellij IDEA to enforce the low coupling:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1175\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij11.png\" alt=\"intellij11\" width=\"336\" height=\"397\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>And here&#8217;s in blue the distribution in the Metric View\u00a0of these types in the source code.<\/p>\n<p style=\"color: #555555;\"><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1174\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij10.png\" alt=\"intellij10\" width=\"848\" height=\"376\" \/><\/a><\/p>\n<p style=\"color: #555555;\">In the Metric View, the code base is represented through a Treemap. Treemapping is a method for displaying tree-structured data by using nested rectangles. The tree structure used \u00a0is the usual code hierarchy:<\/p>\n<ul>\n<li>Project contains packages.<\/li>\n<li>Package contains types.<\/li>\n<li>Type contains methods and fields.<\/li>\n<\/ul>\n<p>The treemap view provides a useful way to represent the result of a CQLinq request; the blue rectangles represent this result, so we can visually see the types concerned by the request.<\/p>\n<p>As we can observe the interfaces and abstract classes are defined in almost all packages, which is useful to present the features provided by a package as contracts.<\/p>\n<p><strong>4- Cohesion<\/strong><\/p>\n<p>The single responsibility principle states that a class should not have more than one reason to change. Such a class is said to be cohesive. A high LCOM value generally pinpoints a poorly cohesive class. There are several LCOM metrics. The LCOM takes its values in the range [0-1]. The LCOM HS (HS stands for Henderson-Sellers) takes its values in the range [0-2]. A LCOM HS value highest than 1 should be considered alarming. Here are \u00a0to compute LCOM metrics:<\/p>\n<blockquote><p>LCOM = 1 \u2013 (sum(MF)\/M*F)<br \/>\nLCOM HS = (M \u2013 sum(MF)\/F)(M-1)<\/p><\/blockquote>\n<p style=\"color: #333333;\">Where:<\/p>\n<ul>\n<li>M is the number of methods in class (both static and instance methods are counted, it includes also constructors, properties getters\/setters, events add\/remove methods).<\/li>\n<li>F is the number of instance fields in the class.<\/li>\n<li>MF is the number of methods of the class accessing a particular instance field.<\/li>\n<li>Sum(MF) is the sum of MF over all instance fields of the class.<\/li>\n<\/ul>\n<p>The underlying idea behind these formulas can be stated as follow: a class is utterly cohesive if all its methods use <span style=\"color: #474747;\">all its instance fields, which means that sum(MF)=M*F and then LCOM = 0 and LCOMHS = 0.<\/span><\/p>\n<p>LCOMHS value higher than 1 should be considered alarming.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij12.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1176\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij12.png\" alt=\"intellij12\" width=\"460\" height=\"533\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Only very few types could be considered as not cohesive.<\/p>\n<p><strong>5- Multithreading and concurrency<\/strong><\/p>\n<p>To make the Intellij IDEA more reactive, many threads are created which improves the user experience .<\/p>\n<p>Let&#8217;s search for all methods starting directly or indirectly threads:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij13.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1177\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij13.png\" alt=\"intellij13\" width=\"457\" height=\"522\" \/><\/a><\/p>\n<p>The concurrency logic is isolated in the following packages:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij14.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1178\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij14.png\" alt=\"intellij14\" width=\"398\" height=\"399\" \/><\/a><\/p>\n<p>And to facilitate the concurrency development the <a href=\"https:\/\/www.jcp.org\/en\/jsr\/detail?id=166\">JSR166<\/a> is used.<\/p>\n<p>Here&#8217;s the list of all the types used from the jsr166 jar:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij32.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1210\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij32.png\" alt=\"intellij32\" width=\"430\" height=\"290\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>6- Abstractenss\u00a0vs\u00a0Instability graph<\/strong><\/p>\n<p>The idea behind this graph is that the more a code element of a program is popular, the more it should be abstract. Or in other words, avoid depending too much directly on implementations, depend on abstractions instead. By popular code element I mean a project (but the idea works also for packages and types) that is massively used by other projects of the program.<\/p>\n<p>It is not a good idea to have concrete types very popular in your code base. This provokes some Zones of Pains in your program, where changing the implementations can potentially affects a large portion of the program. And implementations are known to evolve more often than abstractions.<\/p>\n<p>The main sequence line (dotted) in the below\u00a0diagram shows how abstractness and instability should be balanced. A stable component would be positioned on the left. If you check the main sequence you can see that such a component should be very abstract to be near the desirable line \u2013 on the other hand, if its degree of abstraction is low, it is positioned in an area that is called the \u201czone of pain\u201d.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/AbstractnessVSInstability.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-886\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/AbstractnessVSInstability.png\" alt=\"AbstractnessVSInstability\" width=\"800\" height=\"800\" \/><\/a><\/p>\n<p>Only util is in the zone of pain, which is not really problematic. Indeed, in general an utility library \u00a0provides more some utility classes than features defined by interfaces.<\/p>\n<p><strong>7- Open API and plugin system<\/strong><\/p>\n<p>The use of plugins allows you to extend the\u00a0Intellij IDEA. The &#8220;openapi&#8221; jar is provided to achieve this goal.<\/p>\n<p>The openapi jar provides many interfaces that represent all the features we can use and extend from our plugins.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij24.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1192\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij24.png\" alt=\"intellij24\" width=\"450\" height=\"497\" \/><\/a><\/p>\n<p>An Intellij IDEA plugin contains one or many actions; many thousands of actions are implemented in the source code as shown by this following CQLinq query:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij23.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1191\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij23.png\" alt=\"intellij23\" width=\"572\" height=\"500\" \/><\/a><\/p>\n<p>Exploring an existing implemented action could help developers to develop easily their custom\u00a0plugins.<\/p>\n<p><strong>8- Improve performance using cache<\/strong><\/p>\n<p>Using a\u00a0<i style=\"color: #282828;\">cache<\/i><span style=\"color: #282828;\">\u00a0is a popular way to optimize your application.\u00a0Intellij IDEA uses two cache managers:<\/span><\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij26.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1194\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij26.png\" alt=\"intellij26\" width=\"580\" height=\"304\" \/><\/a><\/p>\n<p>The CacheManager interface is used by the FindInProjectTask to search for words.<\/p>\n<p>Here is the list of all methods called by FindInProjectTask.getFilesForFastWordSearch method:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij25.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1193\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij25.png\" alt=\"intellij25\" width=\"574\" height=\"498\" \/><\/a><\/p>\n<p><strong>9- External libraries used<\/strong><\/p>\n<p>Intellij IDEA uses many external jars, here&#8217;s the list of all the jars used:<br \/>\n<a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij21.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1189\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij21.png\" alt=\"intellij21\" width=\"349\" height=\"413\" \/><\/a><br \/>\n<a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij22.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1190\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij22.png\" alt=\"intellij22\" width=\"349\" height=\"396\" \/><\/a><\/p>\n<p>When external libs are used, it\u2019s better to check if we can easily change a third party lib by another one without impacting the whole application. There are many reasons that can encourage us to change a third party lib. The other lib could:<\/p>\n<ul>\n<li><span style=\"color: #555555;\">Have more features.<\/span><\/li>\n<li><span style=\"color: #555555;\">Be more powerful.<\/span><\/li>\n<li><span style=\"color: #555555;\">Be more secure.<\/span><\/li>\n<\/ul>\n<p>Let&#8217;s discover if some external libs are highly coupled or not.<\/p>\n<p><em>Swing:<\/em><\/p>\n<p>Swing implements a set of components for building graphical user interfaces (GUIs) and adding rich graphics functionality and interactivity to Java applications. The Swing components are implemented entirely in the Java programming language. The pluggable look and feel lets you create GUIs that can either look the same across platforms\u00a0or\u00a0can assume the look and feel of the current OS platform (such as Microsoft Windows, Solaris\u2122 or Linux).<\/p>\n<p>Let&#8217;s search for all types using directly swing components:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij18.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1185\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij18.png\" alt=\"intellij18\" width=\"424\" height=\"499\" \/><\/a><\/p>\n<p>Many types use directly swing components as shown by the following treemap which shows in blue these types.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij16.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1184\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij16.png\" alt=\"intellij16\" width=\"734\" height=\"294\" \/><\/a><\/p>\n<p>It&#8217;s not easy to change swing by another Gui framework. And even\u00a0if Swing is\u00a0<span style=\"color: #545454;\">\u00a0a subject of controversy, the amazing GUI of Intellij IDEA proves that Swing is a good choice for Gui needs.<\/span><\/p>\n<p><em>Netty:<\/em><\/p>\n<p>Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers &amp; clients.<\/p>\n<p>Here&#8217;s the list of all types using this library:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij20.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1188\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij20.png\" alt=\"intellij20\" width=\"389\" height=\"506\" \/><\/a><\/p>\n<p>Only some few types use it directly, which is very useful if we want to change it with another library.<\/p>\n<p><em>ASM:<\/em><\/p>\n<p><span style=\"color: #545454;\">ASM<\/span><span style=\"color: #545454;\">\u00a0is a very small and very fast Java bytecode manipulation framework. It becomes very popular, many tools use it. We used it also in our tool JArchitect to analyse the bytecode.<\/span><\/p>\n<p>Here&#8217;s the list of all types using ASM directly:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij19.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1187\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij19.png\" alt=\"intellij19\" width=\"377\" height=\"420\" \/><\/a><\/p>\n<p>As Netty , the use of ASM is isolated in some packages, and we can change it easily.<\/p>\n<p>Except Swing almost all other external jars are not highly coupled to Intellij IDEA.<\/p>\n<p><strong>10- Statistics<\/strong><\/p>\n<p>10-1 Most used type<\/p>\n<p>It\u2019s interesting to know the most used types in a project; indeed these types must be well designed, implemented and tested. And any change occurs to them could impact the whole project.<\/p>\n<p>We can find them using the\u00a0<em>TypesUsingMe<\/em>\u00a0metric:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij28.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1204\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij28.png\" alt=\"intellij28\" width=\"534\" height=\"428\" \/><\/a><\/p>\n<p>However, there\u2019s another interesting metric to search for popular types: TypeRank.<\/p>\n<p>TypeRank values are computed by applying the\u00a0<a href=\"http:\/\/www.iprcom.com\/papers\/pagerank\/\">Google PageRank<\/a>\u00a0algorithm on the graph of types\u2019 dependencies. A homothety of center 0.15 is applied to make it so that the average of TypeRank is 1.<\/p>\n<p>Types with high TypeRank should be more carefully tested because bugs in such types will likely be more catastrophic.<\/p>\n<p>Here\u2019s the result of all popular types according to the TypeRank metric:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij27.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1203\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij27.png\" alt=\"intellij27\" width=\"538\" height=\"498\" \/><\/a><\/p>\n<p>With this metric PsiElement became the most used type instead of the Project interface.<\/p>\n<p>10-2 Most used methods:<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij30.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1206\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij30.png\" alt=\"intellij30\" width=\"507\" height=\"497\" \/><\/a><\/p>\n<p>10-3 Methods calling many other methods<\/p>\n<p>It\u2019s interesting to know\u00a0the methods using many other ones; a design problem could be revealed in these methods.\u00a0And in some cases a refactoring is needed to make them more readable and maintainable.<\/p>\n<p><a href=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij31.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1207\" src=\"http:\/\/www.codergears.com\/Blog\/wp-content\/uploads\/intellij31.png\" alt=\"intellij31\" width=\"511\" height=\"499\" \/><\/a><\/p>\n<p><strong>Summary<\/strong><\/p>\n<p>Intellij IDEA is very well designed and implemented, many patterns are used and many best practices are implemented. Exploring its source code is a pragmatic way to learn how to design and implement your application. It&#8217;s better than reading only books and articles from the web to improve your design skills.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The first version of IntelliJ IDEA was released in January 2001, and at that\u00a0time it was one of the first available Java IDE with advanced code navigation and\u00a0code refactoring\u00a0capabilities integrated. In 2009 JetBrains open sourced its community version.\u00a0And since then, many IDEs based on it were created, like Android Studio from Google.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-768","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts\/768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=768"}],"version-history":[{"count":53,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts\/768\/revisions"}],"predecessor-version":[{"id":1261,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts\/768\/revisions\/1261"}],"wp:attachment":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}