pgtgrly / GRruby-extension

C Extensions to GR Framework
5 stars 5 forks source link

Task design #7

Closed v0dro closed 6 years ago

v0dro commented 6 years ago

When I said 'each task should be a class' I did not mean 'each kind of plot should be a task'. Also, I did not expect you to hardcode values into the bar chart creator. Explain this?

I mean that each task in GR plot should be a separate class and calling artist methods should add certain tasks (aka classes) to the list.

So for example, GR.setviewport should be its own class like this:

module Tasks
  class SetViewPort
    def initialize(args, for, this, method)
      # save args in instance vars
    end

    def call
       GR.setviewport(@args, @for, @this, @method)
    end
  end
end

And then calling a method called foo inside ArtistPicasso should be like this:

class ArtistPicasso
  def foo
    @tasks << Tasks::SetViewPort.new(some, args)
  end

  def write
    @tasks.each { |t| t.call }
  end
end
translunar commented 6 years ago

I can see arguments for hardcoding a viewport. It's not going to vary plot to plot, is it?

v0dro commented 6 years ago

@mohawkjohn all the functions below it are also hardcoded. Also, the hardcoded values should be properly factored into a class level constant or something like that. The current implementation is too hack-y.