Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Engineering and Architecture

Similar presentations


Presentation on theme: "Software Engineering and Architecture"— Presentation transcript:

1 Software Engineering and Architecture
Hints on Broker II Mandatory

2 Henrik Bærbak Christensen
Broker II Learning Goal Get the return object reference methods implemented getUnitAt(p), and cousins... Get the Invoker code integrated Get the MiniDraw GUI integrated in a full client Product Goal JUnit test suite that cover all broker related code System testing of a full HotCiv GUI based product! Wow!  Henrik Bærbak Christensen

3 Henrik Bærbak Christensen
Broker 2.1 TDD the Game methods that return object references. That is, write JUnit tests that implement the FRDS process AU CS Henrik Bærbak Christensen

4 Henrik Bærbak Christensen
Broker 2.1 What about Tile? AU CS Henrik Bærbak Christensen

5 Henrik Bærbak Christensen
Broker 2.2 Integrate the Invokers from last exercise, ensure that they are split into sub invokers. That is, remove the fakeit objectId code parts from last exercise, and refactor to use multi type dispatch. AU CS Henrik Bærbak Christensen

6 2.3 System Testing Gui, Client, Observer???

7 The Grand Finale System Testing.
Story: Pedersen and Findus play a game of HotCiv Disclaimer: Screenshot is a Unit Test  AU CS Henrik Bærbak Christensen

8 Henrik Bærbak Christensen
Observer so far There are two observers Both Servant and ClientProxy have one Last Iteration Make them shut up… It works well because What is the role of the Observer? To inform the GUI about state changes in the Game domain And – we had no GUI  AU CS Henrik Bærbak Christensen

9 But CivDrawing Observes Game
From the Iteration 8 exercise, the Minidraw Drawing role have to observe on Subject Game Now, CivDrawing will be notified about events in the Game, like worldChangedAt(p) AU CS Henrik Bærbak Christensen

10 Henrik Bærbak Christensen
But... So – requirements collide here  GUI can only update based on Observer events from Game FRDS.Broker insists on not making a remote observer possible because It would require a mirrored Broker Server would have to call ClientProxies of objects on the client side, which require a Requestor and ClientRequestHandler Clients would have to accept incoming method calls, that is implement Servant, Invoker, ServerRequestHandler Architecturally, scaling is difficult Server would accept clients, will never perform... AU CS Henrik Bærbak Christensen

11 Henrik Bærbak Christensen
So What? Early web server systems had the same issues and invented some ways to circumvent it Polling. Client periodically invokes server to get any state changes since last poll. Requires a separate thread with a timer; require sequence numbers on all state events... Long polling. Client invokes a method with a very long time out, which only returns once there has been a change on the server. And then makes a new long polling call indefintely. Also requires a separate thread for handling this long poll. I suggest to take a crude and implementation-wise cheap route instead... AU CS Henrik Bærbak Christensen

12 Observer on the ClientProxy
We simply implement the Subject behaviour in the GameClientProxy as usual, ala Exercise: What do we achieve by that? What do we NOT achieve? That the GUI for user A actually reflect user A’s unit movement correctly. BUT NOT THAT OF B. AU CS Henrik Bærbak Christensen

13 Henrik Bærbak Christensen
Client Manual Refresh Introducing the (ugly) refresh button In GfxConstants Update your CompositionTool so mouseUp() events on button call the Drawing role’s requestUpdate() editor.drawing().requestUpdate() AU CS Henrik Bærbak Christensen

14 Henrik Bærbak Christensen
Discussion Does this have a flavour of being tacked on? Yep! But still ‘refresh’ is quite common : Alternative: Optional Exploration Exercise Make server side observer that keeps log of state events with a incrementing sequence number (index in array may suffice) Make a client side observer that periodically poll the server to fetch a list of all stateevents since the last fetched event getEventsSinceEventWithID(47) or something like that... AU CS Henrik Bærbak Christensen

15 Chatty Interface

16 Henrik Bærbak Christensen
We pay a penalty... In the MiniDraw exercise, I advocated a crude update policy Will rebuild by query all positions for the units on them. This is 256 remote calls! AU CS Henrik Bærbak Christensen

17 Henrik Bærbak Christensen
Chatty Interface That is, the client is chatty. Networks are slow so it takes awfully long time to complete... Build Chunky Interfaces for remote calls Implement client side caching in getUnitAt(p) First call: bulk transfer all unit information, store in internal data structure (the cache), and make a timestamp Next calls: if less than N seconds since cache was populated, just return cache contents. If more than N seconds then reload from the server again. AU CS Henrik Bærbak Christensen

18 Happy Coding... Post/Mail in case if unforseen problems!!!
Conclusions Happy Coding... Post/Mail in case if unforseen problems!!!


Download ppt "Software Engineering and Architecture"

Similar presentations


Ads by Google