e-Commerce UML Use Case Diagram

This script (see usage) contains specific vocabularies for an e-commerce application see sample input and output.


e-commerce-use-case

e-commerce-use-case2b

Rebol [
    Title: "yUML Use Case"
    Author-Url: http://askuml.com
    Script-Url:  http://askuml.com/blog/e-commerce/
    Version: 1.0
    Date:  10-Jul-2010
    Purpose: {
            Generate yUML Use Case Diagram for e-commerce App
    }
]

do code-block/2; business rules parsing
do code-block/3; yUML function
do code-block/4; Robot Maker

print "Copy UML Script to clipboard ..."
input
Yuml-Orders-list: to-block read clipboard://
Create-Use-Case Yuml-Orders-list
clipboard: copy ""

foreach element Yuml-Output-List [
    append clipboard element
    append clipboard newline
    append clipboard newline
]

 Print mold/only Yuml-Output-List

 write clipboard:// mold/only Yuml-Output-List
 ;write clipboard:// clipboard
 ans: "Copied to clipboard... do you want to go to yUml.me (Y/N): "
if ans = "Y" [
    browse http://yuml.me/diagram/scruffy/usecase/draw
]
  note-rule: [(color: "beige") some [
    'note [
            copy note-string to 'fond thru 'fond copy color to end
            (append output rejoin ["note: " note-string "{" "bg:" color "}"])
            |
            copy note-string to  end  (append output rejoin ["note: " note-string "{" "bg:" color "}"])              

      ]
    ]
    |           copy note-string to 'fond thru 'fond copy color to end
            (append output rejoin ["note: " note-string "{" "bg:" color "}"])
            |
            copy note-string to  end  (append output rejoin ["note: " note-string "{" "bg:" color "}"])
  ]

  actor-rule: [some [ [copy Actor to 'is thru 'is 'a 'Actor (append output rejoin ["[" Actor "]"])]
      | [copy Actor to 'is thru 'is 'a copy Actor2 to end (append output rejoin ["[" Actor "]^[" Actor2 "]"])]
   ]
  ]

  extend-rule: [some [copy UseCase2 to 'Extend thru 'Extend copy UseCase1 to end (append output rejoin ["(" UseCase1 ")<(" UseCase2 ")"])]
  ]

  include-rule: [some [copy UseCase2 to 'Include thru 'Include copy UseCase1 to end (append output rejoin ["(" UseCase2 ")>(" UseCase1 ")"])]
]  

  use-rule: [some
[copy Actor to 'Connect thru 'Connect 'to copy UseCase to end (append output rejoin ["[" Actor "]-(" "Connect to " UseCase ")"])]
|
[copy Actor to 'Use thru 'Use copy UseCase to end (append output rejoin ["[" Actor "]-(" "Use " UseCase ")"])]
|
[copy Actor to 'List thru 'List copy UseCase to end (append output rejoin ["[" Actor "]-(" "List " UseCase ")"])]
|
[copy Actor to 'Show thru 'Show copy UseCase to end (append output rejoin ["[" Actor "]-(" "Show " UseCase ")"])]
|
[copy Actor to 'Search thru 'Search copy UseCase to end (append output rejoin ["[" Actor "]-(" "Search " UseCase ")"])]
|
[copy Actor to 'Select thru 'Select copy UseCase to end (append output rejoin ["[" Actor "]-(" "Select " UseCase ")"])]
|
[copy Actor to 'Checkout thru 'Checkout copy UseCase to end (append output rejoin ["[" Actor "]-(" "Checkout" ")"])]
|
[copy Actor to 'Pay thru 'Pay copy UseCase to end (append output rejoin ["[" Actor "]-(" "Pay" ")"])]
|
[copy Actor to 'Delete thru 'Delete copy UseCase to end (append output rejoin ["[" Actor "]-(" "Delete " UseCase ")"])]
|
[copy Actor to 'Modify thru 'Modify copy UseCase to end (append output rejoin ["[" Actor "]-(" "Modify " UseCase ")"])]
|
[copy Actor to 'Add thru 'Connect 'to copy UseCase to end (append output rejoin ["[" Actor "]-(" "Add to " UseCase ")"])]
|
[copy Actor to 'Manage thru 'Manage copy UseCase to end (append output rejoin ["[" Actor "]-(" "Manage " UseCase ")"])]

  ]

  yuml-rule: [(Actor: copy [] Actor2: copy []) actor-rule | extend-rule |  include-rule | use-rule | note-rule ]
Create-Use-Case: func[Yuml-Orders-list][
  Worker: Make Robot[]
  Robot-Orders: [
     Yuml-Output-List: copy []

     foreach Yuml-Orders Yuml-Orders-list [
         Print ["Yuml-Orders: " Yuml-Orders " started ..." newline]
         generate Yuml-Orders
         Print output
         Append Yuml-Output-List copy output

         Print ["Yuml-Orders: " Yuml-Orders " done! " newline]
         Print Newline
     ]
  ]

  Worker/Run Robot-Orders
  Yuml-Output-List
]
ROBOT: make object! [

    ;task1 function
  Generate: func [yuml-orders][

    output: copy ""

    block-orders-draft: parse/all yuml-orders "^/"
    block-orders: copy []
    foreach order block-orders-draft [

      if (length? (order: trim/head/tail order)) > 0 [
          append block-orders  order
      ]
    ]

    foreach order block-orders [
      order-block: to-block order
      parse order-block yuml-rule
      append output newline
    ]
  ]

  ;task2 function
  list: func [][
      foreach Task Tasks-List [
        print Task
      ]
  ]

  ;core engine
  run: func [code][

      Tasks-List: copy [] ; reset the list
      output: copy ""
      do bind code 'self
  ]
]

Sample UML Inputs (2 blocks scripts, first line of each block is an UML note):

{
    Product Catalog
    User List all Product Categories
    User List Products within a Category
    List Products within a Category Extend List all Product Categories
    Select some Products Extend List Products within a Category
    User Search Product
    User Show a Product Detail
    Show a Product Detail Extend Search Product
    Show a Product Detail Extend List Products within a Category
    Add to Shopping Cart Extend Select some Products
    Show a Product Detail Extend Select some Products
    Add to Shopping Cart Extend Show a Product Detail
}

{
    Shopping Cart
    User Connect to Login Page
    User is a Customer
    User Checkout
    Customer Checkout
    Delete a Product Extend Checkout
    Modify a Product Quantity Extend Checkout
    Pay Extend Checkout
    Pay include Connect to Login Page
}

Sample yUML Outputs (2 blocks scripts):

{note: Product Catalog{bg:beige}
[User]-(List all Product Categories)
[User]-(List Products within a Category)
(List all Product Categories)<(List Products within a Category)
(List Products within a Category)<(Select some Products)
[User]-(Search Product)
[User]-(Show a Product Detail)
(Search Product)<(Show a Product Detail)
(List Products within a Category)<(Show a Product Detail)
(Select some Products)<(Add to Shopping Cart)
(Select some Products)<(Show a Product Detail)
(Show a Product Detail)<(Add to Shopping Cart)
}

{
note: Shopping Cart{bg:beige}
[User]-(Connect to Login Page)
[User]^[Customer]
[User]-(Checkout)
[Customer]-(Checkout)
(Checkout)<(Delete a Product)
(Checkout)<(Modify a Product Quantity)
(Checkout)<(Pay)
(Pay)>(Connect to Login Page)
}

Copy a block script output ...
e-commerce-use-case-rebol

and copy it to http://yuml.me/diagram/scruffy/usecase/draw

Articles:

Defining Business Requirements using UML Use Case diagram

Books:

Applying Use Case Driven Object Modeling with UML: An Annotated e-Commerce Example

Bookmark and Share

Leave a comment