473,414 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

I'm very disturbed! Sherlock H. HELP


Within the following construction
switch (expression)
{
int i;
i = GetArgs() //return 2

case constant-expression:

if ( 2 == i )
{
//statement 1
}
else
{
//statement 2
}

break;

case constant-expression:
....
break;
}

(the switch block is nested within a try using catch
block)

I get execution of both statements!!!!. I thought I was
an experienced c++ programmer (10y+) migrating to C# but
I can't see what I'm doing wrong. If I take the code
snippet and puts it over in another project it works
fine, hence the syntax is ok. If I instead of ( 2 == i )
writes ( true ) it also works fine.

Please advise
best regards Jesper

Nov 15 '05 #1
3 1533
100
Hi John,
[You do know that posting private emails is incredibly bad netiquette
by the way, don't you? Please don't do it again.] I'm really sorry about that. I' ve never had the idea to make it private
conversation, but I did. And I brought it back to the thread by mistake. I'm
really, really sorry and I'll make sure that this will never happen again.
And based on my experience - in software companies in North America the most are not.


Pardon?

Sad, but true.

.........

I really thought it might be interesting to the others in the group. It
appears to be not. So now it looks like we are just teasing each other. You
are one of the persons, which posts I almost always read and I've found that
it is like you love to drill down the details, which in many cases are not
relevant to the question (like this one with "const ==var").
Maybe you read the source code like you read books. I don't know this and
I'll never know. But I read source code in the way I read a .... source
code.... I mean engaging my brain. It might be the reason why I don't have
problems with either.
I would suggest that the same is the case for many programmers out
there, given how rarely one sees if (2==x) outside C/C++ where it's
used to avoid bugs.
The reason is that many programmers never thought about it. And it looks
like they don't read books named "Writing solid code". The prefered titles
are "Learning *something* in 24 hours". Or they think "Why should I read a
book where the examples are in c++ if I'm a Java programmer.
Why not? If my code is primarily going to be read by people who have
English as their first language ???????????
(my colleagues, for a start) then why
should I not make the code as readable as possible for them? Like it or not, I *do* think in English, where your way of expressing a
comparison is unnatural. I like it frankly. I think that many problems could be solved if we speek
and think one language. English or not, it doesn't really matter. Back to
the reality, we (non English) don't think in english, though.
You claim it doesn't hurt the readability. I *know* it does, for me. Yes, I can see, for you it does.
In that case I suggest you go back to C/C++ with the "freedom" of
memory leaks etc. Frankly I think you'll find you're in the minority if
you believe that the lax if(...) compiler rules in C/C++ are a benefit.
It is strange that you bring up the qestion of the memory leaks. Reading the
groups for .NET I have seen so many post about memory leaks in the
framework. That many I've never seen in any c++ group. Believe me or not I
have never had problems with memory leaks.
In .NET and Java, I think, lot of objects stay in the managed heap
unreferenced awaiting for the GC to collect them undefined amount of time.
Some thimes they stay there until the precess ends, when eventually they get
freed. This in c++ we called memory leak. In .NET and Java it is called
managed heap.

C/C++ guys looks like more flexible that the JAVA ones. I'm not afraid to
learn and work in any other language. And I'd love to go back to c++ some
time. Even I cen do some Java programs. Why not...
Way to make a post unreadable... you do realise that anyone trying to
follow this who *hasn't* read our previous two emails is now utterly
confused by now, don't you?
I already made my appologies to you. Now I would like to apologize to the
others.
Even if there is 0.01% chance anybody to use them I don't want to take it
and I'll insist the member of the team to use such a "tricks". So you'll prevent someone from writing code they (and other team
members) might find more readable, just because it might just, some
day, create one bug? That's really bad team leadership, IMO - you'll be
creating more bugs just by making them have to do more mental
translation when writing and reading the code. "Mental translation" - sounds so complicated for so easy thing.
Let's just hope I never have to work with you... I'd like to work with you. I feel like you can hardly work with
*non-english*, but we can find a way around this, I believe.
but comparing one boolean with the value of a method is pretty rare
too, in my code Sounds senseless to me.
I'm not saying I never use cut-and-paste. I'm saying I try to use it as
little as possible. Being able to cut and paste between different
languages is almost entirely unimportant for me, and whenever I *do*
cut and paste I have enough sense to check what I'm doing - because
cutting and pasting without examining the code afterwards is going to
cause far more bugs than using if (i==5).

Cut and paste between languages? *hmmm* I've never thought about that. Does
anybody do that?
for (int i=0; i < 10; i++) NULL;
Is clear enough. Too many comments hurts readability as well. Obvious things don't have to be commented.


In that case reduce it to:

for (int i=0; i < 10; i++) {}

Maybe clear..., but ugly. I would prefer to stick with the 3-more-letters
one.

B\rgds
100
Nov 15 '05 #2
100

"Jon Skeet" <sk***@pobox.com> wrote in message
news:MP************************@news.microsoft.com ...
100 <10*@100.com> wrote:
> And based on my experience - in software companies in North America the > most are not.

Pardon? Sad, but true.


I meant pardon as in, please rephrase that, because currently it
doesn't make sense as a sentence.

I'll try one more time. Like it or not the most of the software companies
are situated in North America And in those companies most of the programmers
doesn't have english as a first language. And they don't think in English.
I really thought it might be interesting to the others in the group. It
appears to be not. So now it looks like we are just teasing each other. You
are one of the persons, which posts I almost always read and I've found that it is like you love to drill down the details, which in many cases are not relevant to the question (like this one with "const ==var").
Certainly. I'll pick up on just about anything :)

Try harder, Jon. I don't understand everything of your perfect anglish,
neither. I'm keep trying, though. Some times it takes me several times to
read one paragraph, but I never give up. I appreciate everything that you
say.
And the last I mean it.
Maybe you read the source code like you read books. I don't know this and I'll never know. But I read source code in the way I read a .... source
code.... I mean engaging my brain. It might be the reason why I don't have problems with either.
I engage my brain too, but I read both books and source-code at least
to a certain extent "out loud" in my head.


I would suggest that the same is the case for many programmers out
there, given how rarely one sees if (2==x) outside C/C++ where it's
used to avoid bugs.
The reason is that many programmers never thought about it.


You seem very sure of that.
And it looks like they don't read books named "Writing solid code".


Or maybe they understand why it's not an issue in Java or C#, or just
find it more readable as I do.
The prefered titles
are "Learning *something* in 24 hours". Or they think "Why should I read a
book where the examples are in c++ if I'm a Java programmer.


And where in fact it seems that at least some of the strategies
proposed aren't relevant. I'd suggest that "Effective Java" by Joshua
Bloch is a superb read for Java programmers, but certainly some of the
points made don't apply to C# (although some do).
Why not? If my code is primarily going to be read by people who have
English as their first language

???????????
Sorry, I forgot you are English.

What's surprising about that? My colleagues all have English as their
first language, as do I. Chances are that for any one bit of personal
code I write, I'm likely to be the person reading it most.
(my colleagues, for a start) then why
should I not make the code as readable as possible for them?
Like it or not, I *do* think in English, where your way of expressing a comparison is unnatural.
I like it frankly. I think that many problems could be solved if we speek and think one language. English or not, it doesn't really matter. Back to the reality, we (non English) don't think in english, though.


Sure - I don't have any problem with that. However, I'd be interested
to know which languages have a preference for comparisons like this,
and which way that preference works.


Hmmm. I prefer a programming language for expressing comparitions in my
programs. And I don't try to read it *out loud* in english it doesn't make
sense to me. I read it in C#, C/C++ or whatever language I use.

I have worked like that for a long time. And I'm wondering if you need to
write something in Perl let say. How can you manage to read it *out loud* in
english.
You claim it doesn't hurt the readability. I *know* it does, for me. Yes, I can see, for you it does.
In that case I suggest you go back to C/C++ with the "freedom" of
memory leaks etc. Frankly I think you'll find you're in the minority if you believe that the lax if(...) compiler rules in C/C++ are a benefit.

It is strange that you bring up the qestion of the memory leaks. Reading the
groups for .NET I have seen so many post about memory leaks in the
framework. That many I've never seen in any c++ group. Believe me or not I have never had problems with memory leaks.


But how much energy have you had to expend in getting that right?


Have you ever written programs in C++? I suppose you have. I don't thing the
GC is the biggest advantage in languages like c# and Java. It sounds more
like commercial. I dare to say that I've never seen a question in a c++
group "How to free the memory". There is a lot of questions about GC,
though. And memory leaks in .NET.
In .NET and Java, I think, lot of objects stay in the managed heap
unreferenced awaiting for the GC to collect them undefined amount of time.

Absolutely. However, they *will* be collected if the memory is needed. Why not when I don't need them anymore. I preffer to have control on that
instead of use *dispose design pattern*, which looks more like a patch.

Some thimes they stay there until the precess ends, when eventually they
get freed. This in c++ we called memory leak. In .NET and Java it is called
managed heap.


There's a big difference between "memory isn't reclaimed because
there's no pressure on memory, so the GC doesn't run" and "memory isn't
reclaimed and *cannot* be reclaimed".

C/C++ guys looks like more flexible that the JAVA ones.
I don't think any Java advocate would deny that C/C++ is more flexible
than Java. They're more likely to argue that flexibility itself isn't
necessarily a good thing - which is the view I take.
So you'll prevent someone from writing code they (and other team
members) might find more readable, just because it might just, some
day, create one bug? That's really bad team leadership, IMO - you'll
be creating more bugs just by making them have to do more mental
translation when writing and reading the code.
"Mental translation" - sounds so complicated for so easy thing.


Doesn't sound complicated to me. It's obviously got to happen at some
level - but I believe that making it larger than it needs to be just
because in a different language it would prevent possible bugs isn't a
good idea.
Let's just hope I never have to work with you...

I'd like to work with you. I feel like you can hardly work with
*non-english*, but we can find a way around this, I believe.


I'd certainly have a problem if I couldn't understand people's
documentation and naming, yes. I think any group of programmers who
didn't have a common (human) language between them would find it
difficult to work together.


Take a look at some North American companies. You can find Indians,
Russians, English, Polish, Chinees, you name it programmers working together
in one team and doing great job. I think MS is such a company.
There is no problem with the language and no one of them speaks english like
you.
So, If you can't work with programmers, which you hardly understand without
making any effort the problem is entirely in you.
but comparing one boolean with the value of a method is pretty rare
too, in my code

Sounds senseless to me.


What do you mean? I'm saying that I rarely have a situation of:

if (someValue==SomeMethod())

where SomeMethod returns a boolean.
I'm not saying I never use cut-and-paste. I'm saying I try to use it as little as possible. Being able to cut and paste between different
languages is almost entirely unimportant for me, and whenever I *do*
cut and paste I have enough sense to check what I'm doing - because
cutting and pasting without examining the code afterwards is going to
cause far more bugs than using if (i==5).
Cut and paste between languages? *hmmm* I've never thought about that.

Does anybody do that?


I thought you'd implied it earlier, but I can't find the reference now.

I've never said it.
for (int i=0; i < 10; i++) NULL;
> Is clear enough. Too many comments hurts readability as well. Obvious > things don't have to be commented.

In that case reduce it to:

for (int i=0; i < 10; i++) {}
Maybe clear..., but ugly. I would prefer to stick with the

3-more-letters one.


In what way is it ugly? I would say that introducing the extra concept
of "NULL" is ugly at this stage. Nullity has nothing to do with what's
wanted. What's wanted is a "do nothing" block or statement, which is
*precisely* what {} is.

Nov 15 '05 #3
100 <10*@100.com> wrote:
I meant pardon as in, please rephrase that, because currently it
doesn't make sense as a sentence. I'll try one more time. Like it or not the most of the software companies
are situated in North America And in those companies most of the programmers
doesn't have english as a first language. And they don't think in English.


Did you mean to write that most software companies are *not* situated
in North America?

(I hasten to add that *I'm* not situated in North America too, by the
way.)

I'm quite happy to agree that most software engineers don't have
English as their first language. That's why I've asked whether/which
other languages have preferences like this.
Certainly. I'll pick up on just about anything :) Try harder, Jon. I don't understand everything of your perfect anglish,
neither. I'm keep trying, though. Some times it takes me several times to
read one paragraph, but I never give up. I appreciate everything that you
say.
And the last I mean it.
Thanks - that's much appreciated. Feel free to ask for further
clarification on anything I say.
Sure - I don't have any problem with that. However, I'd be interested
to know which languages have a preference for comparisons like this,
and which way that preference works.


Hmmm. I prefer a programming language for expressing comparitions in my
programs. And I don't try to read it *out loud* in english it doesn't make
sense to me. I read it in C#, C/C++ or whatever language I use.


I don't read it *literally* out loud, but I do "sound it out" in my
head, with appropriate translations for symbols etc. I don't know how
many other people do that. It may well be because that's the way I read
(and write) natural language too. In my head, I'm currently "hearing"
every word I'm typing.
I have worked like that for a long time. And I'm wondering if you need to
write something in Perl let say. How can you manage to read it *out loud* in
english.
Using appropriate mental translations. The translation doesn't
necessarily always keep absolutely all of the context, either - when
you end up in a situation with lots of casting etc, a lot of the
context goes, but you can always get that back by careful examination.
But how much energy have you had to expend in getting that right?


Have you ever written programs in C++?


Yes, some. Not vast amounts - I've written rather more C than C++, and
it amazes me every (rare) time I have to go back to it just how painful
it is to allocate and free memory all over the place.

In C++ I found similar but significantly diminished problems - it was
fine when it was absolutely obvious who "owned" a bit of memory, but
that wasn't always the case. I'll readily concede that I'm really only
a novice in C++.
I suppose you have. I don't thing the
GC is the biggest advantage in languages like c# and Java. It sounds more
like commercial. I dare to say that I've never seen a question in a c++
group "How to free the memory".
Sure - but that's because all C++ programmers are going to know how to
do that because you absolutely have to.
There is a lot of questions about GC, though. And memory leaks in .NET.
There are lots of questions about how to free/delete objects in .NET
because people assume they have to if they've come from a C/C++
background. Yes, there are questions about the operation of the GC,
because it's a reasonably complex thing - but I still believe it saves
a *heck* of a lot of developer time compared with mechanisms in C/C++.
Absolutely. However, they *will* be collected if the memory is needed. Why not when I don't need them anymore.
Because working that out in a deterministic fashion is basically
infeasible in any reasonable and robust way. There's a URL I can dig
out for you which gives some of the problems, if you want.
I preffer to have control on that
instead of use *dispose design pattern*, which looks more like a patch.
But why do you care when memory is reclaimed?
I'd certainly have a problem if I couldn't understand people's
documentation and naming, yes. I think any group of programmers who
didn't have a common (human) language between them would find it
difficult to work together.


Take a look at some North American companies. You can find Indians,
Russians, English, Polish, Chinees, you name it programmers working together
in one team and doing great job.


Do any of them not understand English though? I suspect you won't find
many US programmers who don't use English in their code, even if it's
not their first language for speaking.
I think MS is such a company.
There is no problem with the language and no one of them speaks english like
you.
I suspect all of them can communicate in English though, and I suspect
that that's the language they use for documentation, method naming etc.
So, If you can't work with programmers, which you hardly understand without
making any effort the problem is entirely in you.


I'm willing to make an effort, but if we literally didn't have any
language in common at all, I don't believe it would be a productive
relationship. It would be insane to have to consult a dictionary every
time either "side" wished to use a class that the other "side" had
written. Like it or not, English *is* the basic lingua franca of the
Net and of programming in general. In my experience, even companies who
aren't based in the US/UK/Australia tend to produce APIs in English,
regardless of how they document internally.

Can you name any significant international open source efforts which
have their primary documentation and API naming scheme in a language
other than English, for example?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Edo van der Zouwen | last post by:
I have the following problem. On a website there's a (simple) feedback form. This is used also by Polish visitors who (of course) type Polish text using special characters. However, when I...
43
by: 3seas | last post by:
If you are not interested, then don't bitch, its a short message. http://www.matrixcommunity.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=8;t=000918 I don't know if that link got broken. -- 3...
33
by: Steven Bethard | last post by:
I feel like this has probably been answered before, but I couldn't find something quite like it in the archives. Feel free to point me somewhere if you know where this has already been answered. ...
17
by: Andi Plotsky | last post by:
I am not a .NET developer. I want the Developer's Edition of Visual Studio for use with my Access2000 databases. Does anyone have a clue as to where to find it - my office manager says only .NET...
85
by: masood.iqbal | last post by:
I know that this topic may inflame the "C language Taleban", but is there any prospect of some of the neat features of C++ getting incorporated in C? No I am not talking out the OO stuff. I am...
21
by: Une bévue | last post by:
I'm still a neby in C, i do have two versions of about the same algo. The first one works fine but de second. I don't see what's the prob with the second. the purpose to cut out in sections a...
13
by: LC's No-Spam Newsreading account | last post by:
I have happily lived for 15 years (our first web server started in 1993) without CSS, but I now decided to learn and experiment with it. My personal preference has always been that the width of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.