java - Class with long name -


name of exception class in java must have exception suffix describe throwing situation. have 2 exception classes in primary external storage in android:

/**  * thrown when application tries access primary external storage , not  * available write.this depends on status of storage, example media  * not mounted,bad mounted, or ... .  */ public class primaryexternalstorageisnotreadytowriteexception extends exception { ... }  /**  * thrown when application tries write on directory  * of primary external storage needs  * {@link manifest.permission#write_external_storage} permission  * permission has not granted application.  */ public class writetoprimaryexternalstoragepermisionexception extends runtimeexception { ... } 

as see, names long, can not remove exception or primaryexternalstorage names. not want use securityexception or other existing exceptions because general. know long names not forbidden using , reminding them hard. thing can think creating package name primaryexternalstorageexceptions , change names isnotreadytowriteexception , writepermisionexception. way? , there better way avoid long names?

if using primaryexternalstorage pretty in program, seems ok introduce (and document) abbreviation pes , use pesisnotreadytowriteexception, writetopespermissionexception (or pesisnotreadytowriteexception, writetopespermissionexception depending on policy of using abbreviations in camelcased identifiers).

note is in first exception redundant. see, example, jdk exceptions arrayindexoutofboundsexception not arrayindexisoutofboundsexception.

another thing comes in mind make exceptions more general primaryexternalstoragenotreadyexception (not ready anything, not write) , primaryexternalstoragepermissionexception (actual missing permission write or read may passed exception parameter).


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -