Re: CString
- From: "Sgt. York" <york@xxxxxxxxxxxxxx>
- Date: Fri, 16 Jun 2006 14:13:13 -0700
My customers don't give a hoot in hell who forgot to initialize a variable --- if the software comes from me, it's my problem. From a puritan standpoint with a bottomless pit of time and reliable testers to back you up, it might make sense to "pass the buck" as you describe here. But in the ruthlessly time-constrained world of commercial software of the type I write, I opt to program defensively. I have been doing it successfully for many years.
Ajay Kalra wrote:
I actually fail to see the logic in this. If this was an issue, you.
should expect a well tested library to take care of it. You are dealing
with something which has been used by millions of users.
What you are doing is called "Defensive Programming". You dont actually
want to do this in normal unreleased version of the product. If this
was an issue, you want the product to crash so that it can be fixed in
the library. Its not really a performance issue but more of a style
thing. And Defensive Programming is not good for majority of
development cycles.
---
Ajay
r norman wrote:I have learned that is also best never to make any assumptions about
the state of an object even one exposed through a library that I
created!
There is virtually no place where ensuring the safety of your code by
ensuring that all objects are properly initialized degrades the
execution of your code unless the execution time is already terribly
degraded by improper design.
On Fri, 16 Jun 2006 12:29:10 -0700, "Sgt. York" <york@xxxxxxxxxxxxxx>
wrote:
As a general rule of thumb, I never make any assumptions about the state
of an object when it's created, especially one exposed through a
3rd-party library I have no control over. Maybe this comes from working
in the cross-platform realm all these years. In any case, I would call
Empty(), or set the string explicitly, always, before assuming anything.
An extra function call's worth of performance degradation is worth the
certain knowledge of an object's state.
-York
Tom Serface wrote:Hi Ajay,
I'm not arguing that point. In this case, Empty() just does nothing if the
string is already empty so if you want to the string to be empty and you
don't know whether or not it is, it's safe to call the function. I agree,
in general, that it makes sense to only call functions that are needed for
performance sake.
Tom
"Ajay Kalra" <ajaykalra@xxxxxxxxx> wrote in message
news:1150462950.449106.158370@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Frankly, I don't think it hurts anything, but it doesn't help either.It also does not hurt to call some other function which does nothing.
It may not hurt today but it may start hurting some other time because
code underneath you got changed or performance of calling Empty
deteriorates. IMO, if you dont need a function call, dont call it.
---
Ajay
- Follow-Ups:
- Re: CString
- From: Ajay Kalra
- Re: CString
- References:
- CString
- From: Steve Russell
- Re: CString
- From: Doug Harrison [MVP]
- Re: CString
- From: Steve Russell
- Re: CString
- From: Ajay Kalra
- Re: CString
- From: Tom Serface
- Re: CString
- From: Ajay Kalra
- Re: CString
- From: Tom Serface
- Re: CString
- From: Sgt. York
- Re: CString
- From: r norman
- Re: CString
- From: Ajay Kalra
- CString
- Prev by Date: ActiveX Ctrl problem
- Next by Date: Re: 415 errors?
- Previous by thread: Re: CString
- Next by thread: Re: CString
- Index(es):
Relevant Pages
|