Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Implementing AST Vistitor inside or outside the Analysis class

Implementing AST Vistitor inside or outside the Analysis class

Scheduled Pinned Locked Moved Java
javadata-structures
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wathsala Bandara
    wrote on last edited by
    #1

    Hi, I'm writing a simple visitor-based analysis in Java using Eclipse. Here I have to implement a tree-walker analysis within Crystal. But I wanna know the difference (advantages/disadvantages) between implementing the visitor class inside the analysis class or outside that. Ex: Inner visitor class public class MyAnalysis extends AbstractCrystalMethodAnalysis { ... private class MyVisitor extends ASTVisitor { ... } ... } I really appreciate if some can tell me the difference between these two implementations.

    D 1 Reply Last reply
    0
    • W Wathsala Bandara

      Hi, I'm writing a simple visitor-based analysis in Java using Eclipse. Here I have to implement a tree-walker analysis within Crystal. But I wanna know the difference (advantages/disadvantages) between implementing the visitor class inside the analysis class or outside that. Ex: Inner visitor class public class MyAnalysis extends AbstractCrystalMethodAnalysis { ... private class MyVisitor extends ASTVisitor { ... } ... } I really appreciate if some can tell me the difference between these two implementations.

      D Offline
      D Offline
      David Skelly
      wrote on last edited by
      #2

      I would turn the question around and ask: why do you want to make the visitor a private inner class? What are you hoping to gain by doing that?

      W 1 Reply Last reply
      0
      • D David Skelly

        I would turn the question around and ask: why do you want to make the visitor a private inner class? What are you hoping to gain by doing that?

        W Offline
        W Offline
        Wathsala Bandara
        wrote on last edited by
        #3

        I'm new to this stuff. I was following some sample codes and there I saw inner-class implementations. So I wonder what's the difference between inner and outter implementations. BTW I'm implementing the AST visitor as a public class even inside the Analysis class.

        D 1 Reply Last reply
        0
        • W Wathsala Bandara

          I'm new to this stuff. I was following some sample codes and there I saw inner-class implementations. So I wonder what's the difference between inner and outter implementations. BTW I'm implementing the AST visitor as a public class even inside the Analysis class.

          D Offline
          D Offline
          David Skelly
          wrote on last edited by
          #4

          Usage of inner classes is one of those things that some Java coders get very worked up about, for and against. Personally, I don't much like them but they have their uses. There are plenty of opinions on the net about whether to use them, when to use them, how to use them. For every one person who says "Do it this way" you will find another who says "Don't do it that way". The one thing I would say is: if you are making AST Visitor publicly visible outside Analysis, why not just make it an outer class on its own? What do you gain by making it an inner class of Analysis?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups