Mailinglist Archive: yast-devel (144 mails)

< Previous Next >
Re: [yast-devel] Help: Lost in Ruby
Hi,

Dne 7.8.2013 12:01, Arvin Schnell napsal(a):>
> Hi,
>
> I would like to use some classes in the converted ruby code but I
> have problems with function lookup.
>
> [...]
>
> So what's the correct way here?

I didn't examine your patch in detail, but it seems to me that you are mixing Ruby concepts (classes, modules) with ones inherited from YaST (mainly includes). My general recommendations are the following:

* If you create a new class, put it into a separate file, don't make
it inherit from anything in Yast:: and don't make it part of any
YaST client, module or include. That will ensure separation of
concepts. One class per file is also usual convention in Ruby world.

* If you need to use a YaST module in your class, then just import it
and use it -- that should work well.

* If you need to use a YaST include in the class, include it via Ruby
include as a Ruby module and call its initialize_* method (if any)
manually in the constructor.

You correctly note that this is ugly. The better way is probably to
extract the include functionality you need into a separate Ruby
class/module, use it in your class, and just delegate to the
extracted part in the include.

* If you need to use any part of Ruby bindings (e.g. UI shortcuts) in
your class, just include the appropriate module. This may lead to
some duplication if you do it in many classes, which we will
probably need to address soon (in order to prevent everybody doing
his own thing).

I know this advice is pretty general, but I hope it helps at least a little. We need to have guidelines and conventions for all this, and improve any friction points. Josef planned to work on that (he wanted to do an example refactoring), but he is on vacation now. Once he returns, I am sure he'll be able to provide better advice than me and we'll drive the work on best YaST development practices forward.

--
David Majda
SUSE Studio developer
http://susestudio.com/
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups
References