Hi Emmanuel,

Great thoughts ! Thanks.

>> I wonder if using a specifig field for each of those flags would not be 
>> better ?
I agree. EncodingOption is a dirty work and mixes too many aspects. We should 
divide them. It's good to have specific field for each of the aspects as you 
listed, marked as 'private', and providing 'public' get methods to them, and in 
codes we use the methods instead of those fields. In some future we can 
optimize these fields out using a bit vector or an int to flag them.

>> What about having a decoartor for each type of encoding ?
I agree. If we're going to support BER and DER both well or new schemes, then 
we need such. It won't introduce API change for the types and is only for 
internal encoding/decoding implementation, right ?
Could you have a simple illustration or example, say how to do that for the 
simple Asn1Boolean type ? Thanks.

Regards,
Kai

-----Original Message-----
From: Emmanuel Lécharny [mailto:[email protected]] 
Sent: Sunday, February 01, 2015 9:49 PM
To: Apache Directory Developers List
Subject: [Kerby] Q about EncodingOption

Hi !

just looking at the EncodingOption enum, and I wonder if there is not a mixture 
of things in it.

Typically, we have some encoding type like BER/CER/DER, mixed with other 
unrelated values (CONSTRUCTED/PRIMITIVE/IMPLICIT/EXPLICIT).

I understand that it's used to gather multiple flags into one enum, but
- it's not clear from a programmer POV
- you can't tranlate that easily without adding many explicit methods in the 
enum (isConstructed(), etc...)

I wonder if using a specifig field for each of those flags would not be better ?

Something like :

public abstract class AbstractAsn1Type<T> implements Asn1Type {
    private boolean pc    // Primitive/constructed
    private boolean lengthType;  // Definite/Undefinite
    private EncodingType encoding;     // BER/CER/DER/XER/PER
    ...

Going farther, we do the encoding/decoding in the ASN1 type instances.
That's ok, but as soon as we have to deal with various type of encoding
(BER/CER...) this cipple the code with if/else/then. What about having a 
decoartor for each type of encoding ?

thoughts ?

Reply via email to