Hi Eugene, Gosling, Amit, Cindy,
First, I have to apologize. I have egg on my face. In reviewing my FBN code, it does not exactly conform to the diagram above in that I removed the code that registered a View listener with the Model.
In the classroom project that we did, Sun had used the Observer/Observable pattern (but not the interface or class) to allow the Model to immediately notify all Views of state changes. I really thought this was cool, and wanted to do this, but was discouraged by some wise JavaRanch participants, as the specs definitely state that this is not necessary.
If I had implemented FBN exactly per Sun's example of MVC, I could then explain that the manner taught by Sun of enabling communication between the View and Model when implementing the MVC pattern architecturally is thus:
1. When the View is instantiated, it is passed a reference to Model, which it stores in an instance variable for later use. If View needs to invoke methods directly on Model, it uses this value to reach the Model.
2. When the View's constructor is executing, it uses the Model reference to invoke a viewListenerRegistration method, passing itself as an argument. The Model would store the reference in some type of Array. When later some state changed in the Model, it would invoke a method in itself that would loop through the Array and notify all listening View's of the state change, so that they could respond or not, as each View decided.
As it happens, I took out all the state-change notification logic from FBN, including the code where the View registered itself with the Model. I do still have the Model reference stored in the View.
Now, as to when my View invokes methods directly on Model. In my implementation it currently does not, but I still need the reference as this would very likely change as FBN was extended into a more full-function travel service.
In order for the data presented by View to be updated, there are two ways it can get the info. It can "pull" the data by querying the Model, or data can be "pushed" to the View by Model or Controller. If you look at the diagram again, you see the line where Model notifies the Views of a state change, and this notification might, or might not, include the new data. If it only informs View that there was a change, View will have to query Model to actually update the data it is presenting. Similarly, when Controller directs View to give a particular presentation, it might pass the data to View, or it might just tell View to show window X, and it is then up to View to get the most current data for the population of window X.
In the case of my FBN implementation, the Controller passes ("pushes") the data to the View, so View currently gets away with not having to directly query Model, but who knows in the future when FBN is extended?
Amit, I will address your question on lock/unlock and the modify/enhance issue. First, bear in mind that 2 of the 4 points I lost was on the Server, so I didn't get a perfect score in this area. Second, I would not be helping you if I tell you how to answer the essay question. But, I will tell you some of the thoughts I had on this:
1. I didn't get to write the original Data class, but I had to use what was already there, although clearly (per the specs) it is not implemented code as it is given to us for the FBN project. As such, I considered that Data was fair game to be changed, and that this was the simplest way to accomplish what was needed.
2. I didn't think the client should have mode-specific code after startup. It shouldn't care about which mode it is in, but always do the usual actions of lock/read/update/unlock.
3. The lock and unlock methods aren't actually empty, they are just implemented elsewhere, in my case, in LockManager. There's got to be some workaround here, because the specs tell you to only allow the locking client to unlock a record, but the method signature does not allow the passing of any client identifier. Some people have selected to modify the signature, but I liked the elegance of combining the ConnectionFactory concept with the need to identify the client uniquely for lock/unlock.
Also, I didn't defend my GUI. I've been developing GUIs for 12+ years, and I thought my FBN GUI was pretty slick. It was intuitive for the user, asthetic, and efficient to use, so I figured that if the examiner couldn't see all that, I hadn't really accomplished what I consider to be the main point of a GUI: to allow a user to easily and comfortably be in communication with the computer, and enjoy the tasks he needs to perform.
Hope that helps. I didn't understand anything at all about ConnectionFactory or LockManager until a few weeks ago, but there was a lot of help to be had on the Developers Cert forum. (And I always checked on the score of those giving advice - I like to listen to the ones who demonstrably know their stuff.)
Cindy, I believe Gosling has already addressed your questions regarding the unlock issue. I agree with his assessment.
Good luck everybody. It was really fun doing this assignment, and I took Peter's advice and really wrung from it all the learning that I could. Before I did this, I knew Java syntax, but I didn't really feel that I knew how to build a system. Now I now how to approach this, and I have much more confidence in my level of expertise. The other thing I really learned was how to learn how to use the various classes provided in the JSDK. I must have spent 3/4 of my time studying the Platform API Spec online. There really are a lot of very interesting classes and interfaces of which we can make use.
All for now,
Debra
SCJD