From 077dbdc7435674c7e27e4cb032477054806bab99 Mon Sep 17 00:00:00 2001 From: saadshams Date: Fri, 26 Apr 2019 22:41:02 -0400 Subject: [PATCH] Updated docs --- README.md | 1 + src/core/controller/Controller.go | 93 ++++---- src/core/model/Model.go | 80 +++---- src/core/view/View.go | 122 ++++++----- src/interfaces/ICommand.go | 8 +- src/interfaces/IController.go | 47 +++-- src/interfaces/IFacade.go | 108 +++++----- src/interfaces/IMediator.go | 58 ++--- src/interfaces/IModel.go | 43 ++-- src/interfaces/INotification.go | 46 ++-- src/interfaces/INotifier.go | 27 ++- src/interfaces/IObserver.go | 29 +-- src/interfaces/IProxy.go | 25 ++- src/interfaces/IView.go | 91 ++++---- src/patterns/command/MacroCommand.go | 78 +++---- src/patterns/command/SimpleCommand.go | 20 +- src/patterns/facade/Facade.go | 198 ++++++++++-------- src/patterns/facade/Notifier.go | 35 ++-- src/patterns/mediator/Mediator.go | 36 ++-- src/patterns/observer/Notification.go | 56 ++--- src/patterns/observer/Observer.go | 24 ++- src/patterns/proxy/Proxy.go | 24 +-- test/core/controller/ControllerTestCommand.go | 4 +- .../core/controller/ControllerTestCommand2.go | 4 +- test/core/controller/ControllerTestVO.go | 2 +- test/core/controller/Controller_test.go | 12 +- test/core/model/Model_test.go | 12 +- test/core/view/ObserverTest.go | 6 +- test/core/view/ViewTestMediator.go | 2 +- test/core/view/ViewTestMediator2.go | 2 +- test/core/view/ViewTestMediator3.go | 2 +- test/core/view/ViewTestMediator4.go | 2 +- test/core/view/ViewTestMediator5.go | 2 +- test/core/view/ViewTestMediator6.go | 2 +- test/core/view/View_test.go | 24 +-- .../command/MacroCommandTestCommand.go | 4 +- .../command/MacroCommandTestSub1Command.go | 4 +- .../command/MacroCommandTestSub2Command.go | 4 +- test/patterns/command/MacroCommandTestVO.go | 2 +- test/patterns/command/MacroCommand_test.go | 46 ++-- .../command/SimpleCommandTestCommand.go | 6 +- test/patterns/command/SimpleCommandTestVO.go | 2 +- test/patterns/command/SimpleCommand_test.go | 14 +- test/patterns/facade/FacadeTestCommand.go | 4 +- test/patterns/facade/FacadeTestVO.go | 2 +- test/patterns/facade/Facade_test.go | 22 +- test/patterns/mediator/Mediator_test.go | 6 +- test/patterns/observer/Notification_test.go | 8 +- test/patterns/observer/Observer_test.go | 10 +- test/patterns/proxy/Proxy_test.go | 8 +- 50 files changed, 781 insertions(+), 686 deletions(-) diff --git a/README.md b/README.md index b1cc473..77cb19c 100755 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ require github.com/puremvc/puremvc-go-multicore-framework v1.0.0 * [Pipes](https://github.com/PureMVC/puremvc-go-util-pipes/wiki) ## Platforms / Technologies +* [Go](https://en.wikipedia.org/wiki/Go_(programming_language)) * [FreeBSD](https://en.wikipedia.org/wiki/FreeBSD) * [Linux](https://en.wikipedia.org/wiki/Linux) * [MacOS](https://en.wikipedia.org/wiki/MacOS) diff --git a/src/core/controller/Controller.go b/src/core/controller/Controller.go index 91f7226..a12392f 100755 --- a/src/core/controller/Controller.go +++ b/src/core/controller/Controller.go @@ -15,28 +15,31 @@ import ( "sync" ) -/** -A Multiton `IController` implementation. +/* +A Multiton IController implementation. -In PureMVC, the `Controller` class follows the +In PureMVC, the Controller class follows the 'Command and Controller' strategy, and assumes these responsibilities: -* Remembering which `ICommand`s are intended to handle which `INotifications`. -* Registering itself as an `IObserver` with the `View` for each `INotification` that it has an `ICommand` mapping for. -* Creating a new instance of the proper `ICommand` to handle a given `INotification` when notified by the `View`. -* Calling the `ICommand`'s `execute` method, passing in the `INotification`. +* Remembering which ICommands are intended to handle which INotifications. -Your application must register `ICommands` with the +* Registering itself as an IObserver with the View for each INotification that it has an ICommand mapping for. + +* Creating a new instance of the proper ICommand to handle a given INotification when notified by the View. + +* Calling the ICommand's execute method, passing in the INotification. + +Your application must register ICommands with the Controller. -The simplest way is to subclass `Facade`, -and use its `initializeController` method to add your +The simplest way is to subclass Facade, +and use its initializeController method to add your registrations. */ type Controller struct { Key string // The Multiton Key for this Core - commandMap map[string]func() interfaces.ICommand // Mapping of Notification names to funcs that returns `ICommand` Class instances + commandMap map[string]func() interfaces.ICommand // Mapping of Notification names to funcs that returns ICommand Class instances commandMapMutex sync.RWMutex // Mutex for commandMap view interfaces.IView // Local reference to View } @@ -44,11 +47,13 @@ type Controller struct { var instanceMap = map[string]interfaces.IController{} // The Multiton Controller instanceMap. var instanceMapMutex sync.RWMutex // instanceMap Mutex -/** - `Controller` Multiton Factory method. +/* + Controller Multiton Factory method. - parameter key: multitonKey - - parameter controllerFunc: reference that returns `IController` + + - parameter controllerFunc: reference that returns IController + - returns: the Multiton instance */ func GetInstance(key string, controllerFunc func() interfaces.IController) interfaces.IController { @@ -62,31 +67,31 @@ func GetInstance(key string, controllerFunc func() interfaces.IController) inter return instanceMap[key] } -/** - Initialize the Multiton `Controller` instance. +/* + Initialize the Singleton Controller instance. - Called automatically by the GetInstance. + Called automatically by the GetInstance. - Note that if you are using a subclass of `View` - in your application, you should *also* subclass `Controller` - and override the `InitializeController` method in the - following way: + Note that if you are using a subclass of View + in your application, you should also subclass Controller + and override the InitializeController method in the + following way: - func (self *MyController) InitializeController() { - self.commandMap = map[string]func() interfaces.ICommand{} - self.view = MyView.GetInstance(self.Key, func() interfaces.IView { return &MyView{Key: self.Key} }) - } + func (self *MyController) InitializeController() { + self.commandMap = map[string]func() interfaces.ICommand{} + self.view = MyView.GetInstance(self.Key, func() interfaces.IView { return &MyView{Key: self.Key} }) + } */ func (self *Controller) InitializeController() { self.commandMap = map[string]func() interfaces.ICommand{} self.view = view.GetInstance(self.Key, func() interfaces.IView { return &view.View{Key: self.Key} }) } -/** - If an `ICommand` has previously been registered - to handle a the given `INotification`, then it is executed. +/* + If an ICommand has previously been registered + to handle a the given INotification, then it is executed. - - parameter note: an `INotification` + - parameter note: an INotification */ func (self *Controller) ExecuteCommand(notification interfaces.INotification) { self.commandMapMutex.RLock() @@ -101,19 +106,20 @@ func (self *Controller) ExecuteCommand(notification interfaces.INotification) { commandInstance.Execute(notification) } -/** - Register a particular `ICommand` class as the handler - for a particular `INotification`. +/* + Register a particular ICommand class as the handler + for a particular INotification. - If an `ICommand` has already been registered to - handle `INotification`s with this name, it is no longer - used, the new `ICommand` is used instead. + If an ICommand has already been registered to + handle INotifications with this name, it is no longer + used, the new ICommand is used instead. The Observer for the new ICommand is only created if this the first time an ICommand has been regisered for this Notification name. - - parameter notificationName: the name of the `INotification` - - parameter commandFunc: reference that returns `ICommand` + - parameter notificationName: the name of the INotification + + - parameter commandFunc: reference that returns ICommand */ func (self *Controller) RegisterCommand(notificationName string, commandFunc func() interfaces.ICommand) { self.commandMapMutex.Lock() @@ -125,11 +131,12 @@ func (self *Controller) RegisterCommand(notificationName string, commandFunc fun self.commandMap[notificationName] = commandFunc } -/** +/* Check if a Command is registered for a given Notification - parameter notificationName: - - returns: whether a Command is currently registered for the given `notificationName`. + + - returns: whether a Command is currently registered for the given notificationName. */ func (self *Controller) HasCommand(notificationName string) bool { self.commandMapMutex.RLock() @@ -138,10 +145,10 @@ func (self *Controller) HasCommand(notificationName string) bool { return self.commandMap[notificationName] != nil } -/** - Remove a previously registered `ICommand` to `INotification` mapping. +/* + Remove a previously registered ICommand to INotification mapping. - - parameter notificationName: the name of the `INotification` to remove the `ICommand` mapping for + - parameter notificationName: the name of the INotification to remove the ICommand mapping for */ func (self *Controller) RemoveCommand(notificationName string) { self.commandMapMutex.Lock() @@ -153,7 +160,7 @@ func (self *Controller) RemoveCommand(notificationName string) { } } -/** +/* Remove an IController instance - parameter multitonKey: of IController instance to remove diff --git a/src/core/model/Model.go b/src/core/model/Model.go index 89f7ad7..ea95449 100755 --- a/src/core/model/Model.go +++ b/src/core/model/Model.go @@ -13,21 +13,22 @@ import ( "sync" ) -/** -A Multiton `IModel` implementation. +/* +A Multiton IModel implementation. -In PureMVC, the `Model` class provides +In PureMVC, the Model class provides access to model objects (Proxies) by named lookup. -The `Model` assumes these responsibilities: +The Model assumes these responsibilities: -* Maintain a cache of `IProxy` instances. -* Provide methods for registering, retrieving, and removing `IProxy` instances. +* Maintain a cache of IProxy instances. -Your application must register `IProxy` instances -with the `Model`. Typically, you use an -`ICommand` to create and register `IProxy` -instances once the `Facade` has initialized the Core +* Provide methods for registering, retrieving, and removing IProxy instances. + +Your application must register IProxy instances +with the Model. Typically, you use an +ICommand to create and register IProxy +instances once the Facade has initialized the Core actors. */ type Model struct { @@ -39,23 +40,13 @@ type Model struct { var instanceMap = map[string]interfaces.IModel{} // The Multiton Model instanceMap. var instanceMapMutex sync.RWMutex // instanceMapMutex for thread safety -/** - Initialize the `Model` instance. +/* + Model Multiton Factory method. - Called automatically by the `GetInstance`, this - is your opportunity to initialize the Multiton - instance in your subclass without overriding the - constructor. -*/ -func (self *Model) InitializeModel() { - self.proxyMap = map[string]interfaces.IProxy{} -} + - parameter key: multitonKey -/** - `Model` Multiton Factory method. + - parameter modelFunc: reference that returns IModel - - parameter key: multitonKey - - parameter modelFunc: reference that returns `IModel` - returns: the instance returned by the passed modelFunc */ func GetInstance(key string, modelFunc func() interfaces.IModel) interfaces.IModel { @@ -69,10 +60,22 @@ func GetInstance(key string, modelFunc func() interfaces.IModel) interfaces.IMod return instanceMap[key] } -/** - Register an `IProxy` with the `Model`. +/* + Initialize the Model instance. + + Called automatically by the GetInstance, this + is your opportunity to initialize the Multiton + instance in your subclass without overriding the + constructor. +*/ +func (self *Model) InitializeModel() { + self.proxyMap = map[string]interfaces.IProxy{} +} + +/* + Register an IProxy with the Model. - - parameter proxy: an `IProxy` to be held by the `Model`. + - parameter proxy: an IProxy to be held by the Model. */ func (self *Model) RegisterProxy(proxy interfaces.IProxy) { self.proxyMapMutex.Lock() @@ -83,11 +86,12 @@ func (self *Model) RegisterProxy(proxy interfaces.IProxy) { proxy.OnRegister() } -/** - Retrieve an `IProxy` from the `Model`. +/* + Retrieve an IProxy from the Model. - parameter proxyName: - - returns: the `IProxy` instance previously registered with the given `proxyName`. + + - returns: the IProxy instance previously registered with the given proxyName. */ func (self *Model) RetrieveProxy(proxyName string) interfaces.IProxy { self.proxyMapMutex.RLock(); @@ -96,11 +100,12 @@ func (self *Model) RetrieveProxy(proxyName string) interfaces.IProxy { return self.proxyMap[proxyName] } -/** - Remove an `IProxy` from the `Model`. +/* + Remove an IProxy from the Model. - - parameter proxyName: name of the `IProxy` instance to be removed. - - returns: the `IProxy` that was removed from the `Model` + - parameter proxyName: name of the IProxy instance to be removed. + + - returns: the IProxy that was removed from the Model */ func (self *Model) RemoveProxy(proxyName string) interfaces.IProxy { self.proxyMapMutex.Lock() @@ -114,11 +119,12 @@ func (self *Model) RemoveProxy(proxyName string) interfaces.IProxy { return proxy } -/** +/* Check if a Proxy is registered - parameter proxyName: - - returns: whether a Proxy is currently registered with the given `proxyName`. + + - returns: whether a Proxy is currently registered with the given proxyName. */ func (self *Model) HasProxy(proxyName string) bool { self.proxyMapMutex.RLock() @@ -127,7 +133,7 @@ func (self *Model) HasProxy(proxyName string) bool { return self.proxyMap[proxyName] != nil } -/** +/* Remove an IModel instance - parameter multitonKey: of IModel instance to remove diff --git a/src/core/view/View.go b/src/core/view/View.go index 1b2016f..478a698 100755 --- a/src/core/view/View.go +++ b/src/core/view/View.go @@ -14,6 +14,24 @@ import ( "sync" ) +/** +A Multiton IView implementation. +In PureMVC, the View class assumes these responsibilities: + +* Maintain a cache of IMediator instances. + +* Provide methods for registering, retrieving, and removing IMediators. + +* Notifiying IMediators when they are registered or removed. + +* Managing the observer lists for each INotification in the application. + +* Providing a method for attaching IObservers to an INotification's observer list. + +* Providing a method for broadcasting an INotification. + +* Notifying the IObservers of a given INotification when it broadcast. +*/ type View struct { Key string mediatorMap map[string]interfaces.IMediator // Mapping of Mediator names to Mediator instances @@ -25,24 +43,13 @@ type View struct { var instanceMap = map[string]interfaces.IView{} // The Multiton View instanceMap. var instanceMapMutex = sync.RWMutex{} // instanceMapMutex -/** - Initialize the Multiton View instance. - - Called automatically by the `GetInstance`, this - is your opportunity to initialize the Multiton - instance in your subclass without overriding the - constructor. -*/ -func (self *View) InitializeView() { - self.mediatorMap = map[string]interfaces.IMediator{} - self.observerMap = map[string][]interfaces.IObserver{} -} - -/** +/* View Multiton Factory method. - parameter key: multitonKey - - parameter viewFunc: reference that returns `IView` + + - parameter viewFunc: reference that returns IView + - returns: the Multiton instance returned by executing the passed viewFunc */ func GetInstance(key string, viewFunc func() interfaces.IView) interfaces.IView { @@ -56,12 +63,26 @@ func GetInstance(key string, viewFunc func() interfaces.IView) interfaces.IView return instanceMap[key] } -/** - Register an `IObserver` to be notified - of `INotifications` with a given name. +/* + Initialize the Multiton View instance. + + Called automatically by the GetInstance, this + is your opportunity to initialize the Multiton + instance in your subclass without overriding the + constructor. +*/ +func (self *View) InitializeView() { + self.mediatorMap = map[string]interfaces.IMediator{} + self.observerMap = map[string][]interfaces.IObserver{} +} + +/* + Register an IObserver to be notified + of INotifications with a given name. + + - parameter notificationName: the name of the INotifications to notify this IObserver of - - parameter notificationName: the name of the `INotifications` to notify this `IObserver` of - - parameter observer: the `IObserver` to register + - parameter observer: the IObserver to register */ func (self *View) RegisterObserver(notificationName string, observer interfaces.IObserver) { self.observerMapMutex.Lock() @@ -74,14 +95,14 @@ func (self *View) RegisterObserver(notificationName string, observer interfaces. } } -/** - Notify the `IObservers` for a particular `INotification`. +/* + Notify the IObservers for a particular INotification. - All previously attached `IObservers` for this `INotification`'s - list are notified and are passed a reference to the `INotification` in + All previously attached IObservers for this INotification's + list are notified and are passed a reference to the INotification in the order in which they were registered. - - parameter notification: the `INotification` to notify `IObservers` of. + - parameter notification: the INotification to notify IObservers of. */ func (self *View) NotifyObservers(notification interfaces.INotification) { self.observerMapMutex.RLock() @@ -105,10 +126,11 @@ func (self *View) NotifyObservers(notification interfaces.INotification) { } } -/** +/* Remove the observer for a given notifyContext from an observer list for a given Notification name. - parameter notificationName: which observer list to remove from + - parameter notifyContext: remove the observer with this object as its notifyContext */ func (self *View) RemoveObserver(notificationName string, notifyContext interface{}) { @@ -135,20 +157,20 @@ func (self *View) RemoveObserver(notificationName string, notifyContext interfac } } -/** - Register an `IMediator` instance with the `View`. +/* + Register an IMediator instance with the View. - Registers the `IMediator` so that it can be retrieved by name, - and further interrogates the `IMediator` for its - `INotification` interests. + Registers the IMediator so that it can be retrieved by name, + and further interrogates the IMediator for its + INotification interests. - If the `IMediator` returns any `INotification` - names to be notified about, an `Observer` is created encapsulating - the `IMediator` instance's `handleNotification` method - and registering it as an `Observer` for all `INotifications` the - `IMediator` is interested in. + If the IMediator returns any INotification + names to be notified about, an Observer is created encapsulating + the IMediator instance's handleNotification method + and registering it as an Observer for all INotifications the + IMediator is interested in. - - parameter mediator: a reference to the `IMediator` instance + - parameter mediator: a reference to the IMediator instance */ func (self *View) RegisterMediator(mediator interfaces.IMediator) { self.mediatorMapMutex.Lock() @@ -182,11 +204,12 @@ func (self *View) RegisterMediator(mediator interfaces.IMediator) { mediator.OnRegister() } -/** - Retrieve an `IMediator` from the `View`. +/* + Retrieve an IMediator from the View. + + - parameter mediatorName: the name of the IMediator instance to retrieve. - - parameter mediatorName: the name of the `IMediator` instance to retrieve. - - returns: the `IMediator` instance previously registered with the given `mediatorName`. + - returns: the IMediator instance previously registered with the given mediatorName. */ func (self *View) RetrieveMediator(mediatorName string) interfaces.IMediator { self.mediatorMapMutex.RLock() @@ -195,11 +218,12 @@ func (self *View) RetrieveMediator(mediatorName string) interfaces.IMediator { return self.mediatorMap[mediatorName] } -/** - Remove an `IMediator` from the `View`. +/* + Remove an IMediator from the View. + + - parameter mediatorName: name of the IMediator instance to be removed. - - parameter mediatorName: name of the `IMediator` instance to be removed. - - returns: the `IMediator` that was removed from the `View` + - returns: the IMediator that was removed from the View */ func (self *View) RemoveMediator(mediatorName string) interfaces.IMediator { self.mediatorMapMutex.Lock() @@ -227,11 +251,12 @@ func (self *View) RemoveMediator(mediatorName string) interfaces.IMediator { return mediator } -/** +/* Check if a Mediator is registered or not - parameter mediatorName: - - returns: whether a Mediator is registered with the given `mediatorName`. + + - returns: whether a Mediator is registered with the given mediatorName. */ func (self *View) HasMediator(mediatorName string) bool { self.mediatorMapMutex.RLock() @@ -240,8 +265,9 @@ func (self *View) HasMediator(mediatorName string) bool { return self.mediatorMap[mediatorName] != nil } -/** +/* Remove an IView instance + - parameter multitonKey: of IView instance to remove */ func RemoveView(key string) { diff --git a/src/interfaces/ICommand.go b/src/interfaces/ICommand.go index c10c4b7..9d115cb 100755 --- a/src/interfaces/ICommand.go +++ b/src/interfaces/ICommand.go @@ -8,16 +8,16 @@ package interfaces -/** +/* The interface definition for a PureMVC Command. */ type ICommand interface { INotifier - /** - Execute the `ICommand`'s logic to handle a given `INotification`. + /* + Execute the ICommand's logic to handle a given INotification. - - parameter note: an `INotification` to handle. + - parameter note: an INotification to handle. */ Execute(notification INotification) } diff --git a/src/interfaces/IController.go b/src/interfaces/IController.go index 3615066..8560518 100755 --- a/src/interfaces/IController.go +++ b/src/interfaces/IController.go @@ -8,53 +8,56 @@ package interfaces -/** +/* The interface definition for a PureMVC Controller. -In PureMVC, an `IController` implementor +In PureMVC, an IController implementor follows the 'Command and Controller' strategy, and assumes these responsibilities: -* Remembering which `ICommand`s are intended to handle which `INotifications`. -* Registering itself as an `IObserver` with the `View` for each `INotification` that it has an `ICommand` mapping for. -* Creating a new instance of the proper `ICommand` to handle a given `INotification` when notified by the `View`. -* Calling the `ICommand`'s `execute` method, passing in the `INotification`. +* Remembering which ICommands are intended to handle which INotifications. + +* Registering itself as an IObserver with the View for each INotification that it has an ICommand mapping for. + +* Creating a new instance of the proper ICommand to handle a given INotification when notified by the View. + +* Calling the ICommand's execute method, passing in the INotification. */ type IController interface { - /** - Initialize the Multiton `Controller` instance. + /* + Initialize the Multiton Controller instance. */ InitializeController() - /** - Register a particular `ICommand` class as the handler - for a particular `INotification`. + /* + Register a particular ICommand class as the handler + for a particular INotification. - - parameter notificationName: the name of the `INotification` - - parameter commandFunc: reference that returns `ICommand` + - parameter notificationName: the name of the INotification + - parameter commandFunc: reference that returns ICommand */ RegisterCommand(notificationName string, commandFunc func() ICommand) - /** - Execute the `ICommand` previously registered as the - handler for `INotification`s with the given notification name. + /* + Execute the ICommand previously registered as the + handler for INotifications with the given notification name. - - parameter notification: the `INotification` to execute the associated `ICommand` for + - parameter notification: the INotification to execute the associated ICommand for */ ExecuteCommand(notification INotification) - /** - Remove a previously registered `ICommand` to `INotification` mapping. + /* + Remove a previously registered ICommand to INotification mapping. - - parameter notificationName: the name of the `INotification` to remove the `ICommand` mapping for + - parameter notificationName: the name of the INotification to remove the ICommand mapping for */ RemoveCommand(notificationName string) - /** + /* Check if a Command is registered for a given Notification - parameter notificationName: - - returns: whether a Command is currently registered for the given `notificationName`. + - returns: whether a Command is currently registered for the given notificationName. */ HasCommand(notificationName string) bool } diff --git a/src/interfaces/IFacade.go b/src/interfaces/IFacade.go index 52526eb..229a8db 100755 --- a/src/interfaces/IFacade.go +++ b/src/interfaces/IFacade.go @@ -8,7 +8,7 @@ package interfaces -/** +/* The interface definition for a PureMVC Facade. The Facade Pattern suggests providing a single @@ -22,127 +22,127 @@ the rest of your application. type IFacade interface { INotifier - /** - Initialize the Multiton `Facade` instance. + /* + Initialize the Multiton Facade instance. Called automatically by the constructor. Override in your subclass to do any subclass specific initializations. Be - sure to call `super.initializeFacade()`, though. + sure to call super.initializeFacade(), though. */ InitializeFacade() - /** - Initialize the `Controller`. + /* + Initialize the Controller. */ InitializeController() - /** - Initialize the `Model`. + /* + Initialize the Model. */ InitializeModel() - /** - Initialize the `View`. + /* + Initialize the View. */ InitializeView() - /** - Register an `ICommand` with the `Controller`. + /* + Register an ICommand with the Controller. - - parameter noteName: the name of the `INotification` to associate the `ICommand` with. - - parameter commandFunc: reference that returns `ICommand` + - parameter noteName: the name of the INotification to associate the ICommand with. + - parameter commandFunc: reference that returns ICommand */ RegisterCommand(notificationName string, commandFunc func() ICommand) - /** - Remove a previously registered `ICommand` to `INotification` mapping from the Controller. + /* + Remove a previously registered ICommand to INotification mapping from the Controller. - - parameter notificationName: the name of the `INotification` to remove the `ICommand` mapping for + - parameter notificationName: the name of the INotification to remove the ICommand mapping for */ RemoveCommand(notificationName string) - /** + /* Check if a Command is registered for a given Notification - parameter notificationName: - - returns: whether a Command is currently registered for the given `notificationName`. + - returns: whether a Command is currently registered for the given notificationName. */ HasCommand(notificationName string) bool - /** - Register an `IProxy` with the `Model` by name. + /* + Register an IProxy with the Model by name. - - parameter proxy: the `IProxy` to be registered with the `Model`. + - parameter proxy: the IProxy to be registered with the Model. */ RegisterProxy(proxy IProxy) - /** - Retrieve a `IProxy` from the `Model` by name. + /* + Retrieve a IProxy from the Model by name. - - parameter proxyName: the name of the `IProxy` instance to be retrieved. - - returns: the `IProxy` previously regisetered by `proxyName` with the `Model`. + - parameter proxyName: the name of the IProxy instance to be retrieved. + - returns: the IProxy previously regisetered by proxyName with the Model. */ RetrieveProxy(proxyName string) IProxy - /** - Remove an `IProxy` instance from the `Model` by name. + /* + Remove an IProxy instance from the Model by name. - - parameter proxyName: the `IProxy` to remove from the `Model`. - - returns: the `IProxy` that was removed from the `Model` + - parameter proxyName: the IProxy to remove from the Model. + - returns: the IProxy that was removed from the Model */ RemoveProxy(proxyName string) IProxy - /** + /* Check if a Proxy is registered - parameter proxyName: - - returns: whether a Proxy is currently registered with the given `proxyName`. + - returns: whether a Proxy is currently registered with the given proxyName. */ HasProxy(proxyName string) bool - /** - Register an `IMediator` instance with the `View`. + /* + Register an IMediator instance with the View. - - parameter mediator: a reference to the `IMediator` instance + - parameter mediator: a reference to the IMediator instance */ RegisterMediator(mediator IMediator) - /** - Retrieve an `IMediator` instance from the `View`. + /* + Retrieve an IMediator instance from the View. - - parameter mediatorName: the name of the `IMediator` instance to retrievve - - returns: the `IMediator` previously registered with the given `mediatorName`. + - parameter mediatorName: the name of the IMediator instance to retrievve + - returns: the IMediator previously registered with the given mediatorName. */ RetrieveMediator(mediatorName string) IMediator - /** - Remove a `IMediator` instance from the `View`. + /* + Remove a IMediator instance from the View. - - parameter mediatorName: name of the `IMediator` instance to be removed. - - returns: the `IMediator` instance previously registered with the given `mediatorName`. + - parameter mediatorName: name of the IMediator instance to be removed. + - returns: the IMediator instance previously registered with the given mediatorName. */ RemoveMediator(mediatorName string) IMediator - /** + /* Check if a Mediator is registered or not - parameter mediatorName: - - returns: whether a Mediator is registered with the given `mediatorName`. + - returns: whether a Mediator is registered with the given mediatorName. */ HasMediator(mediatorName string) bool - /** - Notify `Observer`s. + /* + Notify Observers. - This method is left public mostly for backward - compatibility, and to allow you to send custom - notification classes using the facade. + This method is left public mostly for backward + compatibility, and to allow you to send custom + notification classes using the facade. - Usually you should just call sendNotification - and pass the parameters, never having to - construct the notification yourself. + Usually you should just call sendNotification + and pass the parameters, never having to + construct the notification yourself. - - parameter notification: the `INotification` to have the `View` notify `Observers` of. + - parameter notification: the INotification to have the View notify Observers of. */ NotifyObservers(notification INotification) } diff --git a/src/interfaces/IMediator.go b/src/interfaces/IMediator.go index 4eb4ee8..2a1b841 100755 --- a/src/interfaces/IMediator.go +++ b/src/interfaces/IMediator.go @@ -8,64 +8,74 @@ package interfaces -/** +/* The interface definition for a PureMVC Mediator. -In PureMVC, `IMediator` implementors assume these responsibilities: +In PureMVC, IMediator implementors assume these responsibilities: + +* Implement a common method which returns a list of all INotifications the IMediator has interest in. -* Implement a common method which returns a list of all `INotification`s the `IMediator` has interest in. * Implement a notification callback method. + * Implement methods that are called when the IMediator is registered or removed from the View. -Additionally, `IMediator`s typically: +Additionally, IMediators typically: * Act as an intermediary between one or more view components such as text boxes or list controls, maintaining references and coordinating their behavior. + * In Flash-based apps, this is often the place where event listeners are added to view components, and their handlers implemented. -* Respond to and generate `INotifications`, interacting with of the rest of the PureMVC app. -When an `IMediator` is registered with the `IView`, -the `IView` will call the `IMediator`'s -`listNotificationInterests` method. The `IMediator` will -return an `Array` of `INotification` names which +* Respond to and generate INotifications, interacting with of the rest of the PureMVC app. + +When an IMediator is registered with the IView, +the IView will call the IMediator's +listNotificationInterests method. The IMediator will +return an Array of INotification names which it wishes to be notified about. -The `IView` will then create an `Observer` object -encapsulating that `IMediator`'s (`handleNotification`) method -and register it as an Observer for each `INotification` name returned by -`listNotificationInterests`. +The IView will then create an Observer object +encapsulating that IMediator's (handleNotification) method +and register it as an Observer for each INotification name returned by +listNotificationInterests. */ type IMediator interface { INotifier - // Get the `IMediator` instance name + /* + Get the IMediator instance name + */ GetMediatorName() string - // Get the `IMediator`'s view component. + /* + Get the IMediator's view component. + */ GetViewComponent() interface{} - // Set the `IMediator`'s view component. + /* + Set the IMediator's view component. + */ SetViewComponent(viewComponent interface{}) - /** - List `INotification` interests. + /* + List INotification interests. - - returns: an `Array` of the `INotification` names this `IMediator` has an interest in. + - returns: an Array of the INotification names this IMediator has an interest in. */ ListNotificationInterests() []string - /** - Handle an `INotification`. + /* + Handle an INotification. - - parameter notification: the `INotification` to be handled + - parameter notification: the INotification to be handled */ HandleNotification(notification INotification) - /** + /* Called by the View when the Mediator is registered */ OnRegister() - /** + /* Called by the View when the Mediator is removed */ OnRemove() diff --git a/src/interfaces/IModel.go b/src/interfaces/IModel.go index 98f37ac..7c4a642 100755 --- a/src/interfaces/IModel.go +++ b/src/interfaces/IModel.go @@ -8,52 +8,53 @@ package interfaces -/** +/* The interface definition for a PureMVC Model. -In PureMVC, `IModel` implementors provide -access to `IProxy` objects by named lookup. +In PureMVC, IModel implementors provide +access to IProxy objects by named lookup. -An `IModel` assumes these responsibilities: +An IModel assumes these responsibilities: -* Maintain a cache of `IProxy` instances -* Provide methods for registering, retrieving, and removing `IProxy` instances +* Maintain a cache of IProxy instances + +* Provide methods for registering, retrieving, and removing IProxy instances */ type IModel interface { - /** - Initialize the `Model` instance. + /* + Initialize the Model instance. */ InitializeModel() - /** - Register an `IProxy` instance with the `Model`. + /* + Register an IProxy instance with the Model. - - parameter proxyName: the name to associate with this `IProxy` instance. - - parameter proxy: an object reference to be held by the `Model`. + - parameter proxyName: the name to associate with this IProxy instance. + - parameter proxy: an object reference to be held by the Model. */ RegisterProxy(proxy IProxy) - /** - Retrieve an `IProxy` instance from the Model. + /* + Retrieve an IProxy instance from the Model. - parameter proxyName: - - returns: the `IProxy` instance previously registered with the given `proxyName`. + - returns: the IProxy instance previously registered with the given proxyName. */ RetrieveProxy(proxyName string) IProxy - /** - Remove an `IProxy` instance from the Model. + /* + Remove an IProxy instance from the Model. - - parameter proxyName: name of the `IProxy` instance to be removed. - - returns: the `IProxy` that was removed from the `Model` + - parameter proxyName: name of the IProxy instance to be removed. + - returns: the IProxy that was removed from the Model */ RemoveProxy(proxyName string) IProxy - /** + /* Check if a Proxy is registered - parameter proxyName: - - returns: whether a Proxy is currently registered with the given `proxyName`. + - returns: whether a Proxy is currently registered with the given proxyName. */ HasProxy(proxyName string) bool } diff --git a/src/interfaces/INotification.go b/src/interfaces/INotification.go index 4264e9a..6115e1c 100755 --- a/src/interfaces/INotification.go +++ b/src/interfaces/INotification.go @@ -8,7 +8,7 @@ package interfaces -/** +/* The interface definition for a PureMVC Notification. PureMVC does not rely upon underlying event models such @@ -20,50 +20,50 @@ to support event-driven communication between the application and the actors of the MVC triad. Notifications are not meant to be a replacement for Events -in Flex/Flash/AIR. Generally, `IMediator` implementors +in Flex/Flash/AIR. Generally, IMediator implementors place event listeners on their view components, which they -then handle in the usual way. This may lead to the broadcast of `Notification`s to -trigger `ICommand`s or to communicate with other `IMediators`. `IProxy` and `ICommand` -instances communicate with each other and `IMediator`s -by broadcasting `INotification`s. +then handle in the usual way. This may lead to the broadcast of Notifications to +trigger ICommands or to communicate with other IMediators. IProxy and ICommand +instances communicate with each other and IMediators +by broadcasting INotifications. -A key difference between Flash `Event`s and PureMVC -`Notification`s is that `Event`s follow the +A key difference between Flash Events and PureMVC +Notifications is that Events follow the 'Chain of Responsibility' pattern, 'bubbling' up the display hierarchy -until some parent component handles the `Event`, while -PureMVC `Notification`s follow a 'Publish/Subscribe' +until some parent component handles the Event, while +PureMVC Notifications follow a 'Publish/Subscribe' pattern. PureMVC classes need not be related to each other in a parent/child relationship in order to communicate with one another -using `Notification`s. +using Notifications. */ type INotification interface { - /** - Get the name of the `INotification` instance. + /* + Get the name of the INotification instance. */ Name() string - /** - Set the body of the `INotification` instance + /* + Set the body of the INotification instance */ SetBody(body interface{}) - /** - Get the body of the `INotification` instance + /* + Get the body of the INotification instance */ Body() interface{} - /** - Set the type of the `INotification` instance + /* + Set the type of the INotification instance */ SetType(t string) - /** - Get the type of the `INotification` instance + /* + Get the type of the INotification instance */ Type() string - /** - Get the string representation of the `INotification` instance + /* + Get the string representation of the INotification instance */ String() string } diff --git a/src/interfaces/INotifier.go b/src/interfaces/INotifier.go index 8a0101d..1985bee 100755 --- a/src/interfaces/INotifier.go +++ b/src/interfaces/INotifier.go @@ -8,26 +8,26 @@ package interfaces -/** +/* The interface definition for a PureMVC Notifier. -`MacroCommand, Command, Mediator` and `Proxy` -all have a need to send `Notifications`. +MacroCommand, Command, Mediator and Proxy +all have a need to send Notifications. -The `INotifier` interface provides a common method called -`sendNotification` that relieves implementation code of -the necessity to actually construct `Notifications`. +The INotifier interface provides a common method called +sendNotification that relieves implementation code of +the necessity to actually construct Notifications. -The `Notifier` class, which all of the above mentioned classes -extend, also provides an initialized reference to the `Facade` +The Notifier class, which all of the above mentioned classes +extend, also provides an initialized reference to the Facade Singleton, which is required for the convienience method -for sending `Notifications`, but also eases implementation as these -classes have frequent `Facade` interactions and usually require +for sending Notifications, but also eases implementation as these +classes have frequent Facade interactions and usually require access to the facade anyway. */ type INotifier interface { - /** - Send a `INotification`. + /* + Send a INotification. Convenience method to prevent having to construct new notification instances in our implementation code. @@ -38,14 +38,13 @@ type INotifier interface { */ SendNotification(notificationName string, body interface{}, _type string) - /** + /* Initialize this INotifier instance. This is how a Notifier get to Calls to sendNotification or to access the facade will fail until after this method has been called. - */ InitializeNotifier(key string) } diff --git a/src/interfaces/IObserver.go b/src/interfaces/IObserver.go index 746fd14..eb6611a 100755 --- a/src/interfaces/IObserver.go +++ b/src/interfaces/IObserver.go @@ -8,14 +8,17 @@ package interfaces -/** +/* The interface definition for a PureMVC Observer. -In PureMVC, `IObserver` implementors assume these responsibilities: +In PureMVC, IObserver implementors assume these responsibilities: * Encapsulate the notification (callback) method of the interested object. + * Encapsulate the notification context (self) of the interested object. + * Provide methods for setting the interested object' notification method and context. + * Provide a method for notifying the interested object. PureMVC does not rely upon underlying event @@ -30,37 +33,37 @@ MVC triad. An Observer is an object that encapsulates information about an interested object with a notification method that -should be called when an `INotification` is broadcast. The Observer then +should be called when an INotification is broadcast. The Observer then acts as a proxy for notifying the interested object. -Observers can receive `Notification`s by having their -`notifyObserver` method invoked, passing -in an object implementing the `INotification` interface, such -as a subclass of `Notification`. +Observers can receive Notifications by having their +notifyObserver method invoked, passing +in an object implementing the INotification interface, such +as a subclass of Notification. */ type IObserver interface { - /** + /* Set the notification method. - The notification method should take one parameter of type `INotification` + The notification method should take one parameter of type INotification - parameter notifyMethod: the notification (callback) method of the interested object */ SetNotifyMethod(notifyMethod func(notification INotification)) - /** + /* Set the notification context (self) of the interested object. */ SetNotifyContext(notifyContext interface{}) - /** + /* Notify the interested object. - - parameter notification: the `INotification` to pass to the interested object's notification method + - parameter notification: the INotification to pass to the interested object's notification method */ NotifyObserver(notification INotification) - /** + /* Compare the given object to the notificaiton context object. - parameter object: the object to compare. diff --git a/src/interfaces/IProxy.go b/src/interfaces/IProxy.go index 31d2b7f..c0a392a 100755 --- a/src/interfaces/IProxy.go +++ b/src/interfaces/IProxy.go @@ -8,46 +8,51 @@ package interfaces -/** +/* The interface definition for a PureMVC Proxy. -In PureMVC, `IProxy` implementors assume these responsibilities: +In PureMVC, IProxy implementors assume these responsibilities: * Implement a common method which returns the name of the Proxy. + * Provide methods for setting and getting the data object. -Additionally, `IProxy`s typically: +Additionally, IProxys typically: * Maintain references to one or more pieces of model data. + * Provide methods for manipulating that data. -* Generate `INotifications` when their model data changes. -* Expose their name as a `public static const` called `NAME`, if they are not instantiated multiple times. + +* Generate INotifications when their model data changes. + +* Expose their name as a public static const called NAME, if they are not instantiated multiple times. + * Encapsulate interaction with local or remote services used to fetch and persist model data. */ type IProxy interface { INotifier - /** + /* Get the Proxy name */ GetProxyName() string - /** + /* Set the data object */ SetData(data interface{}) - /** + /* Get the data object */ GetData() interface{} - /** + /* Called by the Model when the Proxy is registered */ OnRegister() - /** + /* Called by the Model when the Proxy is removed */ OnRemove() diff --git a/src/interfaces/IView.go b/src/interfaces/IView.go index 7802b55..bf2df16 100755 --- a/src/interfaces/IView.go +++ b/src/interfaces/IView.go @@ -8,36 +8,41 @@ package interfaces -/** +/* The interface definition for a PureMVC View. -In PureMVC, `IView` implementors assume these responsibilities: +In PureMVC, IView implementors assume these responsibilities: -In PureMVC, the `View` class assumes these responsibilities: +In PureMVC, the View class assumes these responsibilities: -* Maintain a cache of `IMediator` instances. -* Provide methods for registering, retrieving, and removing `IMediators`. -* Managing the observer lists for each `INotification` in the application. -* Providing a method for attaching `IObservers` to an `INotification`'s observer list. -* Providing a method for broadcasting an `INotification`. -* Notifying the `IObservers` of a given `INotification` when it broadcast. +* Maintain a cache of IMediator instances. + +* Provide methods for registering, retrieving, and removing IMediators. + +* Managing the observer lists for each INotification in the application. + +* Providing a method for attaching IObservers to an INotification's observer list. + +* Providing a method for broadcasting an INotification. + +* Notifying the IObservers of a given INotification when it broadcast. */ type IView interface { - /** + /* Initialize the Multiton View instance. */ InitializeView() - /** - Register an `IObserver` to be notified - of `INotifications` with a given name. + /* + Register an IObserver to be notified + of INotifications with a given name. - - parameter notificationName: the name of the `INotifications` to notify this `IObserver` of - - parameter observer: the `IObserver` to register + - parameter notificationName: the name of the INotifications to notify this IObserver of + - parameter observer: the IObserver to register */ RegisterObserver(notificationName string, observer IObserver) - /** + /* Remove a group of observers from the observer list for a given Notification name. - parameter notificationName: which observer list to remove from @@ -45,56 +50,56 @@ type IView interface { */ RemoveObserver(notificationName string, notifyContext interface{}) - /** - Notify the `IObservers` for a particular `INotification`. + /* + Notify the IObservers for a particular INotification. - All previously attached `IObservers` for this `INotification`'s - list are notified and are passed a reference to the `INotification` in + All previously attached IObservers for this INotification's + list are notified and are passed a reference to the INotification in the order in which they were registered. - - parameter notification: the `INotification` to notify `IObservers` of. + - parameter notification: the INotification to notify IObservers of. */ NotifyObservers(notification INotification) - /** - Register an `IMediator` instance with the `View`. + /* + Register an IMediator instance with the View. - Registers the `IMediator` so that it can be retrieved by name, - and further interrogates the `IMediator` for its - `INotification` interests. + Registers the IMediator so that it can be retrieved by name, + and further interrogates the IMediator for its + INotification interests. - If the `IMediator` returns any `INotification` - names to be notified about, an `Observer` is created encapsulating - the `IMediator` instance's `handleNotification` method - and registering it as an `Observer` for all `INotifications` the - `IMediator` is interested in. + If the IMediator returns any INotification + names to be notified about, an Observer is created encapsulating + the IMediator instance's handleNotification method + and registering it as an Observer for all INotifications the + IMediator is interested in. - - parameter mediatorName: the name to associate with this `IMediator` instance - - parameter mediator: a reference to the `IMediator` instance + - parameter mediatorName: the name to associate with this IMediator instance + - parameter mediator: a reference to the IMediator instance */ RegisterMediator(mediator IMediator) - /** - Retrieve an `IMediator` from the `View`. + /* + Retrieve an IMediator from the View. - - parameter mediatorName: the name of the `IMediator` instance to retrieve. - - returns: the `IMediator` instance previously registered with the given `mediatorName`. + - parameter mediatorName: the name of the IMediator instance to retrieve. + - returns: the IMediator instance previously registered with the given mediatorName. */ RetrieveMediator(mediatorName string) IMediator - /** - Remove an `IMediator` from the `View`. + /* + Remove an IMediator from the View. - - parameter mediatorName: name of the `IMediator` instance to be removed. - - returns: the `IMediator` that was removed from the `View` + - parameter mediatorName: name of the IMediator instance to be removed. + - returns: the IMediator that was removed from the View */ RemoveMediator(mediatorName string) IMediator - /** + /* Check if a Mediator is registered or not - parameter mediatorName: - - returns: whether a Mediator is registered with the given `mediatorName`. + - returns: whether a Mediator is registered with the given mediatorName. */ HasMediator(mediatorName string) bool } diff --git a/src/patterns/command/MacroCommand.go b/src/patterns/command/MacroCommand.go index 1a57bef..366b4a7 100755 --- a/src/patterns/command/MacroCommand.go +++ b/src/patterns/command/MacroCommand.go @@ -13,23 +13,23 @@ import ( "github.com/puremvc/puremvc-go-multicore-framework/src/patterns/facade" ) -/** -A base `ICommand` implementation that executes other `ICommand`s. - -A `MacroCommand` maintains an list of -`ICommand` Class references called *SubCommands*. - -When `execute` is called, the `MacroCommand` -retrieves `ICommands` by executing funcs and then calls -`execute` on each of its *SubCommands* turn. -Each *SubCommand* will be passed a reference to the original -`INotification` that was passed to the `MacroCommand`'s -`execute` method. - -Unlike `SimpleCommand`, your subclass -should not override `execute`, but instead, should -override the `initializeMacroCommand` method, -calling `addSubCommand` once for each *SubCommand* +/* +A base ICommand implementation that executes other ICommands. + +A MacroCommand maintains an list of +ICommand Class references called SubCommands. + +When execute is called, the MacroCommand +retrieves ICommands by executing funcs and then calls +execute on each of its SubCommands turn. +Each SubCommand will be passed a reference to the original +INotification that was passed to the MacroCommand's +execute method. + +Unlike SimpleCommand, your subclass +should not override execute, but instead, should +override the initializeMacroCommand method, +calling addSubCommand once for each SubCommand to be executed. */ type MacroCommand struct { @@ -37,47 +37,47 @@ type MacroCommand struct { SubCommands []func() interfaces.ICommand } -/** - Initialize the `MacroCommand`. +/* + Initialize the MacroCommand. - In your subclass, override this method to - initialize the `MacroCommand`'s *SubCommand* - list with func references like - this: + In your subclass, override this method to + initialize the MacroCommand's *SubCommand* + list with func references like + this: - // Initialize MyMacroCommand - func (self *MacroCommandTestCommand) InitializeMacroCommand() { - self.AddSubCommand(func() interfaces.ICommand { return &FirstCommand{} }) - self.AddSubCommand(func() interfaces.ICommand { return &SecondCommand{} }) - self.AddSubCommand(func() interfaces.ICommand { return &ThirdCommand{} }) - } + // Initialize MyMacroCommand + func (self *MacroCommandTestCommand) InitializeMacroCommand() { + self.AddSubCommand(func() interfaces.ICommand { return &FirstCommand{} }) + self.AddSubCommand(func() interfaces.ICommand { return &SecondCommand{} }) + self.AddSubCommand(func() interfaces.ICommand { return &ThirdCommand{} }) + } - Note that *SubCommands* may be any func returning `ICommand` - implementor, `MacroCommands` or `SimpleCommands` are both acceptable. + Note that SubCommands may be any func returning ICommand + implementor, MacroCommands or SimpleCommands are both acceptable. */ func (self *MacroCommand) InitializeMacroCommand() { } -/** - Add a *SubCommand*. +/* + Add a SubCommand. - The *SubCommands* will be called in First In/First Out (FIFO) + The SubCommands will be called in First In/First Out (FIFO) order. - - parameter func: reference that returns `ICommand`. + - parameter func: reference that returns ICommand. */ func (self *MacroCommand) AddSubCommand(commandFunc func() interfaces.ICommand) { self.SubCommands = append(self.SubCommands, commandFunc) } -/** - Execute this `MacroCommand`'s *SubCommands*. +/* + Execute this MacroCommand's SubCommands. - The *SubCommands* will be called in First In/First Out (FIFO) + The SubCommands will be called in First In/First Out (FIFO) order. - - parameter notification: the `INotification` object to be passsed to each *SubCommand*. + - parameter notification: the INotification object to be passsed to each SubCommand. */ func (self *MacroCommand) Execute(notification interfaces.INotification) { self.InitializeMacroCommand() diff --git a/src/patterns/command/SimpleCommand.go b/src/patterns/command/SimpleCommand.go index bb20712..5a39901 100755 --- a/src/patterns/command/SimpleCommand.go +++ b/src/patterns/command/SimpleCommand.go @@ -13,25 +13,25 @@ import ( "github.com/puremvc/puremvc-go-multicore-framework/src/patterns/facade" ) -/** -A base `ICommand` implementation. +/* +A base ICommand implementation. -Your subclass should override the `execute` -method where your business logic will handle the `INotification`. +Your subclass should override the execute +method where your business logic will handle the INotification. */ type SimpleCommand struct { facade.Notifier } -/** - Fulfill the use-case initiated by the given `INotification`. +/* + Fulfill the use-case initiated by the given INotification. In the Command Pattern, an application use-case typically - begins with some user action, which results in an `INotification` being broadcast, which - is handled by business logic in the `execute` method of an - `ICommand`. + begins with some user action, which results in an INotification being broadcast, which + is handled by business logic in the execute method of an + ICommand. - - parameter notification: the `INotification` to handle. + - parameter notification: the INotification to handle. */ func (self *SimpleCommand) Execute(notification interfaces.INotification) { diff --git a/src/patterns/facade/Facade.go b/src/patterns/facade/Facade.go index dfd560b..442d9dc 100755 --- a/src/patterns/facade/Facade.go +++ b/src/patterns/facade/Facade.go @@ -17,8 +17,8 @@ import ( "sync" ) -/** -A base Multiton `IFacade` implementation. +/* +A base Multiton IFacade implementation. */ type Facade struct { Key string // The Multiton Key @@ -30,12 +30,14 @@ type Facade struct { var instanceMap = map[string]interfaces.IFacade{} // The Multiton Facade instanceMap. var instanceMapMutex = sync.RWMutex{} // instanceMapMutex for the instance -/** +/* Facade Multiton Factory method - parameter key: multitonKey - - parameter facadeFunc: reference that returns `IFacade` - - returns: the Multiton instance of the `IFacade` + + - parameter facadeFunc: reference that returns IFacade + + - returns: the Multiton instance of the IFacade */ func GetInstance(key string, facadeFunc func() interfaces.IFacade) interfaces.IFacade { instanceMapMutex.Lock() @@ -48,12 +50,12 @@ func GetInstance(key string, facadeFunc func() interfaces.IFacade) interfaces.IF return instanceMap[key] } -/** - Initialize the Multiton `Facade` instance. +/* + Initialize the Multiton Facade instance. Called automatically by the GetInstance. Override in your subclass to do any subclass specific initializations. Be - sure to call `self.Facade.initializeFacade()`, though. + sure to call self.Facade.initializeFacade(), though. */ func (self *Facade) InitializeFacade() { self.InitializeModel() @@ -61,197 +63,210 @@ func (self *Facade) InitializeFacade() { self.InitializeView() } -/** - Initialize the `Controller`. +/* + Initialize the Controller. - Called by the `initializeFacade` method. - Override this method in your subclass of `Facade` + Called by the initializeFacade method. + Override this method in your subclass of Facade if one or both of the following are true: - * You wish to initialize a different `IController`. - * You have `Commands` to register with the `Controller` at startup.`. + * You wish to initialize a different IController. - If you don't want to initialize a different `IController`, - call `self.Facade.initializeController()` at the beginning of your - method, then register `Command`s. + * You have Commands to register with the Controller at startup. + + If you don't want to initialize a different IController, + call self.Facade.initializeController() at the beginning of your + method, then register Commands. */ func (self *Facade) InitializeController() { self.controller = controller.GetInstance(self.Key, func() interfaces.IController { return &controller.Controller{Key: self.Key} }) } -/** - Initialize the `Model`. +/* + Initialize the Model. - Called by the `initializeFacade` method. - Override this method in your subclass of `Facade` + Called by the initializeFacade method. + Override this method in your subclass of Facade if one or both of the following are true: - * You wish to initialize a different `IModel`. - * You have `Proxy`s to register with the Model that do not retrieve a reference to the Facade at construction time.` + * You wish to initialize a different IModel. + + * You have Proxys to register with the Model that do not retrieve a reference to the Facade at construction time. - If you don't want to initialize a different `IModel`, - call `self.Facade.initializeModel()` at the beginning of your - method, then register `Proxy`s. + If you don't want to initialize a different IModel, + call self.Facade.initializeModel() at the beginning of your + method, then register Proxys. - Note: This method is *rarely* overridden; in practice you are more - likely to use a `Command` to create and register `Proxy`s - with the `Model`, since `Proxy`s with mutable data will likely - need to send `INotification`s and thus will likely want to fetch a reference to - the `Facade` during their construction. + Note: This method is rarely overridden; in practice you are more + likely to use a Command to create and register Proxys + with the Model, since Proxys with mutable data will likely + need to send INotifications and thus will likely want to fetch a reference to + the Facade during their construction. */ func (self *Facade) InitializeModel() { self.model = model.GetInstance(self.Key, func() interfaces.IModel { return &model.Model{Key: self.Key} }) } -/** - Initialize the `View`. +/* + Initialize the View. - Called by the `initializeFacade` method. - Override this method in your subclass of `Facade` + Called by the initializeFacade method. + Override this method in your subclass of Facade if one or both of the following are true: - * You wish to initialize a different `IView`. - * You have `Observers` to register with the `View` + * You wish to initialize a different IView. - If you don't want to initialize a different `IView`, - call `self.Facade.initializeView()` at the beginning of your - method, then register `IMediator` instances. + * You have Observers to register with the View - Note: This method is *rarely* overridden; in practice you are more - likely to use a `Command` to create and register `Mediator`s - with the `View`, since `IMediator` instances will need to send - `INotification`s and thus will likely want to fetch a reference - to the `Facade` during their construction. + If you don't want to initialize a different IView, + call self.Facade.initializeView() at the beginning of your + method, then register IMediator instances. + + Note: This method is rarely overridden; in practice you are more + likely to use a Command to create and register Mediators + with the View, since IMediator instances will need to send + INotifications and thus will likely want to fetch a reference + to the Facade during their construction. */ func (self *Facade) InitializeView() { self.view = view.GetInstance(self.Key, func() interfaces.IView { return &view.View{Key: self.Key} }) } -/** - Register an `ICommand` with the `Controller` by Notification name. +/* + Register an ICommand with the Controller by Notification name. + + - parameter notificationName: the name of the INotification to associate the ICommand with - - parameter notificationName: the name of the `INotification` to associate the `ICommand` with - - parameter commandFunc: reference that returns `ICommand` + - parameter commandFunc: reference that returns ICommand */ func (self *Facade) RegisterCommand(notificationName string, commandFunc func() interfaces.ICommand) { self.controller.RegisterCommand(notificationName, commandFunc) } -/** - Remove a previously registered `ICommand` to `INotification` mapping from the Controller. +/* + Remove a previously registered ICommand to INotification mapping from the Controller. - - parameter notificationName: the name of the `INotification` to remove the `ICommand` mapping for + - parameter notificationName: the name of the INotification to remove the ICommand mapping for */ func (self *Facade) RemoveCommand(notificationName string) { self.controller.RemoveCommand(notificationName) } -/** +/* Check if a Command is registered for a given Notification - parameter notificationName: - - returns: whether a Command is currently registered for the given `notificationName`. + + - returns: whether a Command is currently registered for the given notificationName. */ func (self *Facade) HasCommand(notificationName string) bool { return self.controller.HasCommand(notificationName) } -/** - Register an `IProxy` with the `Model` by name. +/* + Register an IProxy with the Model by name. - - parameter proxy: the `IProxy` instance to be registered with the `Model`. + - parameter proxy: the IProxy instance to be registered with the Model. */ func (self *Facade) RegisterProxy(proxy interfaces.IProxy) { self.model.RegisterProxy(proxy) } -/** - Retrieve an `IProxy` from the `Model` by name. +/* + Retrieve an IProxy from the Model by name. - parameter proxyName: the name of the proxy to be retrieved. - - returns: the `IProxy` instance previously registered with the given `proxyName`. + + - returns: the IProxy instance previously registered with the given proxyName. */ func (self *Facade) RetrieveProxy(proxyName string) interfaces.IProxy { return self.model.RetrieveProxy(proxyName) } -/** - Remove an `IProxy` from the `Model` by name. +/* + Remove an IProxy from the Model by name. - - parameter proxyName: the `IProxy` to remove from the `Model`. - - returns: the `IProxy` that was removed from the `Model` + - parameter proxyName: the IProxy to remove from the Model. + + - returns: the IProxy that was removed from the Model */ func (self *Facade) RemoveProxy(proxyName string) interfaces.IProxy { return self.model.RemoveProxy(proxyName) } -/** +/* Check if a Proxy is registered - parameter proxyName: - - returns: whether a Proxy is currently registered with the given `proxyName`. + + - returns: whether a Proxy is currently registered with the given proxyName. */ func (self *Facade) HasProxy(proxyName string) bool { return self.model.HasProxy(proxyName) } -/** - Register a `IMediator` with the `View`. +/* + Register a IMediator with the View. - - parameter mediator: a reference to the `IMediator` + - parameter mediator: a reference to the IMediator */ func (self *Facade) RegisterMediator(mediator interfaces.IMediator) { self.view.RegisterMediator(mediator) } -/** - Retrieve an `IMediator` from the `View`. +/* + Retrieve an IMediator from the View. - parameter mediatorName: - - returns: the `IMediator` previously registered with the given `mediatorName`. + + - returns: the IMediator previously registered with the given mediatorName. */ func (self *Facade) RetrieveMediator(mediatorName string) interfaces.IMediator { return self.view.RetrieveMediator(mediatorName) } -/** - Remove an `IMediator` from the `View`. +/* + Remove an IMediator from the View. + + - parameter mediatorName: name of the IMediator to be removed. - - parameter mediatorName: name of the `IMediator` to be removed. - - returns: the `IMediator` that was removed from the `View` + - returns: the IMediator that was removed from the View */ func (self *Facade) RemoveMediator(mediatorName string) interfaces.IMediator { return self.view.RemoveMediator(mediatorName) } -/** +/* Check if a Mediator is registered or not - parameter mediatorName: - - returns: whether a Mediator is registered with the given `mediatorName`. + + - returns: whether a Mediator is registered with the given mediatorName. */ func (self *Facade) HasMediator(mediatorName string) bool { return self.view.HasMediator(mediatorName) } -/** - Create and send an `INotification`. +/* + Create and send an INotification. Keeps us from having to construct new notification instances in our implementation code. - parameter notificationName: the name of the notiification to send + - parameter body: the body of the notification (optional) - - parameter _type: the type of the notification (optional) + + - parameter _type: the type of the notification */ func (self *Facade) SendNotification(notificationName string, body interface{}, _type string) { self.NotifyObservers(observer.NewNotification(notificationName, body, _type)) } -/** - Notify `Observer`s. +/* + Notify Observers. - This method is left public mostly for backward + This method is left mostly for backward compatibility, and to allow you to send custom notification classes using the facade. @@ -259,29 +274,28 @@ func (self *Facade) SendNotification(notificationName string, body interface{}, and pass the parameters, never having to construct the notification yourself. - - parameter notification: the `INotification` to have the `View` notify `Observers` of. + - parameter notification: the INotification to have the View notify Observers of. */ func (self *Facade) NotifyObservers(notification interfaces.INotification) { self.view.NotifyObservers(notification) } -/** +/* Set the Multiton key for this facade instance. Not called directly, but instead from the - constructor when getInstance is invoked. - It is necessary to be public in order to - implement INotifier. + GetInstance when it is is invoked. */ func (self *Facade) InitializeNotifier(key string) { self.Key = key } -/** +/* Check if a Core is registered or not - parameter key: the multiton key for the Core in question - - returns: whether a Core is registered with the given `key`. + + - returns: whether a Core is registered with the given key. */ func HasCore(key string) bool { instanceMapMutex.RLock() @@ -290,7 +304,7 @@ func HasCore(key string) bool { return instanceMap[key] != nil } -/** +/* Remove a Core. Remove the Model, View, Controller and Facade diff --git a/src/patterns/facade/Notifier.go b/src/patterns/facade/Notifier.go index 1a2502a..d686c15 100755 --- a/src/patterns/facade/Notifier.go +++ b/src/patterns/facade/Notifier.go @@ -10,21 +10,21 @@ package facade import "github.com/puremvc/puremvc-go-multicore-framework/src/interfaces" -/** -A Base `INotifier` implementation. +/* +A Base INotifier implementation. -`MacroCommand, Command, Mediator` and `Proxy` -all have a need to send `Notifications`. +MacroCommand, Command, Mediator and Proxy +all have a need to send Notifications. -The `INotifier` interface provides a common method called -`sendNotification` that relieves implementation code of -the necessity to actually construct `Notifications`. +The INotifier interface provides a common method called +sendNotification that relieves implementation code of +the necessity to actually construct Notifications. -The `Notifier` class, which all of the above mentioned classes -extend, provides an initialized reference to the `Facade` +The Notifier class, which all of the above mentioned classes +extend, provides an initialized reference to the Facade Multiton, which is required for the convienience method -for sending `Notifications`, but also eases implementation as these -classes have frequent `Facade` interactions and usually require +for sending Notifications, but also eases implementation as these +classes have frequent Facade interactions and usually require access to the facade anyway. NOTE: In the MultiCore version of the framework, there is one caveat to @@ -32,8 +32,11 @@ notifiers, they cannot send notifications or reach the facade until they have a valid multitonKey. The multitonKey is set: + * on a Command when it is executed by the Controller + * on a Mediator is registered with the View + * on a Proxy is registered with the Model. */ type Notifier struct { @@ -41,21 +44,23 @@ type Notifier struct { Key string // The Multiton Key for this app } -/** - Create and send an `INotification`. +/* + Create and send an INotification. Keeps us from having to construct new INotification instances in our implementation code. - parameter notificationName: the name of the notification to send + - parameter body: the body of the notification (optional) - - parameter type: the _type of the notification (optional) + + - parameter type: the _type of the notification */ func (self *Notifier) SendNotification(notificationName string, body interface{}, _type string) { self.Facade.SendNotification(notificationName, body, _type) } -/** +/* Initialize this INotifier instance. This is how a Notifier gets its multitonKey. diff --git a/src/patterns/mediator/Mediator.go b/src/patterns/mediator/Mediator.go index 6765fc6..c0464a8 100755 --- a/src/patterns/mediator/Mediator.go +++ b/src/patterns/mediator/Mediator.go @@ -15,8 +15,8 @@ import ( const NAME = "Mediator" // default name for the mediator -/** - A base `IMediator` implementation. +/* +A base IMediator implementation. */ type Mediator struct { facade.Notifier @@ -24,50 +24,56 @@ type Mediator struct { ViewComponent interface{} // The view component } -// Get the name of the `Mediator`. +/* + Get the name of the Mediator. +*/ func (self *Mediator) GetMediatorName() string { return self.Name } -// Get the `IMediator`'s view component. +/* + Get the IMediator's view component. +*/ func (self *Mediator) GetViewComponent() interface{} { return self.ViewComponent } -// Set the `IMediator`'s view component. +/* + Set the IMediator's view component. +*/ func (self *Mediator) SetViewComponent(viewComponent interface{}) { self.ViewComponent = viewComponent } -/** - List the `INotification` names this - `Mediator` is interested in being notified of. +/* + List the INotification names this + Mediator is interested in being notified of. - - returns: Array the list of `INotification` names + - returns: Array the list of INotification names */ func (self *Mediator) ListNotificationInterests() []string { return []string{} } -/** - Handle `INotification`s. +/* + Handle INotifications. Typically this will be handled in a switch statement, - with one 'case' entry per `INotification` - the `Mediator` is interested in. + with one 'case' entry per INotification + the Mediator is interested in. */ func (self *Mediator) HandleNotification(notification interfaces.INotification) { } -/** +/* Called by the View when the Mediator is registered */ func (self *Mediator) OnRegister() { } -/** +/* Called by the View when the Mediator is removed */ func (self *Mediator) OnRemove() { diff --git a/src/patterns/observer/Notification.go b/src/patterns/observer/Notification.go index 7a4f5e0..f1051ae 100755 --- a/src/patterns/observer/Notification.go +++ b/src/patterns/observer/Notification.go @@ -8,10 +8,8 @@ package observer -import "github.com/puremvc/puremvc-go-multicore-framework/src/interfaces" - -/** -A base `INotification` implementation. +/* +A base INotification implementation. PureMVC does not rely upon underlying event models such as the one provided with Flash, and ActionScript 3 does @@ -22,21 +20,21 @@ to support event-driven communication between the application and the actors of the MVC triad. Notifications are not meant to be a replacement for Events -in Flex/Flash/Apollo. Generally, `IMediator` implementors +in Flex/Flash/Apollo. Generally, IMediator implementors place event listeners on their view components, which they -then handle in the usual way. This may lead to the broadcast of `Notification`s to -trigger `ICommand`s or to communicate with other `IMediators`. `IProxy` and `ICommand` -instances communicate with each other and `IMediator`s -by broadcasting `INotification`s. +then handle in the usual way. This may lead to the broadcast of Notifications to +trigger ICommands or to communicate with other IMediators. IProxy and ICommand +instances communicate with each other and IMediators +by broadcasting INotifications. -A key difference between Flash `Event`s and PureMVC -`Notification`s is that `Event`s follow the +A key difference between Flash Events and PureMVC +Notifications is that Events follow the 'Chain of Responsibility' pattern, 'bubbling' up the display hierarchy -until some parent component handles the `Event`, while -PureMVC `Notification`s follow a 'Publish/Subscribe' +until some parent component handles the Event, while +PureMVC Notifications follow a 'Publish/Subscribe' pattern. PureMVC classes need not be related to each other in a parent/child relationship in order to communicate with one another -using `Notification`s. +using Notifications. */ type Notification struct { name string @@ -44,56 +42,58 @@ type Notification struct { _type string } -/** +/* Constructor. -- parameter name: name of the `Notification` instance. (required) -- parameter body: the `Notification` body. (optional) -- parameter type: the type of the `Notification` (optional) +- parameter name: name of the Notification instance. (required) + +- parameter body: the Notification body. (optional) + +- parameter type: the type of the Notification */ -func NewNotification(name string, body interface{}, _type string) interfaces.INotification { +func NewNotification(name string, body interface{}, _type string) *Notification { return &Notification{name: name, body: body, _type: _type} } -/** -Get the name of notification instance +/* + Get the name of notification instance */ func (self *Notification) Name() string { return self.name } -/** +/* Get the body of notification instance */ func (self *Notification) Body() interface{} { return self.body } -/** +/* Set the body of notification instance */ func (self *Notification) SetBody(body interface{}) { self.body = body } -/** +/* Get the type of notification instance */ func (self *Notification) Type() string { return self._type } -/** +/* Set the type of notification instance */ func (self *Notification) SetType(t string) { self._type = t } -/** - Get the string representation of the `Notification` instance. +/* + Get the string representation of the Notification instance. - - returns: the string representation of the `Notification` instance. + - returns: the string representation of the Notification instance. */ func (self *Notification) String() string { msg := "Notification name: " + self.name diff --git a/src/patterns/observer/Observer.go b/src/patterns/observer/Observer.go index 416d9f0..b65728e 100755 --- a/src/patterns/observer/Observer.go +++ b/src/patterns/observer/Observer.go @@ -10,18 +10,21 @@ package observer import "github.com/puremvc/puremvc-go-multicore-framework/src/interfaces" -/** -A base `IObserver` implementation. +/* +A base IObserver implementation. -An `Observer` is an object that encapsulates information +An Observer is an object that encapsulates information about an interested object with a method that should -be called when a particular `INotification` is broadcast. +be called when a particular INotification is broadcast. -In PureMVC, the `Observer` class assumes these responsibilities: +In PureMVC, the Observer class assumes these responsibilities: * Encapsulate the notification (callback) method of the interested object. + * Encapsulate the notification context (this) of the interested object. + * Provide methods for setting the notification method and context. + * Provide a method for notifying the interested object. */ type Observer struct { @@ -29,33 +32,34 @@ type Observer struct { Context interface{} } -/** +/* Notify the interested object. - - parameter notification: the `INotification` to pass to the interested object's notification method. + - parameter notification: the INotification to pass to the interested object's notification method. */ func (self *Observer) NotifyObserver(notification interfaces.INotification) { self.Notify(notification) } -/** +/* Compare an object to the notification context. - parameter object: the object to compare - returns: boolean indicating if the object and the notification context are the same + */ func (self *Observer) CompareNotifyContext(object interface{}) bool { return object == self.Context } -/** +/* Set the notification method. */ func (self *Observer) SetNotifyMethod(notifyMethod func(notification interfaces.INotification)) { self.Notify = notifyMethod } -/** +/* Set the notification context. */ func (self *Observer) SetNotifyContext(notifyContext interface{}) { diff --git a/src/patterns/proxy/Proxy.go b/src/patterns/proxy/Proxy.go index 31315bd..82ded5d 100755 --- a/src/patterns/proxy/Proxy.go +++ b/src/patterns/proxy/Proxy.go @@ -12,21 +12,21 @@ import "github.com/puremvc/puremvc-go-multicore-framework/src/patterns/facade" const NAME = "Proxy" // default name for the proxy -/** -A base `IProxy` implementation. +/* +A base IProxy implementation. -In PureMVC, `Proxy` classes are used to manage parts of the +In PureMVC, Proxy classes are used to manage parts of the application's data model. -A `Proxy` might simply manage a reference to a local data object, +A Proxy might simply manage a reference to a local data object, in which case interacting with it might involve setting and getting of its data in synchronous fashion. -`Proxy` classes are also used to encapsulate the application's +Proxy classes are also used to encapsulate the application's interaction with remote services to save or retrieve data, in which case, we adopt an asyncronous idiom; setting data (or calling a method) on the -`Proxy` and listening for a `Notification` to be sent -when the `Proxy` has retrieved the data from the service. +Proxy and listening for a Notification to be sent +when the Proxy has retrieved the data from the service. */ type Proxy struct { facade.Notifier @@ -34,35 +34,35 @@ type Proxy struct { Data interface{} // the data object } -/** +/* Get the proxy name */ func (self *Proxy) GetProxyName() string { return self.Name } -/** +/* Set the data object */ func (self *Proxy) SetData(data interface{}) { self.Data = data } -/** +/* Get the data object */ func (self *Proxy) GetData() interface{} { return self.Data } -/** +/* Called by the Model when the Proxy is registered */ func (self *Proxy) OnRegister() { } -/** +/* Called by the Model when the Proxy is removed */ func (self *Proxy) OnRemove() { diff --git a/test/core/controller/ControllerTestCommand.go b/test/core/controller/ControllerTestCommand.go index 9c1794c..57759c9 100755 --- a/test/core/controller/ControllerTestCommand.go +++ b/test/core/controller/ControllerTestCommand.go @@ -13,14 +13,14 @@ import ( "github.com/puremvc/puremvc-go-multicore-framework/src/patterns/command" ) -/** +/* A SimpleCommand subclass used by ControllerTest. */ type ControllerTestCommand struct { command.SimpleCommand } -/** +/* Fabricate a result by multiplying the input by 2 - parameter note: the note carrying the ControllerTestVO diff --git a/test/core/controller/ControllerTestCommand2.go b/test/core/controller/ControllerTestCommand2.go index 035b6b9..31e3de2 100755 --- a/test/core/controller/ControllerTestCommand2.go +++ b/test/core/controller/ControllerTestCommand2.go @@ -13,14 +13,14 @@ import ( "github.com/puremvc/puremvc-go-multicore-framework/src/patterns/command" ) -/** +/* A SimpleCommand subclass used by ControllerTest. */ type ControllerTestCommand2 struct { command.SimpleCommand } -/** +/* Fabricate a result by multiplying the input by 2 and adding to the existing result This tests accumulation effect that would show if the command were executed more than once. diff --git a/test/core/controller/ControllerTestVO.go b/test/core/controller/ControllerTestVO.go index d64cf99..3e892a0 100755 --- a/test/core/controller/ControllerTestVO.go +++ b/test/core/controller/ControllerTestVO.go @@ -8,7 +8,7 @@ package controller -/** +/* A utility class used by ControllerTest. */ type ControllerTestVO struct { diff --git a/test/core/controller/Controller_test.go b/test/core/controller/Controller_test.go index afb48f8..9488cc8 100755 --- a/test/core/controller/Controller_test.go +++ b/test/core/controller/Controller_test.go @@ -16,11 +16,11 @@ import ( "testing" ) -/** +/* Test the PureMVC Controller class. */ -/** +/* Tests the Controller Multiton Factory Method */ func TestGetInstance(t *testing.T) { @@ -31,7 +31,7 @@ func TestGetInstance(t *testing.T) { } } -/** +/* Tests Command registration and execution. This test gets a Multiton Controller instance @@ -64,7 +64,7 @@ func TestRegisterAndExecuteCommand(t *testing.T) { } } -/** +/* Tests Command registration and removal. Tests that once a Command is registered and verified @@ -106,7 +106,7 @@ func TestRegisterAndRemoveCommand(t *testing.T) { } } -/** +/* Test hasCommand method. */ func TestHasCommand(t *testing.T) { @@ -128,7 +128,7 @@ func TestHasCommand(t *testing.T) { } } -/** +/* Tests Removing and Reregistering a Command Tests that when a Command is re-registered that it isn't fired twice. diff --git a/test/core/model/Model_test.go b/test/core/model/Model_test.go index e7ddcf9..25f4bac 100755 --- a/test/core/model/Model_test.go +++ b/test/core/model/Model_test.go @@ -15,7 +15,7 @@ import ( "testing" ) -/** +/* Test the PureMVC Model class. */ @@ -29,10 +29,10 @@ func TestGetInstance(t *testing.T) { } } -/** +/* Tests the proxy registration and retrieval methods. - Tests `registerProxy` and `retrieveProxy` in the same test. + Tests registerProxy and retrieveProxy in the same test. These methods cannot currently be tested separately in any meaningful way other than to show that the methods do not throw exception when called. @@ -62,7 +62,7 @@ func TestRegisterAndRetrieveProxy(t *testing.T) { } } -/** +/* Tests the proxy removal method. */ func TestRegisterAndRemoveProxy(t *testing.T) { @@ -88,7 +88,7 @@ func TestRegisterAndRemoveProxy(t *testing.T) { } } -/** +/* Tests the hasProxy Method */ func TestHasProxy(t *testing.T) { @@ -113,7 +113,7 @@ func TestHasProxy(t *testing.T) { } } -/** +/* Tests that the Model calls the onRegister and onRemove methods */ func TestOnRegisterAndOnRemove(t *testing.T) { diff --git a/test/core/view/ObserverTest.go b/test/core/view/ObserverTest.go index 0e5ed74..d2e2dd3 100755 --- a/test/core/view/ObserverTest.go +++ b/test/core/view/ObserverTest.go @@ -10,9 +10,9 @@ package view import "github.com/puremvc/puremvc-go-multicore-framework/src/interfaces" -/** - A test variable that proves the viewTestMethod was - invoked by the View. +/* +A test variable that proves the viewTestMethod was +invoked by the View. */ var ViewTestVar int diff --git a/test/core/view/ViewTestMediator.go b/test/core/view/ViewTestMediator.go index 226b2c4..71b5699 100755 --- a/test/core/view/ViewTestMediator.go +++ b/test/core/view/ViewTestMediator.go @@ -12,7 +12,7 @@ import "github.com/puremvc/puremvc-go-multicore-framework/src/patterns/mediator" const ViewTestMediator_NAME = "ViewTestMediator" -/** +/* A Mediator class used by ViewTest. */ type ViewTestMediator struct { diff --git a/test/core/view/ViewTestMediator2.go b/test/core/view/ViewTestMediator2.go index 307ea86..ec3927d 100755 --- a/test/core/view/ViewTestMediator2.go +++ b/test/core/view/ViewTestMediator2.go @@ -15,7 +15,7 @@ import ( const ViewTestMediator2_NAME = "viewTestMediator2" -/** +/* A Mediator class used by ViewTest. */ type ViewTestMediator2 struct { diff --git a/test/core/view/ViewTestMediator3.go b/test/core/view/ViewTestMediator3.go index 4d8992f..d227482 100755 --- a/test/core/view/ViewTestMediator3.go +++ b/test/core/view/ViewTestMediator3.go @@ -15,7 +15,7 @@ import ( const ViewTestMediator3_NAME = "viewTestMediator3" -/** +/* A Mediator class used by ViewTest. */ type ViewTestMediator3 struct { diff --git a/test/core/view/ViewTestMediator4.go b/test/core/view/ViewTestMediator4.go index ec98032..c3c8a9b 100755 --- a/test/core/view/ViewTestMediator4.go +++ b/test/core/view/ViewTestMediator4.go @@ -12,7 +12,7 @@ import "github.com/puremvc/puremvc-go-multicore-framework/src/patterns/mediator" const ViewTestMediator4_NAME = "ViewTestMediator4" -/** +/* A Mediator class used by ViewTest. */ type ViewTestMediator4 struct { diff --git a/test/core/view/ViewTestMediator5.go b/test/core/view/ViewTestMediator5.go index 6a791bd..a6cec26 100755 --- a/test/core/view/ViewTestMediator5.go +++ b/test/core/view/ViewTestMediator5.go @@ -15,7 +15,7 @@ import ( const ViewTestMediator5_NAME = "viewTestMediator5" -/** +/* A Mediator class used by ViewTest. */ type ViewTestMediator5 struct { diff --git a/test/core/view/ViewTestMediator6.go b/test/core/view/ViewTestMediator6.go index 5dd2186..94c31aa 100755 --- a/test/core/view/ViewTestMediator6.go +++ b/test/core/view/ViewTestMediator6.go @@ -15,7 +15,7 @@ import ( const ViewTestMediator6_NAME = "ViewTestMediator6" // The Mediator base name -/** +/* A Mediator class used by ViewTest. */ type ViewTestMediator6 struct { diff --git a/test/core/view/View_test.go b/test/core/view/View_test.go index eaff5e0..2e4331b 100755 --- a/test/core/view/View_test.go +++ b/test/core/view/View_test.go @@ -16,11 +16,11 @@ import ( "testing" ) -/** +/* Test the PureMVC View class. */ -/** +/* Tests the View Multiton Factory Method */ func TestGetInstance(t *testing.T) { @@ -33,7 +33,7 @@ func TestGetInstance(t *testing.T) { } } -/** +/* Tests registration and notification of Observers. An Observer is created to callback the viewTestMethod of @@ -78,7 +78,7 @@ func TestRegisterAndNotifyObserver(t *testing.T) { } } -/** +/* Tests registering and retrieving a mediator with the View. */ @@ -99,7 +99,7 @@ func TestRegisterAndRetrieveMediator(t *testing.T) { } } -/** +/* Tests the hasMediator Method */ func TestHasMediator(t *testing.T) { @@ -125,7 +125,7 @@ func TestHasMediator(t *testing.T) { } } -/** +/* Tests registering and removing a mediator */ func TestRegisterAndRemoveMediator(t *testing.T) { @@ -150,7 +150,7 @@ func TestRegisterAndRemoveMediator(t *testing.T) { } } -/** +/* Tests that the View callse the onRegister and onRemove methods */ func TestOnRegisterAndOnRemove(t *testing.T) { @@ -176,7 +176,7 @@ func TestOnRegisterAndOnRemove(t *testing.T) { } } -/** +/* Tests successive regster and remove of same mediator. */ func TestSuccessiveRegisterAndRemoveMediator(t *testing.T) { @@ -222,7 +222,7 @@ func TestSuccessiveRegisterAndRemoveMediator(t *testing.T) { } } -/** +/* Tests registering a Mediator for 2 different notifications, removing the Mediator from the View, and seeing that neither notification causes the Mediator to be notified. @@ -270,7 +270,7 @@ func TestRemoveMediatorAndSubsequentNotify(t *testing.T) { } } -/** +/* Tests registering one of two registered Mediators and seeing that the remaining one still responds. */ @@ -329,7 +329,7 @@ func TestRemoveOneOfTwoMediatorsAndSubsequentNotify(t *testing.T) { } } -/** +/* Tests registering the same mediator twice. A subsequent notification should only illicit one response. Also, since reregistration @@ -370,7 +370,7 @@ func TestMediatorReregistration(t *testing.T) { } } -/** +/* Tests the ability for the observer list to be modified during the process of notification, diff --git a/test/patterns/command/MacroCommandTestCommand.go b/test/patterns/command/MacroCommandTestCommand.go index 6db4819..3d068a9 100755 --- a/test/patterns/command/MacroCommandTestCommand.go +++ b/test/patterns/command/MacroCommandTestCommand.go @@ -13,14 +13,14 @@ import ( "github.com/puremvc/puremvc-go-multicore-framework/src/patterns/command" ) -/** +/* A MacroCommand subclass used by MacroCommandTest. */ type MacroCommandTestCommand struct { command.MacroCommand } -/** +/* Initialize the MacroCommandTestCommand by adding its 2 SubCommands. */ diff --git a/test/patterns/command/MacroCommandTestSub1Command.go b/test/patterns/command/MacroCommandTestSub1Command.go index 9a11fd8..45f4722 100755 --- a/test/patterns/command/MacroCommandTestSub1Command.go +++ b/test/patterns/command/MacroCommandTestSub1Command.go @@ -17,10 +17,10 @@ type MacroCommandTestSub1Command struct { command.MacroCommand } -/** +/* Fabricate a result by multiplying the input by 2 - - parameter event: the `IEvent` carrying the `MacroCommandTestVO` + - parameter event: the IEvent carrying the MacroCommandTestVO */ func (command *MacroCommandTestSub1Command) Execute(notification interfaces.INotification) { var vo = notification.Body().(*MacroCommandTestVO) diff --git a/test/patterns/command/MacroCommandTestSub2Command.go b/test/patterns/command/MacroCommandTestSub2Command.go index 33088fa..b9ca773 100755 --- a/test/patterns/command/MacroCommandTestSub2Command.go +++ b/test/patterns/command/MacroCommandTestSub2Command.go @@ -17,10 +17,10 @@ type MacroCommandTestSub2Command struct { command.MacroCommand } -/** +/* Fabricate a result by multiplying the input by itself - - parameter event: the `IEvent` carrying the `MacroCommandTestVO` + - parameter event: the IEvent carrying the MacroCommandTestVO */ func (command *MacroCommandTestSub2Command) Execute(notification interfaces.INotification) { var vo = notification.Body().(*MacroCommandTestVO) diff --git a/test/patterns/command/MacroCommandTestVO.go b/test/patterns/command/MacroCommandTestVO.go index 0ad5cab..edb7d80 100755 --- a/test/patterns/command/MacroCommandTestVO.go +++ b/test/patterns/command/MacroCommandTestVO.go @@ -8,7 +8,7 @@ package command -/** +/* A utility class used by MacroCommandTest. */ type MacroCommandTestVO struct { diff --git a/test/patterns/command/MacroCommand_test.go b/test/patterns/command/MacroCommand_test.go index 1c51e49..ced3f95 100755 --- a/test/patterns/command/MacroCommand_test.go +++ b/test/patterns/command/MacroCommand_test.go @@ -17,32 +17,32 @@ import ( "testing" ) -/** - Tests operation of a `MacroCommand`. +/* +Tests operation of a MacroCommand. - This test creates a new `Notification`, adding a - `MacroCommandTestVO` as the body. - It then creates a `MacroCommandTestCommand` and invokes - its `execute` method, passing in the - `Notification`. +This test creates a new Notification, adding a +MacroCommandTestVO as the body. +It then creates a MacroCommandTestCommand and invokes +its execute method, passing in the +Notification. - The `MacroCommandTestCommand` has defined an - `initializeMacroCommand` method, which is - called automatically by its constructor. In this method - the `MacroCommandTestCommand` adds 2 SubCommands - to itself, `MacroCommandTestSub1Command` and - `MacroCommandTestSub2Command`. +The MacroCommandTestCommand has defined an +initializeMacroCommand method, which is +called automatically by its constructor. In this method +the MacroCommandTestCommand adds 2 SubCommands +to itself, MacroCommandTestSub1Command and +MacroCommandTestSub2Command. - The `MacroCommandTestVO` has 2 result properties, - one is set by `MacroCommandTestSub1Command` by - multiplying the input property by 2, and the other is set - by `MacroCommandTestSub2Command` by multiplying - the input property by itself. +The MacroCommandTestVO has 2 result properties, +one is set by MacroCommandTestSub1Command by +multiplying the input property by 2, and the other is set +by MacroCommandTestSub2Command by multiplying +the input property by itself. - Success is determined by evaluating the 2 result properties - on the `MacroCommandTestVO` that was passed to - the `MacroCommandTestCommand` on the Notification - body. +Success is determined by evaluating the 2 result properties +on the MacroCommandTestVO that was passed to +the MacroCommandTestCommand on the Notification +body. */ func TestMacroCommandExecute(t *testing.T) { // Create the VO @@ -67,7 +67,7 @@ func TestMacroCommandExecute(t *testing.T) { } } -/** +/* Testing MacroCommand via Controller and notify via View */ func TestMacroCommandExecuteViaControllerView(t *testing.T) { diff --git a/test/patterns/command/SimpleCommandTestCommand.go b/test/patterns/command/SimpleCommandTestCommand.go index c1e4efe..44ecacc 100755 --- a/test/patterns/command/SimpleCommandTestCommand.go +++ b/test/patterns/command/SimpleCommandTestCommand.go @@ -10,16 +10,16 @@ package command import "github.com/puremvc/puremvc-go-multicore-framework/src/interfaces" -/** +/* A SimpleCommand subclass used by SimpleCommandTest. */ type SimpleCommandTestCommand struct { } -/** +/* Fabricate a result by multiplying the input by 2 - - parameter event: the `INotification` carrying the `SimpleCommandTestVO` + - parameter event: the INotification carrying the SimpleCommandTestVO */ func (command SimpleCommandTestCommand) execute(notification interfaces.INotification) { var vo = notification.Body().(*SimpleCommandTestVO) diff --git a/test/patterns/command/SimpleCommandTestVO.go b/test/patterns/command/SimpleCommandTestVO.go index 03525c8..efeb6d1 100755 --- a/test/patterns/command/SimpleCommandTestVO.go +++ b/test/patterns/command/SimpleCommandTestVO.go @@ -8,7 +8,7 @@ package command -/** +/* A utility class used by SimpleCommandTest. */ type SimpleCommandTestVO struct { diff --git a/test/patterns/command/SimpleCommand_test.go b/test/patterns/command/SimpleCommand_test.go index cb32135..735bd3d 100755 --- a/test/patterns/command/SimpleCommand_test.go +++ b/test/patterns/command/SimpleCommand_test.go @@ -13,17 +13,17 @@ import ( "testing" ) -/** +/* Test the PureMVC SimpleCommand class. */ -/** - Tests the `execute` method of a `SimpleCommand`. +/* + Tests the execute method of a SimpleCommand. - This test creates a new `Notification`, adding a - `SimpleCommandTestVO` as the body. - It then creates a `SimpleCommandTestCommand` and invokes - its `execute` method, passing in the note. + This test creates a new Notification, adding a + SimpleCommandTestVO as the body. + It then creates a SimpleCommandTestCommand and invokes + its execute method, passing in the note. Success is determined by evaluating a property on the object that was passed on the Notification body, which will diff --git a/test/patterns/facade/FacadeTestCommand.go b/test/patterns/facade/FacadeTestCommand.go index f3f4713..32fb125 100755 --- a/test/patterns/facade/FacadeTestCommand.go +++ b/test/patterns/facade/FacadeTestCommand.go @@ -13,14 +13,14 @@ import ( "github.com/puremvc/puremvc-go-multicore-framework/src/patterns/command" ) -/** +/* A SimpleCommand subclass used by FacadeTest. */ type FacadeTestCommand struct { command.SimpleCommand } -/** +/* Fabricate a result by multiplying the input by 2 - parameter note: the Notification carrying the FacadeTestVO diff --git a/test/patterns/facade/FacadeTestVO.go b/test/patterns/facade/FacadeTestVO.go index 6a7cde8..a41f6f4 100755 --- a/test/patterns/facade/FacadeTestVO.go +++ b/test/patterns/facade/FacadeTestVO.go @@ -8,7 +8,7 @@ package facade -/** +/* A utility class used by FacadeTest. */ type FacadeTestVO struct { diff --git a/test/patterns/facade/Facade_test.go b/test/patterns/facade/Facade_test.go index 8c364b1..08d8d81 100755 --- a/test/patterns/facade/Facade_test.go +++ b/test/patterns/facade/Facade_test.go @@ -16,7 +16,7 @@ import ( "testing" ) -/** +/* Test the PureMVC Facade class. */ @@ -30,7 +30,7 @@ func TestGetInstance(t *testing.T) { } } -/** +/* Tests Command registration and execution via the Facade. This test gets a Multiton Facade instance @@ -60,7 +60,7 @@ func TestRegisterCommandAndSendNotification(t *testing.T) { } } -/** +/* Tests Command removal via the Facade. This test gets a Multiton Facade instance @@ -91,10 +91,10 @@ func TestRegisterAndRemoveCommandAndSendNotification(t *testing.T) { } } -/** +/* Tests the regsitering and retrieving Model proxies via the Facade. - Tests `registerProxy` and `retrieveProxy` in the same test. + Tests registerProxy and retrieveProxy in the same test. These methods cannot currently be tested separately in any meaningful way other than to show that the methods do not throw exception when called. @@ -128,7 +128,7 @@ func TestRegisterAndRetrieveProxy(t *testing.T) { } } -/** +/* Tests the removing Proxies via the Facade. */ func TestRegisterAndRemoveProxy(t *testing.T) { @@ -155,7 +155,7 @@ func TestRegisterAndRemoveProxy(t *testing.T) { } } -/** +/* Tests registering, retrieving and removing Mediators via the Facade. */ func TestRegisterRetrieveAndRemoveMediator(t *testing.T) { @@ -182,7 +182,7 @@ func TestRegisterRetrieveAndRemoveMediator(t *testing.T) { } } -/** +/* Tests the hasProxy Method */ func TestHasProxy(t *testing.T) { @@ -197,7 +197,7 @@ func TestHasProxy(t *testing.T) { } } -/** +/* Tests the hasMediator Method */ func TestHasMediator(t *testing.T) { @@ -220,7 +220,7 @@ func TestHasMediator(t *testing.T) { } } -/** +/* Test hasCommand method. */ func TestHasCommand(t *testing.T) { @@ -244,7 +244,7 @@ func TestHasCommand(t *testing.T) { } } -/** +/* Tests the hasCore and removeCore methods */ func TestHasCoreAndRemoveCore(t *testing.T) { diff --git a/test/patterns/mediator/Mediator_test.go b/test/patterns/mediator/Mediator_test.go index 8c0e742..d73cd2c 100755 --- a/test/patterns/mediator/Mediator_test.go +++ b/test/patterns/mediator/Mediator_test.go @@ -14,11 +14,11 @@ import ( "testing" ) -/** +/* Test the PureMVC Mediator class. */ -/** +/* Tests getting the name using Mediator class accessor method. */ func TestNameAccessor(t *testing.T) { @@ -28,7 +28,7 @@ func TestNameAccessor(t *testing.T) { } } -/** +/* Tests getting the name using Mediator class accessor method. */ func TestViewAccessor(t *testing.T) { diff --git a/test/patterns/observer/Notification_test.go b/test/patterns/observer/Notification_test.go index c56f043..f3457d7 100755 --- a/test/patterns/observer/Notification_test.go +++ b/test/patterns/observer/Notification_test.go @@ -13,11 +13,11 @@ import ( "testing" ) -/** +/* Test the PureMVC Notification class. */ -/** +/* Tests setting and getting the name using Notification class accessor methods. */ func TestNameAccessors(t *testing.T) { @@ -27,7 +27,7 @@ func TestNameAccessors(t *testing.T) { } } -/** +/* Tests setting and getting the body using Notification class accessor methods. */ func TestBodyAccessors(t *testing.T) { @@ -56,7 +56,7 @@ func TestConstructor(t *testing.T) { } } -/** +/* Tests the toString method of the notification */ func TestToString(t *testing.T) { diff --git a/test/patterns/observer/Observer_test.go b/test/patterns/observer/Observer_test.go index 8199ee2..1f83c67 100755 --- a/test/patterns/observer/Observer_test.go +++ b/test/patterns/observer/Observer_test.go @@ -14,7 +14,7 @@ import ( "testing" ) -/** +/* Tests PureMVC Observer class. Since the Observer encapsulates the interested object's @@ -26,7 +26,7 @@ notification method and context and call the notifyObserver method. */ -/** +/* Tests observer class when initialized by accessor methods. */ func TestObserverAccessor(t *testing.T) { @@ -51,7 +51,7 @@ func TestObserverAccessor(t *testing.T) { } } -/** +/* Tests observer class when initialized by constructor. */ func TestObserverConstructor(t *testing.T) { @@ -74,7 +74,7 @@ func TestObserverConstructor(t *testing.T) { } } -/** +/* Tests the compareNotifyContext method of the Observer class */ func TestCompareNotifyContext(t *testing.T) { @@ -97,7 +97,7 @@ type Test struct { Var int } -/** +/* A function that is used as the observer notification method. It multiplies the input number by the observerTestVar value diff --git a/test/patterns/proxy/Proxy_test.go b/test/patterns/proxy/Proxy_test.go index c625ce3..3b01253 100755 --- a/test/patterns/proxy/Proxy_test.go +++ b/test/patterns/proxy/Proxy_test.go @@ -14,11 +14,11 @@ import ( "testing" ) -/** +/* Test the PureMVC Proxy class. */ -/** +/* Tests getting the name using Proxy class accessor method. Setting can only be done in constructor. */ func TestNameAccessor(t *testing.T) { @@ -31,7 +31,7 @@ func TestNameAccessor(t *testing.T) { } } -/** +/* Tests setting and getting the data using Proxy class accessor methods. */ func TestDataAccessor(t *testing.T) { @@ -56,7 +56,7 @@ func TestDataAccessor(t *testing.T) { } } -/** +/* Tests setting the name and body using the Notification class Constructor. */ func TestConstructor(t *testing.T) {