napoleao / java-simple-serial-connector

Automatically exported from code.google.com/p/java-simple-serial-connector
0 stars 0 forks source link

throw exception instead of return-type boolean #28

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have a problem with the current release (v0.9.0) of jSSC. 

When I write bytes to the serial port, the method writeBytes(byte[]) returns 
false. This happens very undeterministic (1 of 5 times).

Due to the contract of the method writeBytes(byte[]) I can not identify the 
exact problem. 

The return-type boolean is bad design in this case. I think it is better to 
communicate an error via an checked exception (SerialPortException). The 
advantage is, that the exception can give much more information about the cause 
of the problem.

Also see: 
http://stackoverflow.com/questions/2156033/returning-boolean-instead-of-declarin
g-a-void-type-in-java

There are much more methods with this design problem. I think this should be 
changed in the whole API.

Original issue reported on code.google.com by android....@gmail.com on 2 Jan 2013 at 12:28