-
Notifications
You must be signed in to change notification settings - Fork 194
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
Fix namespace of Swt: SwtShoes::* -> Shoes::Swt::* #6
Comments
Hi all, look at this again to recall the code structure. I've tried to make a minimum Shoes 4 branch. This is a personal sandbox for experiment. I got the following result. D:\tmp\shoes4>bin\swt-shoooes samples\test1.rb D:\tmp\shoes4>call jruby --1.9 -e "$:<< 'lib'; require 'shoes'; Shoes.backend = :SWT; require 'samples\test1.rb' " #<Shoes::App:0xeabd2f> Shoes::Check #<Java::OrgEclipseSwtWidgets::Button:0x779959> D:\tmp\shoes4>
I think that the code structure in this sandbox is reasonable. What do you think about it? |
In your sandbox, The 'swt' gem handles these, and they are available inside the 'swt' gem at ::Swt::SWT |
Agreed. I started on this a bit too, and think it's good to move stuff to |
@ashbb this is a great practice. I notice one problem, but I'm not sure what is the best way to solve it. I think the output should be
I started trying to make that happen in your code, and realized that it requires 2 levels of delegation:
I tried this idea out in ashbb#1 I don't know if this is a good idea or not. It seems too complicated. But I don't think it works well to
So I think we might need that other layer. |
Yep, I agree w Eric. It isn't pretty. The framework acts as a shim Peter Fitzgibbons On May 29, 2012, at 5:34 PM, Eric Watson
|
So this popped into my mind as I was washing dishes. I have noticed there have been NO DRAWINGS to speak of yet in this Shoes 4 discussion. Tsk, tsk. Next time, maybe I will even use color :) Shoes 3 is like a tricycleYou push the pedal, the wheel goes around. Pedals are tightly coupled to the wheel. You may not use a different wheel. Shoes 4 is like a bicycleYou push the pedal, the wheel goes around. The pedals are loosely coupled to the wheel. You may use different wheels. |
Well done! I like 'em as b&w line art. So... On Tue, May 29, 2012 at 10:50 PM, Eric Watson <
|
Very awesome @wasnotrice |
These could/should be added to some documentation or the README :) |
Well, thanks for the compliments! :) The question is: do the pictures help to clarify/explain/rationalize the proposed architecture? And also, how can you illustrate the current architecture? |
@wasnotrice said in the above post
#<Shoes::App:0xeabd2f> Shoes::Check #<Shoes::Swt::Check:0x779959> Umm,.. sorry, I don't agree with you. I still think the output should be #<Shoes::App:0xeabd2f> Shoes::Check #<Java::OrgEclipseSwtWidgets::Button:0x779959> @pjfitzgibbons said in the above post
I agree. But even so, I don't want to complicate the code. I revised the sandbox. Please review the code structure again. |
@ashbb this is why I think we need In your implementation, we don't control the interface to In terms of the bicycle diagram above, I think your code is permanently coupling the chain to the rear sprocket, so that we cannot simply replace the wheel with a different one and re-use the same chain, front chainring, and pedals. As I read your code, when we want to check the module Shoes
class Check
def check
@real.set_selection true
end
end
end That will work for Swt. But how will it work for Cairo, or Swing, or Qt? I'm going to rename a little here and say we need: module Shoes
class Check
def check
@gui.check # where @gui.class # => Shoes::Swt::Check
end
end
end
module Shoes
module Swt
class Check
def check
@real.set_selected true # where @real.class # => Java::OrgEclipseSwtWidgets::Button
end
end
end
end Then we can easily add other backend implementations in the same way. I think this is more work now, but will be less work later. Does that make sense? |
@wasnotrice Thank you for the explanation. Now I understood your story. :)
I agree. But your story is for developers, not for users. My story is for users. So, users (i.e. Shoes app programmers) can write the following snippet within their code (i.e. their Shoes app)! module Shoes
class Check
def check
@real.set_selection true
end
end
end But okay. If our goal is making a "pluggable" architecture, I agree your story. :) |
Um... correct me if I'm wrong, Shoesers... module Shoes
class Check
def check
@real.set_selection true
end
end
end Peter Fitzgibbons On Wed, May 30, 2012 at 10:23 AM, ashbb <
|
@wasnotrice, @pjfitzgibbons, @alindeman and folks, I still think the output should be Shoes.app do
p self #=> #<Shoes::App:0xeabd2f>
c = check
p c.class #=> Shoes::Check
p c.real #=> #<Java::OrgEclipseSwtWidgets::Button:0x779959>
end But, I understand that we need So, I improved my sandbox again. Now, we can write like this: # lib/shoes/check.rb
module Shoes
class Check
def check
gui_check
end
end
end
# lib/shoes/swt/check.rb
module Shoes
module Swt
module Check
def gui_check
@real.set_selected true
end
end
end
end Can we say we've reached a basic consensus? Or need further discussion? |
Oops, mistakenly pushed |
Now I feel you have achieved the separation I expected. For the Shoes-user-developer, the backend is "hidden". I like it. Peter Fitzgibbons On Thu, May 31, 2012 at 6:46 AM, ashbb <
|
@ashbb @pjfitzgibbons I have further discussion :P Full code is in my sandbox pull request ashbb#2 This version uses classes rather than modules for the backend objects like Here's the check code (compare to #6 (comment)) # lib/shoes/check.rb
module Shoes
class Check
def initialize app
@gui = Shoes.backend::Check.new(app)
end
attr_reader :gui
def real
@gui.real
end
end
end
# lib/shoes/swt/check.rb
class Shoes::Swt::Check
def initialize(app)
@real = Swt::Widgets::Button.new app.gui.shell, Swt::SWT::CHECK
end
attr_accessor :real
end What do you think? |
I'm IN. Keep going Shoes On! Peter Fitzgibbons On Thu, May 31, 2012 at 9:49 AM, Eric Watson <
|
#written by @wasnotrice
Great! I like your solution. Now I think we've reached a basic consensus. :) Try out the following three examples. They works as I expect. $ bin/swt-shoooes samples/test1.rb $ bin/swt-shoooes samples/test2.rb $ bin/swing-shoooes samples/teest1.rb #written by @pjfitzgibbons
Close this issue and start to revise shoes4/spec and shoes4/lib in accordance with our new code structure to make Shoes 4 into a bicycle. :) |
As discussed in shoes/brown_shoes#3
The text was updated successfully, but these errors were encountered: