{"id":804,"date":"2014-10-27T16:31:06","date_gmt":"2014-10-27T16:31:06","guid":{"rendered":"http:\/\/blog.wholetomato.com\/?p=804"},"modified":"2014-10-27T16:31:06","modified_gmt":"2014-10-27T16:31:06","slug":"tools-to-understand-new-code-go-to","status":"publish","type":"post","link":"https:\/\/stage.wholetomato.com\/blog\/tools-to-understand-new-code-go-to\/","title":{"rendered":"Tools to understand new code: Go To"},"content":{"rendered":"<p>You&#8217;ve just started a new job and landed in front of a huge code base. Great! What a challenge! It would be nice to quickly get a general understanding of your project and be able to comfortably move around in the code. How do you do it?<\/p>\n<p>In my series of\u00c2\u00a0articles as a guest contributor to this blog, you will\u00c2\u00a0learn about my favorite Visual Assist tools that help with code understanding. My tools are:<\/p>\n<ul>\n<li>Go To<\/li>\n<li>Find<\/li>\n<li>Move<\/li>\n<li>Additional tips<\/li>\n<\/ul>\n<p>In this post, let&#8217;s take a look at <em>Go To<\/em> functionality.<\/p>\n<p>As an example project, let&#8217;s take a look at <a href=\"http:\/\/irrlicht.sourceforge.net\/\" target=\"_blank\">Irrlicht Engine<\/a>.<\/p>\n<p><strong>Go To<\/strong><\/p>\n<p>The feature in Visual Assist that I probably use most often is\u00c2\u00a0<em>Go To<\/em>. In short, it is an improvement for a very well-known tool from Visual Studio &#8211;\u00c2\u00a0<em>Go to definition\/declaration<\/em>. But, we all know how this works (or actually doesn&#8217;t work) in VS. Sometimes you have to wait for a response from VS, or simply you cannot go\u00c2\u00a0anywhere.<\/p>\n<p>With Visual Assist, you get a really nice, working version of the tool: just press <em>Alt+G<\/em>\u00c2\u00a0(the default keyboard shortcut), select where you want to go, and Visual Assist\u00c2\u00a0will go to\u00c2\u00a0it immediately!<\/p>\n<p><em>Alt+G<\/em>\u00c2\u00a0is especially useful when:<\/p>\n<ul>\n<li>You are reading a class interface and you want to go to the implementation of some method. You can take a glance at\u00c2\u00a0the internal code, then quickly go back to the interface.<\/li>\n<li>You want to check the declaration of a variable. Use <em>Go To<\/em>\u00c2\u00a0to see where the variable is declared (is it a local variable or maybe a member of a class).<\/li>\n<\/ul>\n<p><strong>Go To Example<\/strong><\/p>\n<p>I am in IParticleEmitter.h and I see the\u00c2\u00a0<code>class IParticleEmitter<\/code> interface declaration. There is an interesting method called <code>emitt(...)<\/code>\u00c2\u00a0&#8212; how is it implemented?<\/p>\n<p>I can use <em>Go To<\/em>\u00c2\u00a0and get the following result:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_iparticleemit.png?ssl=1\"><img decoding=\"async\" data-attachment-id=\"805\" data-permalink=\"https:\/\/stage.wholetomato.com\/blog\/tools-to-understand-new-code-go-to\/goto_iparticleemit\/\" data-orig-file=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_iparticleemit.png?fit=1457%2C271&amp;ssl=1\" data-orig-size=\"1457,271\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"goto_iparticleemit\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_iparticleemit.png?fit=300%2C56&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_iparticleemit.png?fit=1024%2C190&amp;ssl=1\" class=\"alignnone size-full wp-image-805\" src=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_iparticleemit.png?resize=660%2C122&#038;ssl=1\" alt=\"goto_iparticleemit\" width=\"660\" height=\"122\" srcset=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_iparticleemit.png?w=1457&amp;ssl=1 1457w, https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_iparticleemit.png?resize=300%2C56&amp;ssl=1 300w, https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_iparticleemit.png?resize=1024%2C190&amp;ssl=1 1024w, https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_iparticleemit.png?resize=768%2C143&amp;ssl=1 768w, https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_iparticleemit.png?resize=360%2C67&amp;ssl=1 360w\" sizes=\"(max-width: 660px) 100vw, 660px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>Of course, Visual Assist sees that a method can have multiple polymorphic implementations. <em>Go To<\/em>\u00c2\u00a0allows one to select the desired implementation and jump into it. In the list, you can move via arrow keys, mouse, or assigned numbers\/letters.<\/p>\n<p>Now, I am in the implementation of this method: <code>CParticleBoxEmitter::emitt.<\/code>\u00c2\u00a0There is some code:<\/p>\n<pre><code>if (MaxAngleDegrees)\r\n{\r\n    core::vector3df tgt = Direction;\r\n    tgt.rotateXYBy(os::Randomizer::frand() * MaxAngleDegrees);\r\n    tgt.rotateYZBy(os::Randomizer::frand() * MaxAngleDegrees);\r\n    tgt.rotateXZBy(os::Randomizer::frand() * MaxAngleDegrees);\r\n    p.vector = tgt;\r\n}\r\n<\/code><\/pre>\n<p>What is this <code>MaxAngleDegrees<\/code>? Is it a static constant or a class member? I can hover my mouse over it and get some basic information, but via <em>Go To<\/em>\u00c2\u00a0, I can go to the place where it is defined so I can see some more context.<\/p>\n<p>When I want to return (to the interface that I was looking at initially), I can do it in\u00c2\u00a0several ways:<\/p>\n<ul>\n<li>Ctrl+Tab to go to the previous window<\/li>\n<li>Ctrl+- to go to the previous location<\/li>\n<li>Navigate Back &#8212; a Visual Assist command that I will describe in another article<\/li>\n<\/ul>\n<p>Tip: Additionally, <em>Alt+G<\/em>\u00c2\u00a0works in other situations; for instance, press <em>Alt+G<\/em> when the caret is in a line with the <code>#include \"#xyz\"<\/code> statement. You will simply move to the header!<\/p>\n<p><strong>Go To Related<\/strong><\/p>\n<p>Visual Assist goes\u00c2\u00a0even further than\u00c2\u00a0<em>Go To<\/em> with the implementation of another commend &#8211;\u00c2\u00a0<em>Go To Related<\/em>. If you use <em>Shift+Alt+G<\/em>\u00c2\u00a0instead of <em>Alt+G<\/em>, you will see a much more advanced version of <em>Go To<\/em>. For instance:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_related_iparticle.png?ssl=1\"><img decoding=\"async\" data-attachment-id=\"806\" data-permalink=\"https:\/\/stage.wholetomato.com\/blog\/tools-to-understand-new-code-go-to\/goto_related_iparticle\/\" data-orig-file=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_related_iparticle.png?fit=965%2C191&amp;ssl=1\" data-orig-size=\"965,191\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"goto_related_iparticle\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_related_iparticle.png?fit=300%2C59&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_related_iparticle.png?fit=965%2C191&amp;ssl=1\" class=\"alignnone size-full wp-image-806\" src=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_related_iparticle.png?resize=660%2C130&#038;ssl=1\" alt=\"goto_related_iparticle\" width=\"660\" height=\"130\" srcset=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_related_iparticle.png?w=965&amp;ssl=1 965w, https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_related_iparticle.png?resize=300%2C59&amp;ssl=1 300w, https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_related_iparticle.png?resize=768%2C152&amp;ssl=1 768w, https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2014\/10\/goto_related_iparticle.png?resize=360%2C71&amp;ssl=1 360w\" sizes=\"(max-width: 660px) 100vw, 660px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>With <em>Shift+Alt+G<\/em>, I can see base classes, derived classes and even go to the definition a particular member!<\/p>\n<p><strong>Summary<\/strong><\/p>\n<p><em>Go To<\/em>\u00c2\u00a0 and its related commands, <em>Go To Related<\/em> and <em>Go To Member<\/em>, are some of\u00c2\u00a0the most important tools\u00c2\u00a0in Visual Assist. The <em>Go To<\/em> commands\u00c2\u00a0enable us to move in the code quickly and jump among\u00c2\u00a0definition\/use\/declaration. The\u00c2\u00a0implementations in Visual Assist are\u00c2\u00a0very advanced and more efficient that the native\u00c2\u00a0Visual Studio solution.<\/p>\n<p><strong>Learn More<\/strong><\/p>\n<p>You can learn more about the <em>Go To<\/em> commands in the documentation for Visual Assist:<\/p>\n<ul>\n<li><a title=\"Go To\" href=\"http:\/\/docs.wholetomato.com\/default.asp?W191\">Go To<\/a><\/li>\n<li><a title=\"Go To Related\" href=\"http:\/\/docs.wholetomato.com\/default.asp?W478\">Go To Related<\/a><\/li>\n<li><a title=\"Go To Member\" href=\"http:\/\/docs.wholetomato.com\/default.asp?W515\">Go To Member<\/a><\/li>\n<\/ul>\n<p><em>This article was contributed by\u00c2\u00a0Bartlomiej Filipek, who writes\u00c2\u00a0at\u00c2\u00a0<a href=\"http:\/\/www.bfilipek.com\/\" target=\"_blank\">Code And Graphics<\/a>\u00c2\u00a0&#8211;\u00c2\u00a0a technical blog about\u00c2\u00a0C++ and OpenGL.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You&#8217;ve just started a new job and landed in front of a huge code base. Great! What a challenge! It would be nice to quickly get a general understanding of your project and be able&#8230;<\/p>\n","protected":false},"author":66190671,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[672],"tags":[],"class_list":["post-804","post","type-post","status-publish","format-standard","hentry","category-tips-and-tricks"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pfhqii-cY","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/posts\/804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/users\/66190671"}],"replies":[{"embeddable":true,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/comments?post=804"}],"version-history":[{"count":12,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/posts\/804\/revisions"}],"predecessor-version":[{"id":845,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/posts\/804\/revisions\/845"}],"wp:attachment":[{"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/media?parent=804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/categories?post=804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/tags?post=804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}