You should only be calling 'create' for testing purposes, so I suppose it is up to you what you send in as parameters. I did add a helper method to pad my fields with whitespace for writing to the file so that my file does not get corrupted. I also use my Value Object (Hotel Room, in my case) to set the fields and do the conversions from the String passed in. Any time you are writing, you do need to deal with the whitespace issue IMO. Some of the test classes I am using send in nulls. The only thing you should ever be writing to from your actual application is the Owner Field if you have UrlyBird. I'll guess it's Contractor ID or the like for Bodgitt and Scarper. Hope this helps in some small way...
I did add a helper method to pad my fields with whitespace for writing to the file so that my file does not get corrupted
That's what I'm think about....if a find some null inside array I'll pad with whitespace...but I have thought...maybe implements mandory field when GUI deal with bussines layer....so....I really dont know yeat....but thanks Anne
Here are my 2 cents:
- you should not provide creating a new record through your gui, like Anne said: just do it for testing purposes (to see if your create method works as expected). I used a JUnit test-case to validate if i implemented every method correctly
- booking a hotel room or a contractor will result in an update. so in my gui i have a field to let user enter the customer id. in my gui i check if it is entered + if its length equals 8 (this is a business requirement) and only allow digits. If all these gui-tests end successful, I call my method to book a room (that method is in my business interface). In this interface i check again if the customer id is valid (meaning: only digits, not null and length equals 8). If it's valid, a call to the update-method of my Data instance is invoked. If it's not valid, an IllegalArgumentException is thrown. I know (because I designed/developed the gui) that in my program this exception never will be thrown, because I do the same tests at the gui. But if you have to develop a web-application (using my business interface) and you don't have the necessary checks implemented in the html-page (and the user will be able to enter something like "no012"), the IllegalArgumentException will be thrown and you know that you have to add these checks (or catch the exception and let user re-enter the customer-id) before an update will be executed.
- in my data-class update method i also check if the data-array is valid. This means for example length of the array is number of columns in the database schema and some other checks. If the data array is valid, the actual update is executed. If it's not valid, again an IllegalArgumentException is thrown. And the same of the point above applies here again: I know that this exception is never thrown, because I designed/developed everything. But if you would create an extra method in my business service and you would pass a data array with just 3 elements in it (meaning you won't have read my javadoc very carefully), the update-method of the data array will throw IllegalArgumentException (giving you the information that array had the wrong length).
Maybe it was a bit more than just 2 cents (maybe 4 ), but I hope my explanation was helpful.