From: Harpo Date: 2004-02-09T09:24:07+09:00 Subject: [newbie question] Variable visibility [I do apologize for my bad english] Hello, I'm learning Ruby and I think it is a very interesting way of passing time. I already wrote some programs like an enhanced "hello world", and some other programs a little bit more sophisticated but not much more useful. I now want to build a little project which would be usable in the so-called real world. Let me explain this in the fewest words I can before I speak of my philosophical problems : The purpose of the project is to display and manage a data structure, say a tree, and to disjoint the description of the tree from the way it is displayed ([G]UI used, layout, interaction with te end user and other things like this). The architecture I thought roughly consist of a manager which acts like a master with 2 slaves, the application which manage data in respond to manager requests and the the GUI stuff which interacts with the end-user. A typical example of use is the implemention of a file manager which manage a file system hierarchy subset (The display I consider should look like the one of a good file manager), the tree might also represent dependencies within software packages etc. I think an application which use that software to implement a file manager should be able to do it in 200 lines of Ruby code (including comments but not the full license). Thank you for following me so far, here is the point where the problems begin (despite the fact that the project is in progress, I already found its name "Onx"). A problem arise when I want the manager and the application objects communicate : Probably due to my heavy background of assembly and C programmer, I first imagine that these 2 objects might interact via an object which is passed from the manager to the application object appropriate method to handle the request and returned to the manager object with some data inside. This object class definition would be (very) roughly like this : # # The manager feeds req and node, the application feeds cc and msg # the array is fed by either manager or application depending on the # request # class OnxRequest < Array attr_reader :req :cc :msg :node attr_writer :req :cc :msg :node def initialize( req = nil, node = nil ) super @node = node # @req = req # request code (edit, delete etc.) @cc = nil # completion code @msg = nil # completion message # maybe some methods ... end end I know it would work, but I don't like it much because the manager has no need to write in the completion code, the application has no need to write in the request code, and the application programmer has no need to spend his time reading the documentation of the methods only used by the manager before finding the ones he needs. Another way is to define a class for a request object and another for the answer, I'm not sure it can solve many things. Maybe another way is to change the architecture and envisage something very different. I just don't know and this is the reason why I need some help to make a clean project design. It is probably not a typical Ruby concern, but I shouldn't like to see answers to this question in some obfuscating language and there may be some possibilities of Ruby to do it cleanly. This is the reason why I post in this NG. I thank you for the attention you paid to this post.