Created
June 28, 2017 20:19
-
-
Save GeePawHill/ecdb0953a912809dace5d5c11ed3e843 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Desired code inside a thing that writes scripts: | |
Script writeIt() | |
{ | |
Format boxFormat = new Format(...); | |
LabelBox box1 = new LabelBox("Box 1", new Point(400d,400d), boxFormat); | |
LabelBox box2 = new LabelBox("Box 2", new Point(600d,600d), boxFormat); | |
Arrow arrow = new Arrow(box1,false,box2,true,boxFormat): | |
// here's the script proper | |
cue(3); // wait until the clock says it's 3. | |
sketch(500d, box1); // sketch the box in a half-second | |
sketch(500d, box2); | |
sketch(2000d, arrow); // slowly draw the arrow | |
swipe(0); // move & scale everything to fit in position 0 (lower right corner); | |
} | |
old-school: | |
just derive every writer of scripts from class ScriptWriter which has all those cue/sketch/etc methods, and use them. | |
with NII meaning 'never override a method' | |
same as old-school | |
with NII meaning 'never use extends' | |
1) define a helper, embed it in the person who writes scripts, prepend every line with "helper." | |
2) define helper with all statics, use import static ...Helper.*; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks like you want the semicolon operator in Smalltalk. The closest you have in Java is
Yes, this uses
extends
(at least in the background), but it doesn't override a concrete method and it elides the implicit receiverprimitiveOperationsLibrary
. It's a cheat, but I'd consider it here. It extendsScript
in such a way that avoids the risk of breaking a contract, since usingScript
this way has no contract, except forrun()
which runs the script.