commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory" <>
Subject RE: [codec] Binary BIT_n and BITS question.
Date Wed, 17 Mar 2004 21:25:57 GMT
> -----Original Message-----
> From: Alex Karasulu []
> Sent: Wednesday, March 17, 2004 11:24
> To: 'Jakarta Commons Developers List'
> Subject: RE: [codec] Binary BIT_n and BITS question.
> Greg,
> > (1) The public Binary.BITS field is not used from anywhere. How is
> > generally useful, it has no Javadoc? Should we get rid of it?
> I was planning on using it later when I cleaned up this class a bit.
> If you're going for a release feel free to blow it away.  I have not
> decided yet whether to leave loops unraveled and ugly or add another
> loop to cycle through this array.  I thought it might be better to
> unravel it for speed.

My POV is to *not* write code "for speed" over proper abstractions until
a proven bottleneck has been identified. In general, I do not optimize
before measuring bottlenecks. In the case of unrolling a loop, I doubt
that any measurable performance gain would up in an application. But
feel free to measure ;-)

> > (2) The public Binary.BIT_n fields are only used from Binary. Should
> > they really be public fields?
> Hmmm I think this might be best kept private but I do use them else
> in applications that depend on Binary however perhaps incorrectly.
Let me
> explain below.

I see them used from the unit tests so perhaps they can be moved to the
unit test code base.

> I think there really is not that much value to having these constants
> since people can just use hex masks on the fly.  But it's proper form
> make them into a constant no?  

I think so.

> I thought so and strive to write code
> that uses a constant every time I can regardless of data type.  The
> question is: When is too much formality too much?  Are we going to
> create 8 or 32 constants for each bit in a byte or in an integer?  Do
> you think it might be going a little overboard?  

I you do things in the XP spirit, then you'd create the constants as you
need them. In this case, the tests needs them, so we have them. Maybe
the constants are in the wrong place, I am not sure.

> The array of masks on
> the other hand might be good to have for looping over bit ranges in
> bytes and integers.
> Another concern is whether or not codec is the place for general stuff
> like this.  Personally I think the constants might be better off in a
> commons-lang class like BitField or BooleanUtils but do you want
> the dependency for such a small benefit.  

Agreed, it would perhaps be better in [lang]'s BitField but some in the
Jakarta community do not like cross-project dependencies. 

> Are these constants worth
> it to incur the dependency?  

That is a tricky issue as I stated above. My company's server ships with
a whole bunch of Jakarta jars, so I would rather see code in its proper
place, but hey, that's just me.

Then again is it ok for other commons
> projects to have a dependency on something like commons-lang which
> has no other dependency.  To me commons-lang can be a universal
> dependency and get away with it.

Agreed, but plenty of folks do not want codec to depend on anything.

> Alex
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message