Re: Question on assert

2016-09-30 Thread Mick Semb Wever
On 22 September 2016 at 03:34, Michael Kjellman < mkjell...@internalcircle.com> wrote: > They can both live in harmony and they both serve a purpose. Thanks for writing that Michael. I'm a big fan of assert statements and have over the years seen them add value and stability to projects *when*

Re: Question on assert

2016-09-22 Thread Edward Capriolo
Yes obviously we do not need to go in and replace them all at once. Some rough guidance/general consensus should be in place, because we are violating the standard usage: https://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html Do *not* use assertions for argument checking in p

Re: Question on assert

2016-09-22 Thread Benjamin Lerer
I fully agree. On Thu, Sep 22, 2016 at 11:57 AM, Dave Brosius wrote: > As an aside, C* for some reason heavily uses asserts in unit tests, which > adds to the "can't see the forest for the trees" problem. I see no reason > for that. they should all be moved over to junit asserts. > > > > On 09/2

Re: Question on assert

2016-09-22 Thread Dave Brosius
As an aside, C* for some reason heavily uses asserts in unit tests, which adds to the "can't see the forest for the trees" problem. I see no reason for that. they should all be moved over to junit asserts. On 09/22/2016 03:52 AM, Benjamin Lerer wrote: We can spend hours arguing about assert v

Re: Question on assert

2016-09-22 Thread Benjamin Lerer
We can spend hours arguing about assert vs exceptions. I have seen it happen in every company I worked for. Overall, based on the patches I have reviewed, it seems to me that in general people are using them only has internal safety checks. Unfortunatly, the code change and we can miss things. If a

Re: Question on assert

2016-09-21 Thread DuyHai Doan
I found that SO question very interesting to fuel the discussion about assert vs exception : http://stackoverflow.com/questions/1957645/when-to-use-an-assertion-and-when-to-use-an-exception On Wed, Sep 21, 2016 at 8:20 PM, Michael Kjellman < mkjell...@internalcircle.com> wrote: > Yeah, I understa

Re: Question on assert

2016-09-21 Thread Michael Kjellman
Yeah, I understand what you're saying, don't get me wrong. However, I just spent close to a year total working and writing CASSANDRA-9754 and when you're dealing with IO, sometimes asserts are the right way to go. I found putting them there are sanity checks mostly to ensure that code changes t

Re: Question on assert

2016-09-21 Thread Edward Capriolo
You are essentially arguing, "if you turn off -ea your screwed" which is a symptom of a larger problem that I am pointing out. Forget the "5%" thing. I am having a discussion about use of assert. You have: 1) checked exceptions 2) unchecked exceptions 3) Error (like ioError which we sometime have

Re: Question on assert

2016-09-21 Thread Jonathan Ellis
That sounds to me like we have some asserts that should be turned into actual exceptions. (I'm definitely not arguing that ALL our asserts are in this category.) On Wed, Sep 21, 2016 at 12:34 PM, Michael Kjellman < mkjell...@internalcircle.com> wrote: > Asserts have their place as sanity checks.

Re: Question on assert

2016-09-21 Thread Michael Kjellman
Asserts have their place as sanity checks. Just like exceptions have their place. They can both live in harmony and they both serve a purpose. What doesn't serve a purpose is that comment encouraging n00b users to get a mythical 5% performance increase and then get silent corruption when their

Re: Question on assert

2016-09-21 Thread Edward Capriolo
" potential 5% performance win when you've corrupted all their data." This is somewhat of my point. Why do assertions that sometimes are trapped "protect my data" better then a checked exception? On Wed, Sep 21, 2016 at 1:24 PM, Michael Kjellman < mkjell...@internalcircle.com> wrote: > I hate tha

Re: Question on assert

2016-09-21 Thread Michael Kjellman
I hate that comment with a passion. Please please please please do yourself a favor and *always* run with asserts on. `-ea` for life. In practice I'd be surprised if you actually got a reliable 5% performance win and I doubt your customers will care about a potential 5% performance win when you'

Question on assert

2016-09-21 Thread Edward Capriolo
There are a variety of assert usages in the Cassandra. You can find several tickets like mine. https://issues.apache.org/jira/browse/CASSANDRA-12643 https://issues.apache.org/jira/browse/CASSANDRA-11537 Just to prove that I am not the only one who runs into these: https://issues.apache.org/jira