What should be the preferred way by programmers:
1) Only Write:
SomeBoolean = True
2) Read but write only if necessary
If Not SomeBoolean Then SomeBoolean = True
What should be the preferred way by programmers:
1) Only Write:
SomeBoolean = True
2) Read but write only if necessary
If Not SomeBoolean Then SomeBoolean = True
Assuming you are referring to a RUNTIME context and a shared variable:
In a multiprocessor environment, unnecessary writes can lead to performance degradation: cache flush, synchronization overhead etc.
So YES it can make a difference... get profiling if the situation lends itself to it.
The difference is negligible. You will see performance differences when reading and writing files to the drive, but program performance is measured in big O. Read:
Especially in VB you will not see a difference.
It's really hard to know the answer to this without knowing more about the environment. It seems a reasonable check would be to run some performance tests by iterating over this task many, many times.
Empirical evidence sometimes is surprising compared to what you'd expect.
1) will be maybe a few nanoseconds faster. I suspect that compared to other things going on in your code, that difference is nanoscopic.
On the other hand, I usually write (2) if I might want to do something else when I know that I'm actually changing the boolean. That gives me a place to do it.