SlideShare a Scribd company logo
Tooled Composite  Design Pattern Presentation by Andy Bulka CTO Austhink Software [email_address]
What is this about? Ever wanted to create a "direct manipulation" program where you select various tools and manipulate stuff on a workspace?  Like MS paint etc. These sorts of applications are quite difficult to build due to the many possible combinations of behavior that is needed.  Every tool must know what to do with each type of object.  How do we manage this sort of complexity?
By GOF author John Vlissides http://www.research.ibm.com/designpatterns/pubs/ph-sep99.pdf
The Problem
“ direct manipulation” metaphor. How do you represent shapes? How do you represent tools? How do tools and shapes interact? How do you enhance the editor with new shapes and tools?
Representing shapes COMPOSITE – design pattern
Representing “Tools” usually a palette of tools editor’s behavior changes with the current tool E.g. when  drawing  tool is active we  create  shapes;  E.g. when the  selection  tool is active we  select  shapes
Representing “Tools” STATE  – design pattern
How tools and shapes interact How a tool interacts with each shape is usually different m  x  n  possible interactions between  m  tools and  n  shapes.  How do we manage and organise this complexity?
Visitor
Visitor Shapes don’t have tool knowledge – tools do all the work.  Shapes just implement  AcceptVisitor(v)  and then do a v.VisitShape() or v.VisitEdge() or whatever they themselves are. Each tool has a    VisitShape   VisitEdge   VisitShapeRhEdgeZone method  that gets triggered in this way.
Example Sequence Start in Hover Tool All mouseMove events go to Hover tool As hover over shapes/edges you ask what is under me and change cursor.  You “visit” the shape and change cursor accordingly ToolHover -------------- VisitShape()   cursor = HAND VisitEdge()   cursor = ARROW
Example Sequence continued User Left Clicks HoverTool.OnLeftClick sees that you are over a resize zone shape, so switches to the Resize tool   Zones (e.g. resize zone) within shapes are also ‘shapes’ Resize tool.OnMouseMove resizes the shape you are on.  Repeatedly (as MouseMove events arrive). Resize tool.OnMouseUp switches back to the hover tool.
RTTI as  alternative to Visitor Have each tool use RTTI (runtime type info) to see what the type of the shape is and do something. Thus instead of each tool with numerous VisitSOMETHING() method, just have a single Visit() method with an  if  statement based on rtti inside. ToolHover -------------- Visit()   if target == Shape  // use of RTTI …   else if target == Edge   …..  ToolHover -------------- VisitShape()   … VisitEdge()   ...
RTTI as  alternative to Visitor When visitor was invented double dispatch was the only way to get around the lack of RTTI in C++ RTTI approach is simpler than visitor Easier to reuse and specialise tools since don’t have to modify visitor class every time add new shape – just subclass a tool and use RTTI
Events Funnel all events through to the  current tool . Each tool has custom handling for all the gui events e.g. mouseDown, mouseClick, mouseMove etc. Classic STATE pattern, passing through method invocations to the current state object
Tooled Composite pattern Rewire events as you swap tools SwapTool(tool)
Event Handling MouseUp might trigger exiting a tool and reverting to another tool e.g. back to Hover. State pattern – each state knows when to switch to another state – OR – outer class e.g. canvas knows
State Pattern – switching state Notice calls to “SetTool”
Prototype Pattern Use for creation tool Create a copy of an instance of an object Could create a new instance rather than prototype – depends on how complex the prototypical object is
Command Pattern Hook in command manager for undo/redo We use tool to generate a command and then run the command, which redoes the gui action, except through “official channels”  
Final Pattern
Reflections Classic approach -> visitor. Practical approach  -> use RTTI (or equivalent e.g. have each shape return a shapeType enum) for better comprehensibility. Classic approach -> 3D table of possibilities, with events, shapes, tools on each axis. Practical approach  -> table too sparse and complex, so just code for the cases you want.
Reflections Classic approach -> some blend of visitShape() / visitEdge() etc methods and mouse event methods, within each tool Practical approach  -> Skip most of the visit methods and do the logic in the mouse handling methods.  Generalise the mouse handling into one event (mouseAction) and use if statements to catch the situations of interest.  You know what the current shape is by having a pointer to it (set up for you by the tool or something).

More Related Content

Viewers also liked (6)

PDF
Python BCN Introduction to SQLAlchemy
theManda
 
PDF
Cake pattern. Presentation by Alex Famin at scalaby#14
Vasil Remeniuk
 
PPTX
Delivery modes
Heather Nash
 
KEY
Object Relational Mapping in PHP
Rob Knight
 
PPTX
Python PPT
Edureka!
 
PDF
Web Development with Python and Django
Michael Pirnat
 
Python BCN Introduction to SQLAlchemy
theManda
 
Cake pattern. Presentation by Alex Famin at scalaby#14
Vasil Remeniuk
 
Delivery modes
Heather Nash
 
Object Relational Mapping in PHP
Rob Knight
 
Python PPT
Edureka!
 
Web Development with Python and Django
Michael Pirnat
 

Similar to Tooled Composite Design Pattern presentation (20)

PPTX
My favorite slides
Mitchell Wand
 
PPT
Model Based Development For 3 D User Interfaces
Juan Manuel Gonzalez Calleros
 
PPT
3 d modeling part 2
Charles Flynt
 
PDF
Distributed Graphical User Interfaces to Class Diagram: Reverse Engineering A...
ijseajournal
 
PPSX
Prophecy Of Design Patterns
pradeepkothiyal
 
KEY
Architectures for Inclusive Design
colinbdclark
 
PPT
Ch09
guest50f28c
 
PDF
design pattern presentation 2.pdf
JonathasOliveira50
 
PDF
Intro to Software Engineering - Module Design
Radu_Negulescu
 
PPT
M04 Design Patterns
Dang Tuan
 
PDF
Refactoring
Yaniv Pessach
 
PDF
DojoX GFX Session Eugene Lazutkin SVG Open 2007
Eugene Lazutkin
 
PPT
12266422.ppt
CSEC5
 
PDF
Design Patterns Summer Course 2009-2010 - Session#1
Muhamad Hesham
 
PPT
M04_DesignPatterns software engineering.ppt
ssuser2d043c
 
PDF
FOCUS K3D AWG CAD/CAE
FOCUS K3D
 
PDF
ASE01.ppt
Ptidej Team
 
PDF
Module 4: UML In Action - Design Patterns
jaden65832
 
PPT
Rich User Interaction with SVG
stsire
 
My favorite slides
Mitchell Wand
 
Model Based Development For 3 D User Interfaces
Juan Manuel Gonzalez Calleros
 
3 d modeling part 2
Charles Flynt
 
Distributed Graphical User Interfaces to Class Diagram: Reverse Engineering A...
ijseajournal
 
Prophecy Of Design Patterns
pradeepkothiyal
 
Architectures for Inclusive Design
colinbdclark
 
design pattern presentation 2.pdf
JonathasOliveira50
 
Intro to Software Engineering - Module Design
Radu_Negulescu
 
M04 Design Patterns
Dang Tuan
 
Refactoring
Yaniv Pessach
 
DojoX GFX Session Eugene Lazutkin SVG Open 2007
Eugene Lazutkin
 
12266422.ppt
CSEC5
 
Design Patterns Summer Course 2009-2010 - Session#1
Muhamad Hesham
 
M04_DesignPatterns software engineering.ppt
ssuser2d043c
 
FOCUS K3D AWG CAD/CAE
FOCUS K3D
 
ASE01.ppt
Ptidej Team
 
Module 4: UML In Action - Design Patterns
jaden65832
 
Rich User Interaction with SVG
stsire
 
Ad

More from tcab22 (6)

PPTX
State Pattern In Flex
tcab22
 
PDF
Null Object Design Pattern
tcab22
 
PPT
Blackboard Pattern
tcab22
 
PPT
Tooled Composite Design Pattern
tcab22
 
PDF
Andy Bulka Pattern Automation
tcab22
 
PPT
Representing Design Patterns In Uml Andy Bulka Oct2006
tcab22
 
State Pattern In Flex
tcab22
 
Null Object Design Pattern
tcab22
 
Blackboard Pattern
tcab22
 
Tooled Composite Design Pattern
tcab22
 
Andy Bulka Pattern Automation
tcab22
 
Representing Design Patterns In Uml Andy Bulka Oct2006
tcab22
 
Ad

Recently uploaded (20)

PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Python basic programing language for automation
DanialHabibi2
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
July Patch Tuesday
Ivanti
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 

Tooled Composite Design Pattern presentation

  • 1. Tooled Composite Design Pattern Presentation by Andy Bulka CTO Austhink Software [email_address]
  • 2. What is this about? Ever wanted to create a "direct manipulation" program where you select various tools and manipulate stuff on a workspace?  Like MS paint etc. These sorts of applications are quite difficult to build due to the many possible combinations of behavior that is needed.  Every tool must know what to do with each type of object.  How do we manage this sort of complexity?
  • 3. By GOF author John Vlissides http://www.research.ibm.com/designpatterns/pubs/ph-sep99.pdf
  • 5. “ direct manipulation” metaphor. How do you represent shapes? How do you represent tools? How do tools and shapes interact? How do you enhance the editor with new shapes and tools?
  • 6. Representing shapes COMPOSITE – design pattern
  • 7. Representing “Tools” usually a palette of tools editor’s behavior changes with the current tool E.g. when drawing tool is active we create shapes; E.g. when the selection tool is active we select shapes
  • 8. Representing “Tools” STATE – design pattern
  • 9. How tools and shapes interact How a tool interacts with each shape is usually different m x n possible interactions between m tools and n shapes. How do we manage and organise this complexity?
  • 11. Visitor Shapes don’t have tool knowledge – tools do all the work. Shapes just implement AcceptVisitor(v) and then do a v.VisitShape() or v.VisitEdge() or whatever they themselves are. Each tool has a VisitShape VisitEdge VisitShapeRhEdgeZone method that gets triggered in this way.
  • 12. Example Sequence Start in Hover Tool All mouseMove events go to Hover tool As hover over shapes/edges you ask what is under me and change cursor. You “visit” the shape and change cursor accordingly ToolHover -------------- VisitShape() cursor = HAND VisitEdge() cursor = ARROW
  • 13. Example Sequence continued User Left Clicks HoverTool.OnLeftClick sees that you are over a resize zone shape, so switches to the Resize tool Zones (e.g. resize zone) within shapes are also ‘shapes’ Resize tool.OnMouseMove resizes the shape you are on. Repeatedly (as MouseMove events arrive). Resize tool.OnMouseUp switches back to the hover tool.
  • 14. RTTI as alternative to Visitor Have each tool use RTTI (runtime type info) to see what the type of the shape is and do something. Thus instead of each tool with numerous VisitSOMETHING() method, just have a single Visit() method with an if statement based on rtti inside. ToolHover -------------- Visit() if target == Shape // use of RTTI … else if target == Edge ….. ToolHover -------------- VisitShape() … VisitEdge() ...
  • 15. RTTI as alternative to Visitor When visitor was invented double dispatch was the only way to get around the lack of RTTI in C++ RTTI approach is simpler than visitor Easier to reuse and specialise tools since don’t have to modify visitor class every time add new shape – just subclass a tool and use RTTI
  • 16. Events Funnel all events through to the current tool . Each tool has custom handling for all the gui events e.g. mouseDown, mouseClick, mouseMove etc. Classic STATE pattern, passing through method invocations to the current state object
  • 17. Tooled Composite pattern Rewire events as you swap tools SwapTool(tool)
  • 18. Event Handling MouseUp might trigger exiting a tool and reverting to another tool e.g. back to Hover. State pattern – each state knows when to switch to another state – OR – outer class e.g. canvas knows
  • 19. State Pattern – switching state Notice calls to “SetTool”
  • 20. Prototype Pattern Use for creation tool Create a copy of an instance of an object Could create a new instance rather than prototype – depends on how complex the prototypical object is
  • 21. Command Pattern Hook in command manager for undo/redo We use tool to generate a command and then run the command, which redoes the gui action, except through “official channels” 
  • 23. Reflections Classic approach -> visitor. Practical approach -> use RTTI (or equivalent e.g. have each shape return a shapeType enum) for better comprehensibility. Classic approach -> 3D table of possibilities, with events, shapes, tools on each axis. Practical approach -> table too sparse and complex, so just code for the cases you want.
  • 24. Reflections Classic approach -> some blend of visitShape() / visitEdge() etc methods and mouse event methods, within each tool Practical approach -> Skip most of the visit methods and do the logic in the mouse handling methods. Generalise the mouse handling into one event (mouseAction) and use if statements to catch the situations of interest. You know what the current shape is by having a pointer to it (set up for you by the tool or something).