patterns-discussion AT lists.siebelschool.illinois.edu
Subject: General talk about software patterns
List archive
- From: "Mike Beedle" <beedlem AT e-architects.com>
- To: <patterns-discussion AT cs.uiuc.edu>
- Subject: [patterns-discussion] Pattern-Oriented Programming
- Date: Fri, 22 Oct 2004 12:39:35 -0500
- List-archive: <http://mail.cs.uiuc.edu/pipermail/patterns-discussion>
- List-id: General talk about software patterns <patterns-discussion.cs.uiuc.edu>
;;----------------------------------------- ;; PATTERN LIBRARY – first example ;;----------------------------------------- ;; This is a Pattern Library (short) ;; i.e. Macros defining Patterns ;; like Strategy, etc. ;;--------------------------------- (defmacro make-strategy-structure(baseclass derivedclass method generic function initvalue) `(progn (defclass ,baseclass () ((,method :initform 0.0 :initarg :start :accessor ,method))) (defclass ,derivedclass (,baseclass) ((,method :initform ,initvalue :initarg :start :accessor ,method))) (defgeneric ,generic (,baseclass)) (defmethod ,generic ((base-class-instance ,baseclass)) (format t "~%We are in the generic") (funcall ,function) (print (,method base-class-instance)) )))
(defmacro make-strategy(baseclass derivedclass method initvalue) `(progn (defclass ,derivedclass (,baseclass) ((,method :initform ,initvalue :initarg :start :accessor ,method))) ))
;;---------------------------------- ;; Standard Existing Code to Reuse ;;---------------------------------- (defun defunexecute () (format t "~%We are in the defun") )
;;-------------------------------------- ;; PROGRAM by instantiating patterns ;;-------------------------------------- ;; Program using the Pattern Library ;; creates interacting inter-connected ;; "patterns" ;;-------------------------------------- (defparameter s1 nil) (defparameter s2 nil) (format t "~%~%Create a Strategy Hierarcy and execute it:~%") (make-strategy-structure service logging-service parameter executeGen #'defunexecute 'testfile) (setf s1 (make-instance 'logging-service :start 'myfile)) (print (parameter s1)) ;; executing generic (print (executeGen s1))
(format t "~%~%Create another Strategy and execute it:~%") (make-strategy service db-logging-service parameter 'testdb) (setf s2 (make-instance 'db-logging-service :start 'mydb)) ;; executing method (print (parameter s2))
;; print pattern code ;(pprint (macroexpand-1 '(make-strategy-structure service logging-service parameter execute #'defunexecute 'testfile)))
|
- [patterns-discussion] Pattern-Oriented Programming, Mike Beedle, 10/22/2004
- Re: [patterns-discussion] Pattern-Oriented Programming, Pascal Costanza, 10/22/2004
- <Possible follow-up(s)>
- RE: [patterns-discussion] Pattern-Oriented Programming, Mike Beedle, 10/24/2004
- Re: [patterns-discussion] Pattern-Oriented Programming, Ralph Johnson, 10/24/2004
- Re: [patterns-discussion] Pattern-Oriented Programming, Mark Grand, 10/24/2004
- Re: [patterns-discussion] Pattern-Oriented Programming, Pascal Costanza, 10/25/2004
- Re: [patterns-discussion] Pattern-Oriented Programming, Ralph Johnson, 10/26/2004
- RE: [patterns-discussion] Pattern-Oriented Programming, Chris Finlayson, 10/27/2004
- Re: [patterns-discussion] Pattern-Oriented Programming, Pascal Costanza, 10/28/2004
- RE: [patterns-discussion] Pattern-Oriented Programming, Chris Finlayson, 10/27/2004
- Re: [patterns-discussion] Pattern-Oriented Programming, Pascal Costanza, 10/25/2004
- Re: [patterns-discussion] Pattern-Oriented Programming, Ralph Johnson, 10/25/2004
- Re: [patterns-discussion] Pattern-Oriented Programming, Mark Grand, 10/24/2004
- Re: [patterns-discussion] Pattern-Oriented Programming, Ralph Johnson, 10/24/2004
Archive powered by MHonArc 2.6.16.