[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sdx-developers] Big brother is watching you (copyright Malo Pichot)
From: |
Pierrick Brihaye |
Subject: |
[sdx-developers] Big brother is watching you (copyright Malo Pichot) |
Date: |
Thu, 24 Jun 2004 14:29:28 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Win98; fr-FR; rv:1.6) Gecko/20040113 |
Salut,
J'essaie, tant bien que mal, de suivre vos développements. Ca s'annonce
bien :-)
Petit commentaire relatif à Utilities.java pendant qu'il est chaud :
567 public static void isObjectUnique(Context objs,
String key, Object obj) throws SDXException {
568 String l_key = key;
569 if (!Utilities.checkString(l_key) && obj !=
null && obj instanceof SdxObject) l_key = ((SdxObject) obj).getId();
570 try {
571 rpandey 1.98 Object l_obj = objs.get(l_key);
572 if (l_obj != null) {//the object with the
l_key already exists
573 String[] l_args = new String[2];
574 l_args[0] = l_obj.toString();
575 if (obj != null) l_args[0] =
obj.toString();
576 l_args[1] = l_key;
577 throw new SDXException(null,
SDXExceptionCode.ERROR_OBJECT_WITH_ID_EXISTS, l_args, null);
578 }
579 rpandey 1.89 } catch (ContextException e) {
580 rpandey 1.98 //do nothing here as the object doesn't
already exist in the context object
581 rpandey 1.89 }
582 }
Gaffe à ce genre de construction : l'interception d'une exception bouffe
énormément de performances et, IMHO, mieux vaut un gros bloc de if avant
: check early, return early...
En ce qui concerne le nommage, je m'attends à ce que isXXXX renvoie un
booléen ; j'aurais préféré checkXXX. M'enfin...
Mes 2 centimes,
--
Pierrick Brihaye, informaticien
Service régional de l'Inventaire
DRAC Bretagne
mailto:address@hidden
+33 (0)2 99 29 67 78
- [sdx-developers] Big brother is watching you (copyright Malo Pichot),
Pierrick Brihaye <=