Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract initialization of your code #6

Open
clbustos opened this issue Jul 26, 2013 · 2 comments
Open

Abstract initialization of your code #6

clbustos opened this issue Jul 26, 2013 · 2 comments

Comments

@clbustos
Copy link

On many classes, the initialize method is always the same

          def initialize
            super
            set_options(self.class.options) if self.class.options 
            self.class.data.setClassIndex(self.class.class_index) if self.class.class_index
            buildClassifier(self.class.data)
          end

You should create a base module, like RubyMining, with a method that run this procedure
Example:

        module RubyMining
        def init_classifier
            super
            set_options(self.class.options) if self.class.options 
            self.class.data.setClassIndex(self.class.class_index) if self.class.class_index
            buildClassifier(self.class.data)
         end
         end
         class Base < NaiveBayes
         include ::RubyMining
         def initialize
         super
          init_classifier
         end
         end
@clbustos
Copy link
Author

You could use metaprogramming, to create automagicly classes...

module Weka::Classifier::Trees
      java_import 'weka.classifiers.trees.J48'
      java_import 'weka.classifiers.trees.RandomForest'
      create_classifier :FT
      create_classifier :J48
end

@rjpbonnal
Copy link

Good point.
I would dedicate a section of the second part of GSoC to refactoring.
@alberto Claudio is right, first finish the implementation planned, then
start a strong refactoring.

I think the students should notice how tedious is re writing the same thing
all the times :)

On Fri, Jul 26, 2013 at 8:58 AM, Claudio Bustos [email protected]:

You could use metaprogramming, to create automagicly classes...

module Weka::Classifier::Trees
java_import 'weka.classifiers.trees.J48'
java_import 'weka.classifiers.trees.RandomForest'
create_classifier :FT
create_classifier :J48end


Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-21604638
.

Ra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants