|
A BASIC developer new to C#?
jofli wrote: Recieved
And maybe didn't graduate high school either?
|
|
|
|
|
PIEBALDconsult wrote: A BASIC developer new to C#?
No way. Any Basic developer would use either Chr$(13) & Chr$(10) or vbCrLf , both much more readable than the OP.
|
|
|
|
|
PIEBALDconsult wrote: jofli wrote:
Recieved
And maybe didn't graduate high school either? Big Grin
http://www.recieved.co.uk/[^]
Well, at least he tried to use English namings. And I must admit that sometimes it's not that easy, if you're not a native speaker.
|
|
|
|
|
My guess is that this is an artifact of Reflector, not of the original coder.
I do know that in VB, the Chr() function actually does use Convert.ToChar internally so my guess is that C# does the same. Who knows what Environment.NewLine does internally. I assume that the compiler has in-lined the Chr function, and Reflector has simply given you back what the compiler produced. Anyone with too much free time on their hands and a handy copy of Reflector is invited to experiment to find out what the compiler does with this sort of thing.
Reflector is showing you what the code looks like after the compiler has munged it around and played merry havoc with your beautiful code.
|
|
|
|
|
OK, there is no Chr function in C# but you know what I mean.
|
|
|
|
|
The correct code in C# is "\r\n" which is ldstr "\r\n" in MSIL (which is generated exactly like that by the C# compiler)
|
|
|
|
|
The OP doesn't say that the code was written in C#, it was reverse engineered using Reflector. Reflector is capable of taking code written in VB and decompiling it back into C#. The resulting C# code may look pretty odd, but you will at least be able to see what it is doing.
|
|
|
|
|
That's right, but afaik he only codes c#.
|
|
|
|
|
Well, OK, maybe he's just an idiot. As far as I am aware, Reflector doesn't stop people from writing bad code and will happily decompile bad C# back into bad C#. GIGO, as they say.
For what it's worth, the MS .NET Framework implementation of C# Environment.NewLine returns a literal constant "\r\n". No idea what Mono does. So if the contractor wrote this in C#, goodness only knows what was going through his brain. Nothing, probably, if he's like some of the contractors I've known.
|
|
|
|
|
The Chr() = Convert.ToChar() thing makes some sense, but why int.Parse("13") instead of just 13?
|
|
|
|
|
Looks like temp = Chr(13) + Chr(10) gets decompiled into temp = "\r\n"; so the compiler is smart enough to actually make the string when you call Chr with a constant. Environment.NewLine shows up as a property call in Reflector, but the JIT may inline it as a literal string.
There's no way Reflector would generate what the OP is seeing unless the code really was that bad.
|
|
|
|
|
Come to think of it, why are you having to reverse engineer the contractor's project? If he wrote the code while in your employ, I would expect that you would own the intellectual property rights to the code, and normally you would expect to have a copy of the source after his contract ends.
Unless you bought this from him as a finished product rather than contracting his time to write it for you. In which case, he owns the copyright and reverse engineering it could be a breach of the licence terms (which normally forbid that sort of thing).
|
|
|
|
|
David Skelly wrote: reverse engineering it could be a breach of the licence terms (which normally forbid that sort of thing)
Perhaps this could be the reason exactly why they forbid reverse engineering?
|
|
|
|
|
|
I'm working with some really bad code at the moment. There is some code which joins a load of values (integers) with '~', and then it passes it to a function. So it would be something like 1~5~12~3 etc. In the function it then splits this values on the '~' to get each value. It would be so much more readable, efficient, and less frangile if they had used an array. It amazes me how these people do their job. The other code in the project isn't much better either, actually the other problems are more difficult to fix. I hate blaming other peoples code, but I think that's what I will need to do.
|
|
|
|
|
I suspect this kind of genius deservse some sort of coding award. Shall we call it the "Golden Hammer" ?
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Sounds like you work with a coworker of mine
|
|
|
|
|
Arrays are magical objects that only the high priests can call into being and manipulate.
|
|
|
|
|
And every now and again developers must be sacrificed in order to summon them.
|
|
|
|
|
I can think of a few you can have - do they have to be virgins?
(buyer collects, sold as seen and definately without warrantee)
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
OriginalGriff wrote: do they have to be virgins?
Not a very limiting factor...
|
|
|
|
|
Maybe not in the states, but in europe software developers are next only to film and pop stars in the "shagabillity" stakes! Unless they are VB developers, obviously.
</lie mode>
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
OriginalGriff wrote: Unless they are VB developers, obviously
Then they trump even Brad Pitt!!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
You are both horrible liars.
Come on, we all know the standard programmer package involves a guy living in mom's basement at 20-something who plays World of Warcraft, goes to ren faires and hasn't touch a female pink part in 20 something years.
The upgraded "I'll code for food" programmer has a wife, 2 kids, a mortgage and wishes he had gone into business school.
For the premium package you get the choice of it being male or female, and the programmer is actually happy in the job. Most business do not opt for this upgrade.
|
|
|
|
|
ragnaroknrol wrote: You are both horrible liars.
I think they are quite good at it!
|
|
|
|