|
Is this a modern Where's Wally?
red_moon wrote: Where is the exit?
Private Function xxx(ByVal name As String) As Boolean
Dim xxxResult As Boolean = False
If name = "A" Then
' Lots of code here
Return xxxResult
Else
' Lots of code here
Return xxxResult
End If
' Lots of code again
Return xxxResult
Exit Function <------Its there just before the word function; Whats the prize?
End Function
Ok, so he's using multiple return points, and there is no requirement here for the Exit Function statement as it is at the end.
|
|
|
|
|
And all statements after End If is never executed too ...
25160506848319
|
|
|
|
|
daveauld wrote: Its there just before the word function; Whats the prize?
Check the code again. Will it come there to execute? How?
Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.
Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial
|
|
|
|
|
There are chunks of code removed, so we cannot assume that there are no Exit If 's anywhere.
Also, if its VB6 there may also be some On Error Resume Next statements. (Or On Error Goto xyz ), Ah, those 'handy' statements!
|
|
|
|
|
So, it's depends on the whole code implementation... Without seeing the original code, it's not feasible to reply...
Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.
Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial
|
|
|
|
|
Maybe this function is so comfortable that the thread spends a lot more time than needed in it ? Therefore the Exit Function to kick its ass and make it return to work... ^^
|
|
|
|
|
Yeah, that needs some GOTOs.
|
|
|
|
|
Yeah - starting with "GOTO AProgrammingLanguageThanSpotsUnreachableCode"
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I haven't met many compilers that do a good job at detecting unreachable statements, try this C# snippet:
public int unreachable(int a) {
if (a==1) return 2;
if (a!=1) return 3;
return 4;
}
|
|
|
|
|
That's just a if..else..maybe construct: we used to use them all the time in FORTRAN (because the compiler was such rubbish "maybe" would get executed sometimes).
At least C# would spot
public int unreachable(int a)
{
if (a==1)
return 2;
else
return 3;
return 4;
} Unlike some of the "coderzz" we have asking questions at the moment...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
He codes for both Aristotlean and Bhuddist logic. In the vast majority of cases the black and white of Aristotle will hold true but never underestimate the differing shades of Bhuddist logic. Maybe.
|
|
|
|
|
Most girls I've asked seem to think there is a very specific area that is an exit (making sure to note that it is not an entrance). In order to pass on this knowledge, I thought I'd let you know that "Return xxx..." is not an entrance.
|
|
|
|
|
I remember in around 1993 I was on an assembly language final project when I wrote around 65 thousand lines of code to replicate a text editor of Norton Commander. I successfully copied 98% of the functionality and 100% of the look and feel that NC Editor offered... and yes I got full marks on my project
The coding horror part: I didn't know the "jump far" instruction yes! imaging that! and I had to jump through a chain of labels to go far in my code! It was only when my brilliant professor[^] told me in the final presentation and viva, that I could have used the "jump far" instruction to tidy up the code.
I had backup of the code on a 3.5" floppy which i don't know where i lost in time, but i still have a print out of the code in the Project Report file.
Good ol' days!
Sohail Iqbal
|
|
|
|
|
I was a little frightened to open this message... I thought it might contain 65K lines of code.
|
|
|
|
|
LOLz
|
|
|
|
|
I am very much new to this forum, Just wanted to salute you for the fact that U had managed to learn Assembly. I know C, but assembly was never my cup of tea. Maybe I didn't try it that much. Now-a-days, companies usually look for only high level language programmers. I work on Vb6, but .NET is almost everywhere. There's no end to learning.
Hope u are into system programming. Would like to hear more from you in order to learn. Thanks.
|
|
|
|
|
Thank you ChandanPatra, much appreciated
Well i am a software architect now, (and yes, still happily coding) and this was some 16-17 years ago. I have been extensively coding in C those days and C# and is my first choice now. I only used assembly as a learning tool for to know goes on under-the-hood when you use high level languages. Even in doing micro-controller programming, I have used C and not much assembly as it takes much time and effort to do even basic tasks.
Assembly is easy to learn if you are determined, and there are many resources online to get started.
And you are right, companies look for high-level language programmers because they want to make things happen fast. More than 90% of developers are coding for business oriented applications using high-level languages and RAD tools and only a few select groups use low-level languages, mostly for research oriented projects, for example super fast algorithms.
I'm mostly into integration-specific projects now but will be happy to share my experiences if anyone asks
Cheers.
|
|
|
|
|
Thanks for ur beautiful reply. My name is Chandan Patra, I stay at Kolkata, India, I am almost a novice in true sense, being a Commerce Graduate I still find programming a great entertainer, and I just love it. I had Learned C some five years back, but got a job in Life Insurance industry [far away from programming].. Now desperately trying to come back to join the IT at this age of 30.. but opportunities are only for Computer engineers. But I want to start it over again... Now joined a company where I do some VB6 coding, Revising my C/C++ books.. need suggestion from your end...
What I should be learning immediately in order to survive and be a part of good programmers community?
Really looking forward to your answers.
|
|
|
|
|
Hello again, Chandan, and sorry for a late reply.
Its good to know that you are coming back to programming, and don't worry about your age, it doesn't matter here, you can always do something which you love
If you have done C/C++ in past then you should really jump into C# as soon as you can. Just take *ANY* C# book and read it all, from title to index. Then you need a copy of C# Black Book (http://www.amazon.com/Black-Book-Comprehensive-Problem-Paraglyph/dp/1932111174) on you desk when you start coding... and when you are fluent with the language, you wont possibly need anything, there is plenty of help and this huge community on internet to solve *any* problem you might have.
Get a copy of VS 2010 Express and you are in!
good luck
|
|
|
|
|
Dear checkmate, I really appreciate ur such a nice mail. I was a bit down finding no reply from ur end, thinking that advanced users like U may be wasting ur time after me. I am truly glad that u replied. I accepted all ur suggestions, will surely do it.
Thanks and regards .. Chandan
|
|
|
|
|
You are welcome friend
Happy coding.
|
|
|
|
|
What processor were you using that had a "jump far" instruction whose effect could be simulated with many shorter jumps? Were you using a 68000 and with the "bra" instruction rather than "jmp"? The "near jmp" instruction on the 8088 can't go between segments; were you using something else?
BTW, I have done some creative code-rearranging on some cycle-critical stuff for processors where conditional branches were limited to +/-127 instructions and I couldn't afford excessive jmp's. From a design standpoint, a horror, but it made things work which would otherwise take too long.
|
|
|
|
|
We were using 8088 Assembly and i was using simple "jmp" instruction which has limitation to +/- 127 bytes.
And i forgot to mention that my this 65K lines of code produced an executable of only 3.5K bytes... how about that?
Cheers
|
|
|
|
|
I've got a co-worker, who has done some great job in producing handsome and easy to understand pieces of code. The previos pearl was a 238 lines method, and when I asked to refactor it, he told that it was just fine.
Still, this one is my favorite. (The name of the metHod is not that important)
<pre>public void SendMetod<T, T1, T2>(IEnumerable<T> t)
where T: class
where T1: class
where T2: class</pre>
For some company issues I cannot post the method itself(a nice piece of work too, trust me), but it's header is adorable. T, T1, T2 and t is kinna brain explosive
-- Modified Thursday, September 2, 2010 5:53 AM
|
|
|
|
|
T2 was one of those rare movies where the sequel was better than the original. I understand what T1 and T2 are, but what is T? A prequel, perhaps? In any event, I'm glad they're making it with class.
|
|
|
|