|
I agree; can't the variables be passed into the constructor as a collection?
|
|
|
|
|
Or just a structure... It could even have a static method to fill itself from the session variables...
MyClass spork = new MyClass(MyClassArgs.LoadFromSession());
Same effect, a bit more verbose, but actually makes it obvious what's happening.
|
|
|
|
|
Both would be improvements.
I think the real horror and a very very common horror is the overuse and misuse of Session Variables.
These classes creating themselves from session variables are a symptom of that.
In reality if you have all these session variables, the class might as well not have any properties, since it then just turns around and writes it's properties to the DB.
Why not just write the Session variables to the DB?
Or why even bother with a class? If you're nailing your colors to the mast of Session variables then a Sub in a Module would do the same job.
Time for someone to write "Session Variables Considered Harmful"
Session variables are actually worse than traditional Global Variables, yet I rarely hear that much fuss about them.
In this day and age shouldn't we be required to declare Session Variables explicitly and also make them typesafe?
The more of other people's ASP.Net code that I have to maintain, the more I despise these little devils.
-Rd
|
|
|
|
|
How true. Did I ever mention the problems caused by a great thinker who stored dynamically created ASP.Net controls in the session?
The session state is member of the page object. The entries in the session state are controls, which again have a reference to the page. Circle complete. Now, what was this about a garbage collection and when exactly does it clean up?
A while ago he asked me what he should have printed on my business cards. I said 'Wizard'.
I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.
|
|
|
|
|
What is the end of the session?
I'll take Coding Horrors for $500 Alex.
|
|
|
|
|
|
I just take a look into my friend's code, then I found something confusing to me
I have made some modifications here :
Private Function xxx(ByVal name As String) As Boolean
Dim xxxResult As Boolean = False
If name = "A" Then
Return xxxResult
Else
Return xxxResult
End If
Return xxxResult
Exit Function
End Function
Finally, when I want to go back to my home, I still confused, the world is spinning in my head, there are so much doors.
25160506848319
|
|
|
|
|
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.
|
|
|
|