Kaspar Thommen

Greenhorn
+ Follow
since Dec 22, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kaspar Thommen

Originally posted by Niels de Feijter:

You mentioned you used the the Eclipse auto formatter with some manual improvements. Did you define the auto format template yourself or did you use one of the build in templates (e.g. Java Conventions [build-in]).



I used a slightly customized version of the official Java conventions. Frankly, I don't really remember all changes, but it's not much. I think some switch-case indenting, some line wrapping and similar stuff

Regards
Kaspar
17 years ago

Originally posted by liao test:
1. Do you remove the unit test code (using JUnit) when you submit the project? I ask this question because SUN is saying that you can't use 3rd party code.



Yes, JUnit code was removed. A good advice is to kept all JUnit test code in a separate source folder anyway.


2. Client side has to reference/use the business objects. How does it know what business classes the server side have? I assume that you design the business objects on the server side first. And then? the client side keeps a copy of source code of these classes?



The only business class I have is HotelRoom which represents a record in the database that will eventually be displayed in the JTable.

The client knows about this class because it is started with the same JAR file as the server.


3. How do you populate the "hotel room" and "hotel location" JComboBox on the GUI? Do you search certain field in the DB to get uniques rooms and locations?



I do not have any JComboBoxes in my GUI, please read my original post again and the reply I gave on January 21.

Oops - I just saw that my reply from January 21 is wrong - I meant JCheckBox instead of JComboBox. Sorry...

Regards
Kaspar
[ January 26, 2007: Message edited by: Kaspar Thommen ]
17 years ago

Originally posted by Frank Lu:
may I ask you what kind of Search Mechanism did you use for the project? Thanks



For each of the two possible search terms "hotel room" and "hotel location" I used a JTextField and an associated JComboBox [Edit: I meant JCheckBox here]. If the combo box [Edit: should be check box] is enabled, the corresponding text field is enabled and will be taken into account for searching, otherwise it won't.

The GUI then calls the search() method in the service layer with the two search terms. If a search term is disabled as described above, a null value is sent to the search() method.

The search() method of the service layer performs its task in two steps. Step one is to call the find() method in the database to get all records where hotel name and hotel location *start* with the given criteria. Then, the search results are filtered to only let through records where hotel name and location *exactly* match the search criteria.

Note that I did not use any form of caching anywhere.

Regards
Kaspar
[ January 26, 2007: Message edited by: Kaspar Thommen ]
17 years ago

Originally posted by Frank Lu:
may I ask you what kind of Search Mechanism did you use for the project? Thanks



For each of the two possible search terms "hotel room" and "hotel location" I used a JTextField and an associated JComboBox. If the combo box is enabled, the corresponding text field is enabled and will be taken into account for searching, otherwise it won't.

The GUI then calls the search() method in the service layer with the two search terms. If a search term is disabled as described above, a null value is sent to the search() method.

The search() method of the service layer performs its task in two steps. Step one is to call the find() method in the database to get all records where hotel name and hotel location *start* with the given criteria. Then, the search results are filtered to only let through records where hotel name and location *exactly* match the search criteria.

Note that I did not use any form of caching anywhere.

Regards
Kaspar
17 years ago

Originally posted by Mark Smyth:
May I ask how long did it take to get your results from the moment you took the essay exam?



About four weeks. However, Prometric seems to have screwed things up a bit as their site tells that I'm now "Sun certified developer for Java web services" I wrote them but I didn't get a reply yet. I'm wondering if I get the web services certificate for free now
17 years ago

Originally posted by Mark Smyth:
May I ask how long did it take to get your results from the moment you took the essay exam?



About four weeks. However, Prometric seems to have screwed things up a bit as their site tells that I'm now "Sun certified developer for Java web services" I wrote them but I didn't get a reply yet. I'm wondering if I get the web services certificate for free now
17 years ago
Hello

I have received my SCJD certification results and got 400 out of 400 points! I guess in this case I don't have to give you the split-up for the individual topics (GUI, Networking, ...)

At first I believed that it was a mistake, but after an e-Mail confirmation from Prometric it seems I really achieved the high-score ;o) As some of you might be interested in my design choices, I will give a brief overview over my assignment here.

But first things first: I would like to thank all people for the interesting and helpful discussions on javaranch.com, that helped me a lot for my assignment! The most helpful information came from Ken Krebs and his thread about his very good score (https://coderanch.com/t/184523/java-developer-SCJD/certification/NX-Notes-design-passed&p=). I have followed many of his advices during my assignment.

Summary
- Assignment: URLyBird 1.3.3
- Implementation: Java 5.0
- Networking: RMI (I didn't even bother to look into Sockets as RMI is so simple...)
- 22 Java source files (means 22 + a few (anonymous) inner classes)
- 107 kBytes of Java source code in total, including comments
- 4 kBytes for userguide.txt
- 5 kBytes for choices.txt
- 5 sub-packages inside "suncertify" package
- IDE: Eclipse 3.1

Architecture
As Ken, I chose a 3-tier design:
- GUI layer
- Service layer
- Backend layer with DB and locking
This makes it easy to switch between standalone and networked mode by simply changing the service layer from a local to a remote (RMI) version.

I have used logging extensively, mostly method entry/exit plus at some relevant branching points. Logging just went to the console. I applied test-driven development which I really love and thus used JUnit for automated testing. This was a real time saver and gave me confidence about the application, because the total development time was about one year because I was quite busy in my job. Being able to quickly re-run all tests after a few weeks of pausing and seeing the green bar in Eclipse really gives a good feeling )

The build process was based on an Ant script that performed compilation, unit testing, Javadoc generation and final JAR packaging. Also a big time saver.

Application Startup
A main application class handles the startup parameters. It first builds the service layer, which means that it either constructs a local service layer for standalone mode or tries to get the published RMI version from the RMI registry for networking mode). Then, the GUI is built using the service layer. Note that the service layer is responsible for starting the backend layer because it's its only user.

If something goes wrong during GUI construction, a simple error message (no stack trace!) is printed on the console and the application terminates. Stack traces and the like are, however, logged. As soon as the GUI is visible, further problems also result in user-friendly error messages, but are displayed in dialogs.

GUI Layer
My GUI is really simple. There's one "Edit" menu with an "Exit" item only. The table is quite basic too, with no sorting, no icons, no smart column width stuff. The "Smoking" column is, however, displayed as nice checkboxes.

I did not use icons anywhere, just plain text labels whose texts are simply hardcoded in the source file. Everything is held together by a few BorderLayouts and GridBagLayouts. Most GUI widgets have an informative tooltip text attached. Still, I provided an external userguide.txt file.

Note that contrarily to the classic model-view-controller (MVC) approach, I did not use a dedicated data model or a dedicated controller class. There is, however, a TableModel behind the JTable that holds list of HotelRooms. The HotelRoom class is a nice OO abstraction of a record in the database. Controller functionality is implemented as a set of anonymous inner ActionListeners that are attached to the relevant GUI elements (JButtons, JCheckBoxes etc.). They call methods in the service layer and may update the table model (if a search was triggered).

Note that I did not use the observer pattern, as there is no such thing as a data model that could fire events. Data is basically sucked out of the service layer and pushed into the table model by the ActionListeners.

Also note that there is only a GUI for the client-side of the application. The network server runs without a GUI, except for configuration. After the server configuration is done, the configuration window closes and the server runs in the console window. This is sufficient as the only possible operation on the network server is stopping it. This can be done by pressing CTRL-C, thus just terminating the JVM.

I have underestimated the configuration GUIs. It was quite a bit of work to handle the three different application modes and the corresponding configuration GUI elements and their validation.

Service Layer
I followed Ken's advices pretty closely here, so please consult the "Networking" and "General" paragraph the link I gave above.

Locking
Same here, have a look at "Locking" in Ken's description. I did, however, use classic synchronization (using the synchronized keyword) instead of using Lock objects as Ken did.

Database
Again, I pretty much followed Ken here, so have a look at his "Persistence" section.

General
- I used Eclipse's auto-formatter for formatting. Sometimes this doesn't look nice and manual correction would have been an improvement, but I was too lazy ) But apparently you can get the full score by using auto-formatters.
- 48 hour booking hour rule was ignored and justified in choices.txt.
- The DBMain interface specifies for the create method that a new record is created in the database, "possibly reusing a deleted entry". For simplicity, I decided not to reuse deleted entries, but instead always append records to the end of the database file. This makes things much simpler. Make sure you also put such decisions in the choices.txt file.
- The database schema (field lengths etc.) are hardcoded in my source code because the schema is not going to change. That's at least how I justified it
- The update and delete methods specified by DBMain were correctly implemented in the Data class. However, no GUI controls for this functionality are provided, except for booking which eventually calls update.

I hope that this information is of any use for some of you. Please feel free to ask further questions.

Regards
Kaspar
17 years ago
Hello

I have received my SCJD certification results and got 400 out of 400 points! I guess in this case I don't have to give you the split-up for the individual topics (GUI, Networking, ...)

At first I believed that it was a mistake, but after an e-Mail confirmation from Prometric it seems I really achieved the high-score ;o) As some of you might be interested in my design choices, I will give a brief overview over my assignment here.

But first things first: I would like to thank all people for the interesting and helpful discussions on javaranch.com, that helped me a lot for my assignment! The most helpful information came from Ken Krebs and his thread about his very good score (https://coderanch.com/t/184523/java-developer-SCJD/certification/NX-Notes-design-passed&p=). I have followed many of his advices during my assignment.

Summary
- Assignment: URLyBird 1.3.3
- Implementation: Java 5.0
- Networking: RMI (I didn't even bother to look into Sockets as RMI is so simple...)
- 22 Java source files (means 22 + a few (anonymous) inner classes)
- 107 kBytes of Java source code in total, including comments
- 4 kBytes for userguide.txt
- 5 kBytes for choices.txt
- 5 sub-packages inside "suncertify" package
- IDE: Eclipse 3.1

Architecture
As Ken, I chose a 3-tier design:
- GUI layer
- Service layer
- Backend layer with DB and locking
This makes it easy to switch between standalone and networked mode by simply changing the service layer from a local to a remote (RMI) version.

I have used logging extensively, mostly method entry/exit plus at some relevant branching points. Logging just went to the console. I applied test-driven development which I really love and thus used JUnit for automated testing. This was a real time saver and gave me confidence about the application, because the total development time was about one year because I was quite busy in my job. Being able to quickly re-run all tests after a few weeks of pausing and seeing the green bar in Eclipse really gives a good feeling )

The build process was based on an Ant script that performed compilation, unit testing, Javadoc generation and final JAR packaging. Also a big time saver.

Application Startup
A main application class handles the startup parameters. It first builds the service layer, which means that it either constructs a local service layer for standalone mode or tries to get the published RMI version from the RMI registry for networking mode). Then, the GUI is built using the service layer. Note that the service layer is responsible for starting the backend layer because it's its only user.

If something goes wrong during GUI construction, a simple error message (no stack trace!) is printed on the console and the application terminates. Stack traces and the like are, however, logged. As soon as the GUI is visible, further problems also result in user-friendly error messages, but are displayed in dialogs.

GUI Layer
My GUI is really simple. There's one "Edit" menu with an "Exit" item only. The table is quite basic too, with no sorting, no icons, no smart column width stuff. The "Smoking" column is, however, displayed as nice checkboxes.

I did not use icons anywhere, just plain text labels whose texts are simply hardcoded in the source file. Everything is held together by a few BorderLayouts and GridBagLayouts. Most GUI widgets have an informative tooltip text attached. Still, I provided an external userguide.txt file.

Note that contrarily to the classic model-view-controller (MVC) approach, I did not use a dedicated data model or a dedicated controller class. There is, however, a TableModel behind the JTable that holds list of HotelRooms. The HotelRoom class is a nice OO abstraction of a record in the database. Controller functionality is implemented as a set of anonymous inner ActionListeners that are attached to the relevant GUI elements (JButtons, JCheckBoxes etc.). They call methods in the service layer and may update the table model (if a search was triggered).

Note that I did not use the observer pattern, as there is no such thing as a data model that could fire events. Data is basically sucked out of the service layer and pushed into the table model by the ActionListeners.

Also note that there is only a GUI for the client-side of the application. The network server runs without a GUI, except for configuration. After the server configuration is done, the configuration window closes and the server runs in the console window. This is sufficient as the only possible operation on the network server is stopping it. This can be done by pressing CTRL-C, thus just terminating the JVM.

I have underestimated the configuration GUIs. It was quite a bit of work to handle the three different application modes and the corresponding configuration GUI elements and their validation.

Service Layer
I followed Ken's advices pretty closely here, so please consult the "Networking" and "General" paragraph the link I gave above.

Locking
Same here, have a look at "Locking" in Ken's description. I did, however, use classic synchronization (using the synchronized keyword) instead of using Lock objects as Ken did.

Database
Again, I pretty much followed Ken here, so have a look at his "Persistence" section.

General
- I used Eclipse's auto-formatter for formatting. Sometimes this doesn't look nice and manual correction would have been an improvement, but I was too lazy ) But apparently you can get the full score by using auto-formatters.
- 48 hour booking hour rule was ignored and justified in choices.txt.
- The DBMain interface specifies for the create method that a new record is created in the database, "possibly reusing a deleted entry". For simplicity, I decided not to reuse deleted entries, but instead always append records to the end of the database file. This makes things much simpler. Make sure you also put such decisions in the choices.txt file.
- The database schema (field lengths etc.) are hardcoded in my source code because the schema is not going to change. That's at least how I justified it
- The update and delete methods specified by DBMain were correctly implemented in the Data class. However, no GUI controls for this functionality are provided, except for booking which eventually calls update.

I hope that this information is of any use for some of you. Please feel free to ask further questions.

Regards
Kaspar
17 years ago
Hi Mustafa

Can you tell us a bit about your locking strategy?

Kaspar
17 years ago
Hi Guys

I have some general questions regarding the URLyBird 1.3.3 assignment:

1. What's the point of the "date" field if it's in the past (e.g. 2004)? Do I simply ignore them in the booking or should I allow booking of available rooms which are in the past (which wouldn't make sense for a real-world application)?

2. What about the 48h rule? I this must be followed strictly, it means that the application cannot be tested unless the current date is really within 48h of the free room date.

3. As far as I can tell by reading Sun's requirements, the CSRs want to search for records and possibly book some of them. Now if a room gets booked, what happens afterwards? Shall it automatically get unbooked after one day? Shall the CSR be able to unbook it manually? The specs don't say anything about this - but when I don't implement any unbooking functionality, the database will get gradually filled up (i.e. records get booked) until the database is full and the application cannot be used anymore as no more bookable rooms are avialable anymore. Not very useful for a real-world application.

Best regards

Kaspar
Hi Elena

I recently had the same problem as you have now, and I guess I will have it again when I start working on my URLyBird assignment.

I solved it like this: The Exceptions caught by the Controller are delegated to the View by method of the sort "view.showErrorMessage(String message, String title)".

The problem with this approach is, however, that there is strong coupling between the Controller and the View because the Controller must know about the View (i.e. contain a reference to it) in order to call this method. This strong coupling makes it hard to change the View and reuse the Controller. Luckily, the solution is quite simple: I made the View implement an interface called ErrorMessageDisplayer declaring the showErrorMessage(...) method and let the Controller contain a reference to the interface only. Therefore, the coupling is reduced to the Controller having to know the ErrorMessageDisplayer interface only.

Kaspar