|
tef posted:*producer puts thing on shared queue* *releases semaphore* *producer spins until it can acquire semaphore, reads queue* *implements threaded queue with a threaded queue*
|
# ? Nov 14, 2011 16:52 |
|
|
# ? Jun 10, 2024 09:04 |
|
Zombywuf posted:*implements threaded queue with a threaded queue* FYI, there is a ConcurrentQueue in .NET 4.0 for those of you who don't know: http://msdn.microsoft.com/en-us/library/dd267265.aspx
|
# ? Nov 14, 2011 19:25 |
|
So I'm trying to debug a unit test in visual studio 2010. I've set a breakpoint on every single loving line and it still bombs out by throwing an exception without hitting a breakpoint somehow. So I need to tell it to break on exceptions. http://msdn.microsoft.com/en-us/library/d14azbfh.aspx I'd forgotten just how much of a pile of poo poo this is. Why did I volunteer to do some .Net development? EDIT: goddamnit visual studio, I have jumped through your loving hoops, why you no break at breakpoint? Zombywuf fucked around with this message at 20:59 on Nov 14, 2011 |
# ? Nov 14, 2011 20:52 |
|
My limited attempts at C# development made me realize that most testing frameworks were fragile hokey metaprogramming attempts that made debuggers really confused. The only testing framework that was worth a poo poo was ones that tried to avoid that and just mocked a new instance using the interface definition.
|
# ? Nov 14, 2011 21:23 |
|
I haven't ran into any problems debugging unit tests. Are you sure you are debugging the unit test and not just running it?
|
# ? Nov 14, 2011 22:32 |
|
NotShadowStar posted:My limited attempts at C# development made me realize that most testing frameworks were fragile hokey metaprogramming attempts that made debuggers really confused. The only testing framework that was worth a poo poo was ones that tried to avoid that and just mocked a new instance using the interface definition. I ran into some weird edgecase in VS 2005 trying to determine how some unit test scaffolding was failing. You know all those attributes you use like [TestClass] and [TestMethod] and [TestCleanup]? Turns out MSTest does some hosed up syntactic analysis of the actual .cs file instead of using reflection to interrogate those attributes like any sane .NET code would. I don't know if this is still true in VS 2008 or 2010 but that one blew my mind back then.
|
# ? Nov 14, 2011 22:36 |
|
It seems to be due to the project files being on a remote directory which Visual Studio considers untrusted. I had to set it to trust it to load it, but I can't find the setting to trust it enough to debug it. Microsoft, misunderstanding security since forever.
|
# ? Nov 14, 2011 22:39 |
|
code:
|
# ? Nov 14, 2011 22:48 |
|
While loop is for loosers.
|
# ? Nov 14, 2011 23:20 |
|
TasteMyHouse posted:
Haha, a post about goto being used improperly (for once) AND a redundant if. Lovely.
|
# ? Nov 15, 2011 00:06 |
|
Jonnty posted:Haha, a post about goto being used improperly (for once) AND a redundant if. Lovely. e: whoops
|
# ? Nov 15, 2011 01:41 |
|
So yeah, I copy the folder to my VMs local drive and it breaks on breakpoints fine. And the test throws a different exception. EDIT: BindingFailure was detected Message: The assembly with display name 'Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel' or one of its dependencies. The system cannot find the file specified. Zombywuf fucked around with this message at 14:04 on Nov 15, 2011 |
# ? Nov 15, 2011 13:15 |
|
Reminds me of drudging through half a page of STL template syntax to get at the actual error.
|
# ? Nov 15, 2011 15:35 |
|
Beef posted:Reminds me of drudging through half a page of STL template syntax to get at the actual error. At least that would contain the actual error. The worst part is that after throwing that the unit test passed. Then I added more unit tests and it stopped throwing the exception.
|
# ? Nov 15, 2011 15:43 |
|
code:
WHY
|
# ? Nov 15, 2011 16:33 |
|
TasteMyHouse posted:
Maybe he was editing code in Word and was getting pissed off by auto-capitalization.
|
# ? Nov 15, 2011 17:34 |
|
TasteMyHouse posted:
The author of this book on C# insists on using Int32 everywhere instead of int because apparently having the shorter version defined in the language spec as 32 bits is not a good enough guarantee that it will actually be 32 bits wide. The keyword int can represent different width integers in other languages you see, so if you try to run your C# code through a COBOL compiler you may get errors. That book is an ok read in general but the author spergs out about stuff constantly, sometimes to the point that the editor clearly moved big blocks of text into "Jeff's Ignorable Opinion" callout boxes just to preserve the reader's sanity.
|
# ? Nov 15, 2011 17:57 |
|
PDP-1 posted:if you try to run your C# code through a COBOL compiler you may get errors.
|
# ? Nov 15, 2011 18:43 |
|
PDP-1 posted:The author of this book on C# insists on using Int32 everywhere instead of int because apparently having the shorter version defined in the language spec as 32 bits is not a good enough guarantee that it will actually be 32 bits wide. The keyword int can represent different width integers in other languages you see, so if you try to run your C# code through a COBOL compiler you may get errors. This is C++ code.
|
# ? Nov 15, 2011 19:18 |
|
PDP-1 posted:The author of this book on C# insists on using Int32 everywhere instead of int because apparently having the shorter version defined in the language spec as 32 bits is not a good enough guarantee that it will actually be 32 bits wide. The keyword int can represent different width integers in other languages you see, so if you try to run your C# code through a COBOL compiler you may get errors. He also pimps his own libraries constantly, sometimes to the detriment of explaining how the original thing his library replaces actually works under the hood which is the whole point of the book. It does have a couple really good chapters about threading though.
|
# ? Nov 15, 2011 19:22 |
|
TasteMyHouse posted:This is C++ code. obviously it's so he can typedef short Int; if he ever needs to move to an embedded platform. anyway code:
|
# ? Nov 15, 2011 20:37 |
|
evensevenone posted:obviously it's so he can typedef short Int; if he ever needs to move to an embedded platform. Are you referring to the fact that the behavior is opposite of that of most languages? Also
|
# ? Nov 15, 2011 20:47 |
|
PDP-1 posted:The author of this book on C# insists on using Int32 everywhere instead of int because apparently having the shorter version defined in the language spec as 32 bits is not a good enough guarantee that it will actually be 32 bits wide. The keyword int can represent different width integers in other languages you see, so if you try to run your C# code through a COBOL compiler you may get errors. The advice I remember from the book was that you should make sure you name your methods as DoSomethingWithInt32 instead of DoSomethingWithInt because Int32 is a CLS type and int is a language keyword, not guaranteed to mean the same thing in another language calling your code. Which is good advice that I agree with, but it isn't super important because I expect 100% of programmers targeting .NET to assume int=Int32.
|
# ? Nov 15, 2011 22:01 |
|
Modern Pragmatist posted:Are you referring to the fact that the behavior is opposite of that of most languages? I'm bitching about the fact that a) matlab does have enums and b) even if it didn't (they are kinda new), this is a pretty dumb way to do them. I don't really care that strcmp is backwards of C which is kind of backwards to begin with.
|
# ? Nov 15, 2011 22:09 |
|
evensevenone posted:I'm bitching about the fact that a) matlab does have enums and b) even if it didn't (they are kinda new), this is a pretty dumb way to do them. What? Matlab's strcmp only tells you if the strings are equal or not. strcmp(str1,str2) in every other language returns 0 if they're equal, something < 0 if str1 < str2, and something > 0 if str1 > str2. What alternative do you propose?
|
# ? Nov 15, 2011 22:35 |
|
Nothing. The C way is probably the best. anyway, using strings as enums is dumb.
|
# ? Nov 15, 2011 23:23 |
|
Smugdog Millionaire posted:The advice I remember from the book was that you should make sure you name your methods as DoSomethingWithInt32 instead of DoSomethingWithInt because Int32 is a CLS type and int is a language keyword, not guaranteed to mean the same thing in another language calling your code. True, and I understand his argument on naming conventions when you're writing stuff that could be called from outside. If you look at his code examples however, he uses Int32 inside of his classes with the argument that people reading the code may be confused by the less-specific int keyword. That goes past the point of careful coding practices and into crazy spergtown in my mind. ninjeff posted:What good is that? M$ needs to get a new language designer as Anders is obviously not pulling his weight. Really makes you wonder how many other languages C# won't compile as, in the year of our lord 2011 no less. Just wait until the Roslyn compiler services go live - you'll be able to copy/paste code between C#, VB, and Managed COBOL projects seamlessly!
|
# ? Nov 15, 2011 23:27 |
|
Smugdog Millionaire posted:The advice I remember from the book was that you should make sure you name your methods as DoSomethingWithInt32 instead of DoSomethingWithInt because Int32 is a CLS type and int is a language keyword, not guaranteed to mean the same thing in another language calling your code. He does say this and it's definitely good advice (in fact it's part of the Microsoft Framework Design Guidelines) but he also rails against the basic C# type keywords which is... okay I can kinda see his point but relax buddy. There are quite a few portions of the book that swerve into "this is how I would have designed C# if somebody asked me and by the way I'd like to point out that no one asked me" territory. What's odd is I don't remember the second edition of the book having these weird asides; it was only the third edition after .NET 3.5 he apparently got all fussy about C# syntax. Dr Monkeysee fucked around with this message at 23:49 on Nov 15, 2011 |
# ? Nov 15, 2011 23:44 |
|
code:
|
# ? Nov 16, 2011 01:24 |
|
evensevenone posted:Nothing. The C way is probably the best. To be fair, matlab doesn't really have strings at all which I've already mentioned is hosed Up.
|
# ? Nov 16, 2011 06:12 |
|
Just did this right now.code:
code:
|
# ? Nov 16, 2011 06:43 |
|
Shrodinger's Collection.
|
# ? Nov 16, 2011 06:53 |
|
From when I was TAing intro to data structures:code:
|
# ? Nov 16, 2011 07:00 |
|
Haha, worst binary search variable names ever. Also runs a comparer of unknown complexity 3 times per iteration...
|
# ? Nov 16, 2011 07:25 |
|
Orzo posted:Haha, worst binary search variable names ever. Also runs a comparer of unknown complexity 3 times per iteration... Eh. I might have used variable names like that when I was a student, just for a laugh. Granted, I'd have no idea what they were when I examined them later, nor would the grader understand it, but it'd be funny. The comparator would be a bigger concern; even as a student, I understood that you want to avoid doing things like that more than once. Would it be so hard to do it right? code:
|
# ? Nov 16, 2011 08:18 |
|
apseudonym posted:
This is amazing.
|
# ? Nov 16, 2011 16:52 |
|
can anyone spot the bug in the binary search? answer tef fucked around with this message at 19:52 on Nov 16, 2011 |
# ? Nov 16, 2011 19:50 |
|
There's no bug, it's by design...the variable is called 'maybe' because maybe it overflows, maybe it doesn't.
|
# ? Nov 16, 2011 20:17 |
|
That's clearly the main problem with that code.
|
# ? Nov 16, 2011 20:48 |
|
|
# ? Jun 10, 2024 09:04 |
|
tef posted:can anyone spot the bug in the binary search? The worst part about being self-taught/un-educated in programming is that I've noticed this bug several times, but thought I just didn't understand what was really going on.
|
# ? Nov 16, 2011 22:29 |