Option Explicit

K

Keith Wilby

Warrio said:
The first message was uncompleted, I apologised and completed it!

and yes you are right after all! you are the best in the world!!! keep
going

I never made such a claim but it occurred to me after replying that you are
the orignator of the other meaningless debate "group by vs distinct".

<PLONK>
 
W

Warrio

meaningless to you maybe! I learned a lot!
you can learn as well if you open your eyes, ears, ..., mind!

Keep going ; )
 
A

Albert D. Kallal

David W. Fenton said:
You should still use Option Explicit so you don't write garbage
code.

Yup...."garbage code" sums it up!!!

For me, it never been a debate...the *first* change in setting is to ensure
option explicit...

It much like putting a seat belt on...it not because it is a local by-law,
it because is common sense.....
 
W

Warrio

Common sense can differ depending on what you want to do and on your
reasons... action = reaction (1st Newton low)
It's rather called tolitarism (only one opinion is right)

What I'm trying to say that I'm shocked to see people saying that there is
only one option that is right.

and I'm more disappointed to see an MVP treating someone's code of garbage!!

That's really great

PS: Google is also going out of law by neglecting the right to the private
life... but they do it, and thanks to them to try to change the habits based
on old rules.
if you want to follow a rule, at least try to know why they were made!

Cheers!
 
B

BruceM

Everybody makes typographical errors. That is what people mean in this
thread by "garbage". It is not a reference to the quality of your code. If
you use a variable 50 times in your code, and misspell it once, in that one
instance it will be treated as a new variable if you do not require variable
declaration. The code may run, but you won't get the expected result, and
will be left to sort through your code line by line to figure out why. If
you require variable declaration, when you compile the code you will be
asked about the undeclared (i.e. misspelled) variable. This is my choice.
If you wish to make another choice (because you have always done it that
way, or because you feel the need to rebel against common methods, or
whatever), go for it.
However, leave the "totalitarianism" (if that's what you meant by
"tolitarism") stuff out of the discussion. You can take your incoherent
rants about Google somewhere else, too. Everybody who has replied uses
Option Explicit, and has told you why. Take the advice or leave it, but you
can get off of your persecution high horse any time now.
 
W

Warrio

Thanks Bruce for correcting my English..
I became aggressive when I saw the people using Option Explicit trying to
tell me that I must or should do the same.
I've always respected their choice and all what I'm saying is that I do not
understand that they can perceive that other people can do differently.
I have my reasons, they have theirs... everybody is happy and all this
discussion shouldn't exist.
 
R

Rick Brandt

Warrio said:
Thanks Bruce for correcting my English..
I became aggressive when I saw the people using Option Explicit
trying to tell me that I must or should do the same.
I've always respected their choice and all what I'm saying is that I
do not understand that they can perceive that other people can do
differently. I have my reasons, they have theirs... everybody is happy and
all this
discussion shouldn't exist.

You initiated a discussion in a discussion group and now say the discussion
shouldn't exist. I have a solution for you. The next time you feel an urge
to post to a discussion group slam your fingers in a drawer until the urge
goes away.
 
B

BruceM

If I am ever in the position of hiring somebody by the hour to do VBA
coding, I will have to remember to ask about whether they require variable
declaration. If not, they don't get the job (at least not at an hourly
rate), since it will surely take more time that way. You are of course free
to spend your time as you choose. Best of luck.
 
W

Warrio

and only if I can add something to try to finish with this.
many people tried to give an answer to my question but everybody kept on
focusing on the fact that Option Explicit is a must.
even if it wasn't the purpose of my question, they tried to advice me about
something that I have never asked! I'm sure it comes from a good intention
to help other and it's really kind. but you can't help someone who doesn't
want the help. and this some mvps understood it well and focus and are
really accurate when they answer a question.
I tried to ignore all of that but after 5 or 6 messages of advice, I got
enough and felt like imprisoned between 4 walls... that explains the bad
reactions of me and others.

but thanks again to calm and objective point of view, and if I aggressed
anyone by my reaction to their advice, I apologize again!
 
W

Warrio

talking and unsulting is easy... but you're lucky to feel safe behind your
screen ;)

don't bring it back again! if you were capable of focusing on my question,
all this wouldn't happen, I mean that I wouldn't have to try to keep the
answer focusing on the real question. and the answer with what Albert said.

if you look for another job, let me know, I have a swiming pool that needs
to be cleaned!
 
R

Rick Brandt

Warrio wrote:
[snip drivel]
if you were capable of focusing on my
question, all this wouldn't happen, I mean that I wouldn't have to
try to keep the answer focusing on the real question. and the answer
with what Albert said.

Imagine a group dedicated to discussions of a particular classic car and
someone posted the question "What's the best way to permanently mount a set
of deer antlers to the hood?"

Would you be surprised if most responders didn't focus on the original
question, but instead told the poster that it's a terrible idea?
 
W

Warrio

you are right! you finally understood the point! it's the natural way that
people behave!

but it's not mine... even if someone (adult capable of making the difference
between bad and good things) would ask me about the best way to suicicde, I
will tell him, because of the freedom of choice: if he/she is an adult with
his/her complete brain, I suppose that he has the right to make the choice
he/she wants at the condition of taking the concequences (good and bad) of
his decision.
but anyway, not everybody thinks the same and it's normal.

it's my fault if it took so long to have an answer with many people feeling
offendend. Normaly the question that I asked are about a particular
situation that in 80% doesn't happen. and people react the same way, but I
try to tell from the begining to please do answer me this or this.

I know it's completly unconciderable to do not use Option Explicit, but my
fault was to say that I don't use it... in order to do not have the "natural
reaction", I should have say, "yes I use it, but I want to know in which way
it will run the code faster in runtime?" in that case, people won't focus on
"should or should not use Option Explicit" because I'm doing the corret
thing as it's supposed to be done.

I agree, it's my fault, if I had all these reactions... and this is the
positive thing! is that I'm learning how to talk to people in order to get
what I want... and at least I'm happy with the message and as I've said, I
appology if they got offended by my reaction.




Rick Brandt said:
Warrio wrote:
[snip drivel]
if you were capable of focusing on my
question, all this wouldn't happen, I mean that I wouldn't have to
try to keep the answer focusing on the real question. and the answer
with what Albert said.

Imagine a group dedicated to discussions of a particular classic car and
someone posted the question "What's the best way to permanently mount a
set of deer antlers to the hood?"

Would you be surprised if most responders didn't focus on the original
question, but instead told the poster that it's a terrible idea?
 
D

David W. Fenton

I said it before! you made your decision, I respect it, respect
mine!

I cannot respect your choice to not use OPTION EXPLICIT. It is the
mark of a novice programmer or of someone who is a complete idiot
(i.e., they know why it's important to use it but stupidly choose
not to).
and as someone who has some respect for himself, if you answer a
message, just answer the question asked not something else letting
your emotions talk instead of your mind!

Where have I done anything more than answer the question?

In any event, sometimes the question you think you are asking is not
the most important question. Someone answering may see that behind
your question are a number of assumptions or hidden problems that
need to be explicitly addressed in order for any answer to be
useful.

In that case, it's not really answering the question to ignore those
implicit issues.
I have my reason to write what I write and I don't need to tell
them. all what you need to know if you "care so much" about the
code I'm writing.... is that I always calculate in ROI (Return On
Investment) which tells the risk I can take and the one I cannot.

I don't give a rat's ass about the code you write. But you're pretty
clearly not very smart in choosing *not* to use OPTION EXPLICIT.
and my calculations results in not declaring..
your ROI on declaring your variables is to save time on debugging,
fine with it, I said it! I respect that and understand it.

No, you obviously don't respect it or you wouldn't go to such great
length (wich such great emotion) to claim that you do.
what I win with not declaring is :
1. if I declare them all, I can have useless variables within
my code.
and in Access the optimizer doesn't tell you that as it does in
Delphi for example.

It's not Access, but VBA that compiles. Compile-time checking is a
*good* thing, as anyone with any common sense knows.
2. I save some memory (even if it's meaningless as Albert D.
Kallal) but
with billions of lines of code, it can have a sense...
3. I save some memory in using a variable that is not
declared, so
variant for many purposes thanks to the casting
4. Sepending time on debugging is not a waste of time for me,
because I
learn how to find errors and try to minimize the time to find
it... can be useful not only in coding but in many stuff.

You can only find the errors you know to look for.
your messages telling me what I "should do"... is far away from my
original question. and if you reply to a message in a forum, you
are supposed to give some help on what people asked, not telling
them about which shirt color they should wear...

If someone asks me if they should wear a hat or not while driving
their car off a cliff I think I'd be remiss in answering only the
question they asked -- it's my duty to try to dissuade them from
driving the car off the cliff.
I asked about how can we make the code run faster with
an "Option Explicit" statement. Albert D. Kallal was the only one
with some experience of forum to answer only the question asked!
and I appreciated the quality of his answer. That's why I thanked
him.

If you don't like the answers you get, then don't pay the people
giving the answers.

Oops!

We aren't getting paid!!!

So, you just have to accept the answers you get.
Tolerance is the key word in here.

Physician! Heal thyself!
Respect the choice of others even if it
looks wrong to you,

I have no obligation to "respect" stupidity. You are not the only
person involved here -- there are thousands of potential readers of
your posts and it's important that they not pick up really bad ideas
from your stupid coding choices.
it might look right to them, you can show the difference
and the weaknesses of the other option, but Respect it!
what do you do in life? do you shout after all the people who have
another religion, political opinion,.....? no, because it would be
a the war! and that's what happen today, because people don't have
tolerance of other options! so respect other's opinions!

This is not a matter of opinion. It's a matter of objective fact --
using OPTION EXPLICIT is objectively superior to not using it.

If you choose to ignore fact, then you're obviously a really dumb
person.
 
D

David W. Fenton

What I'm trying to say that I'm shocked to see people saying that
there is only one option that is right.

If you're writing a database app, it is quite obvious that you
should have strongly-typed variables, because they data in your
database is strongly typed (i.e., each field in each table has a
strict data type).

It may be OK in a web application using vbScript or PHP to not have
strongly-typed variables, but we're talking about Access.
 
B

BruceM

How do you know the best way to commit suicide? How does anybody, for that
matter? How do you get inside a person's brain and determine that the
person is capable of knowing good from bad? Having made the determination,
you would assist the person in doing bad? You may want to find a different
forum in which to work out some of these issues.

You came into the discussion determined that you are not going to declare
variables unless there is a performance enhancement to be obtained by doing
so. If you come across me on the street, and you point to a road and ask
how to take it to a destination that I know is not on that road, or if I
know that you would be taking the long way, I will point that out. If you
tell me that you need to take that road because of another destination that
is on that road, that is a different matter. All you ever had to do was to
ask if there is a performance difference between declaring and not declaring
variables. You brought on the rest of it yourself. I think you
acknowledged that. However, you seem to expect that knowledgeable people
should forget what they know in order to tell you how to take the long way.

Warrio said:
you are right! you finally understood the point! it's the natural way that
people behave!

but it's not mine... even if someone (adult capable of making the
difference between bad and good things) would ask me about the best way to
suicicde, I will tell him, because of the freedom of choice: if he/she is
an adult with his/her complete brain, I suppose that he has the right to
make the choice he/she wants at the condition of taking the concequences
(good and bad) of his decision.
but anyway, not everybody thinks the same and it's normal.

it's my fault if it took so long to have an answer with many people
feeling offendend. Normaly the question that I asked are about a
particular situation that in 80% doesn't happen. and people react the same
way, but I try to tell from the begining to please do answer me this or
this.

I know it's completly unconciderable to do not use Option Explicit, but my
fault was to say that I don't use it... in order to do not have the
"natural reaction", I should have say, "yes I use it, but I want to know
in which way it will run the code faster in runtime?" in that case, people
won't focus on "should or should not use Option Explicit" because I'm
doing the corret thing as it's supposed to be done.

I agree, it's my fault, if I had all these reactions... and this is the
positive thing! is that I'm learning how to talk to people in order to get
what I want... and at least I'm happy with the message and as I've said, I
appology if they got offended by my reaction.




Rick Brandt said:
Warrio wrote:
[snip drivel]
if you were capable of focusing on my
question, all this wouldn't happen, I mean that I wouldn't have to
try to keep the answer focusing on the real question. and the answer
with what Albert said.

Imagine a group dedicated to discussions of a particular classic car and
someone posted the question "What's the best way to permanently mount a
set of deer antlers to the hood?"

Would you be surprised if most responders didn't focus on the original
question, but instead told the poster that it's a terrible idea?
 
W

Warrio

you've convinced me! I'm using Option Explicit every where in my code now!!
thanks for your precious advices!
 
W

Warrio

I'm using Option Explicit now!!

BruceM said:
How do you know the best way to commit suicide? How does anybody, for
that matter? How do you get inside a person's brain and determine that
the person is capable of knowing good from bad? Having made the
determination, you would assist the person in doing bad? You may want to
find a different forum in which to work out some of these issues.

You came into the discussion determined that you are not going to declare
variables unless there is a performance enhancement to be obtained by
doing so. If you come across me on the street, and you point to a road
and ask how to take it to a destination that I know is not on that road,
or if I know that you would be taking the long way, I will point that out.
If you tell me that you need to take that road because of another
destination that is on that road, that is a different matter. All you
ever had to do was to ask if there is a performance difference between
declaring and not declaring variables. You brought on the rest of it
yourself. I think you acknowledged that. However, you seem to expect
that knowledgeable people should forget what they know in order to tell
you how to take the long way.

Warrio said:
you are right! you finally understood the point! it's the natural way
that people behave!

but it's not mine... even if someone (adult capable of making the
difference between bad and good things) would ask me about the best way
to suicicde, I will tell him, because of the freedom of choice: if he/she
is an adult with his/her complete brain, I suppose that he has the right
to make the choice he/she wants at the condition of taking the
concequences (good and bad) of his decision.
but anyway, not everybody thinks the same and it's normal.

it's my fault if it took so long to have an answer with many people
feeling offendend. Normaly the question that I asked are about a
particular situation that in 80% doesn't happen. and people react the
same way, but I try to tell from the begining to please do answer me this
or this.

I know it's completly unconciderable to do not use Option Explicit, but
my fault was to say that I don't use it... in order to do not have the
"natural reaction", I should have say, "yes I use it, but I want to know
in which way it will run the code faster in runtime?" in that case,
people won't focus on "should or should not use Option Explicit" because
I'm doing the corret thing as it's supposed to be done.

I agree, it's my fault, if I had all these reactions... and this is the
positive thing! is that I'm learning how to talk to people in order to
get what I want... and at least I'm happy with the message and as I've
said, I appology if they got offended by my reaction.




Rick Brandt said:
Warrio wrote:
[snip drivel]
if you were capable of focusing on my
question, all this wouldn't happen, I mean that I wouldn't have to
try to keep the answer focusing on the real question. and the answer
with what Albert said.

Imagine a group dedicated to discussions of a particular classic car and
someone posted the question "What's the best way to permanently mount a
set of deer antlers to the hood?"

Would you be surprised if most responders didn't focus on the original
question, but instead told the poster that it's a terrible idea?
 
A

Albert D. Kallal

Warrio said:
and I'm more disappointed to see an MVP treating someone's code of
garbage!!

I was commenting on David's suggestion, not your code.

This is not personal (at least not for me).

He just stated it helps to prevent garbage code. I saw NOTHING in the that
suggestion that pointed towards YOUR code being garbage. \

It would be much the height of hypocrisy if you were to stand here and speak
of not criticising, but then go about doing exactly that.

You seem to think that suggestions here should be limited to the exact
question, and nothing beyond the question should be suggested here? This can
hardly be argued as a means to enlightenment, and learning that supposed to
go
on here. How can we really stand here and talk about having open minds when
you can't accept suggestions that are the *norm* in our industry?

As you said, it is really a matter of your needs. There no need to take any
of this personal at all. I certainly not make it personal, and I can't speak
for others who posted here.

Option explicit is a time honoured practice. it is a good thing, and the
VAST majority of developers use it. You can certainly try to make a case as
to
why you do things the way you do. However, those points you make likely will
not convince many here. You asking for the majority of software craftsman to
throw out something that they realized on for years.

It like changing oil in your car. If you don't change it tomorrow, the
engine
will not fall out, but lets at least admit it a good idea to change oil. If
you walk into a room of experienced mechanics, and tell them you don't need
to
change oil, you going to get a harsh reaction.

The same occurs for option explicit.

If you going to convince anyone of your position, then you have to make a
better case.
1. if I declare them all, I can have useless variables within my code.
and in Access the optimizer doesn't tell you that as it does in Delphi for
example.

Well, ok, but how often and how much is this a legitimate problem? It is
not
a problem that outweighs, or convinces anyone that you should not use option
explicit. so what, you have a un-used variable. It just not a big deal.

Declaring variables at the start of routine is a instant documentations as
to
how large, how complex, and what kinds of variables are to be expected in
the code that follows. Anyone who optimizes their time and wants to make
a estimate of the code they are about to read needs this information. It
would
be asking to not asking how many pages are in a book before you tart reading
it.

So, the dim's and declares at the start of routine thus provide valuable
documentation of the code that follows. And, hopefully, some of the
variables
are explained. Further, it means that all variables are defined in ONE
PLACE.
So, if I have to modify YOUR code, I can use ctrl-up arrow, and I am
transported to the top of the routine, and presto- I have a list of
variables
used. If you don't have a nice list of variables to pick from, then I can
ASSURE YOU that your suggestion that not using option explicit will results
in MORE variables being used then necessary, because you have no handily
list of
current variables for the routine! Are you actually telling me that I have
now look through ALL OF the code to see what variables are being used? That
is far worse of a problem.

So, your bullet point #1 is not a convincing reason.

Further, while there is not built in tools, the free mztools will find and
display un-used variables anyway. Further, mztools also allows you to view
what subroutines and other code CALLS YOUR EXISTING code routines your are
in. (this is invaluable). Often, while in code when the cursor is on a
function name for sub name, then I use shift-f2 to "jump" to the other
routine (sub, or function).
And, ctrl-shift-f2 un-corks you back
the way your came through the code. The free mztools will also show what
routines call the code your in. I can't tell you have valuable that is.

mztools can also insert error handling code for you also. It is near must
have, and it is free. So, the free mztools will find those un-used vars for
you

http://www.mztools.com/index.htm

The benefit of declare variables is not speed or space. And, to further
clear
my answer, those variant type variables use the same space in each case
until
they are initialized.

Anyway, the use of option explicit is much that of forcing documentation for
the
software. It like a table of contents of the following code. As a developer
you will QUICKLY realize that maintains of code is FAR MORE expensive then
that of writing code (or running code).

The other issue is hidden errors in code. If you miss type a var name, and
ship your code, you can have hidden errors in it. Option explicit resolves
these errors at compile time, and thus finds errors BEFORE you run the code.
Even if your a 1st rate debugger, it makes no sense to use human time and
cost in place of what a machine can do.
your messages telling me what I "should do"... is far away from my original
question. and if you reply to a message in a forum, you are supposed to give
some help on what people asked, not telling them about which shirt color
they should wear...


I think giving answers that don't expand beyond the actual question is
rather rude. You mean I should give you directions to get around the
mountain,
but leave out that the next corner has a cliff?

Further, we not talking about the color of your shirt, we talking about and
learning about software development. There is HUGE grand canyon here about
telling
you what color of clothes as compared to that of what seasoned software
developers do.

You mean you want to ask about what kind of knife a butcher should use to
cut pork, but not accept suggestions that the knife should be clean ad also
sharp? Gosh, you telling me that this forum is not to be become a place of
learning, and enlightenment, but the cold hard fact of dishing out answers?

Why would anyone here volunteer to become a robot answering machine?
Without a discussion and learning process, this free group would fall
apart in an instant.

You are walking into a public form for the exchange, and learning of ideas
about ms-access. The people here are not paid to do this.

If you only want to only have "yes" sir answers that don't go beyond
anything else you don't want to hear, then that is called a paid employee!
And, further, you have to tell that person you don't want to hear anything
beyond exact what you asked? (by the way, that is the exact type of
environment
that most creative people will not work under). I can't imagine trying to
work in that kind of environment! You seem to think software is like
Macdonald's. It is a very creative and engauging type of process.

By the way, I don't think you done anything wrong. However, walking into a
room and disagreeing with everyone is not some big moral wrong, but it
certainly a way to fight a up hill battle...

And, please accept my honest ad sincere apologies if anything I said was
rude, offensive, or put this whole discussion in a wrong light.

I have no beef with you, and I look forward to continued to discussions
about software, ms-access. And I will also be most happy to continue to help
and answer your questions to the best of my ability.

And, lets all have a great day. Life needs to be enjoyable! It is 7:37
am..and I am going to grab a coffie!!!...
 
W

Warrio

Thanks again for your and all other's help!

I learn from my mistakes and what I've learned here is to be relaxed
regarding people : ) and reconsider my position every time in order to get
better.

and it's my fault if I took what you have said wrong. I took it as an
offence because it came straight after some people being aggressive who were
reacting to my aggressive reaction when they were advising me (which, I
agree, I could have taken it in a better and more relaxed way). it's just
that I want to get what I want as quickly as possible. With a machine, it's
very easy. but with people it's less easier. I'll have one month of
vacations not touching one keyboard and reappreciate to talk to people and
uncertainty. And I'm also sure there is much more to learn in uncertainty
than in exact answers.



Wish you all a good day and thanks again for your and all other's help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top