last day (5167 days later) » 
07:00 - 16:0016:00 - 00:00

07:05
ArgumentNullException
3
Welcome to C# on SO Chat, and please remember to read the FAQ
16
Can you star that @balpha?
you can pin it
Aha
I have still so much to learn
Be patient, my young Padawan
07:20
I thought it was grasshoppa
I don't think I remember "grasshoppa" in the Lucas script...
so is this room IDisposable?
He switched it out I think
No
That's a using directive, not a using statement
singleton?
Definitely
There can be only one
but mutable; hmmm... mutable singletons need careful handling
2
07:26
It's worse than that
It's also used in a multithreaded context
People will be throwing stuff at it all willy nilly
07:43
hello world
Debug.WriteLine("Hello World");
This site is built for Release, so Debug doesn't work here
Sorry I forgot it just came out from beta status
Just for the fun : I am debugging a 8 year old code in ASP.NET 1.1 :p It's pure pain. We have sever memoery issues because of very high w3svc worker processes, and we realize the guy who code things did not even only .Dispose() a single SPWeb and SPSite object, nor he .Close() data readers :D
This is typically a Daily WTF case
08:00
No fxcop to check all of that? :p
Disposing resources correctly is a pure pain when using(...) {} does not exists. The whole things is written in VB.NET 1.1
eeeeek
@controlbreak Not as much written, as much as coagulated
it allways could be worse : at least it does not use MS Access as a back end database
It could be worse than that, it could use MySQL 3
08:04
A few days ago, we had a code review done by MS experts. One of the comment was that we used "latest C# 3.5 techniques such as lambda expressions and methods extensions".
Luckily, management plans to move towards Sharepoint 2010. That will enable us to rewrite the whole thing. I expect this to happens in 2017, after Win7 workstation migration.
@Philippe Was that a good job or don't do this type of comment?
then stating that the use of new stuff would mean more training for the staff that will have to maintain that
It was mitigated, saying that the codebase had different styles (namely old C# techniques)
VB.NET worse inventions are "option explicit" and "option strict" : because they can be turned OFF.
@controlbreak using(...) {} can be over-used. I've seen an app where mysterious bugs were the result of usings.
08:11
@cofiem This is interresting. Do you have a SO question related to this ? I'm curious about it
@controlbreak options explicit and strict came from VB, possibly V1. VB.NET just continued them
@controlbreak no SO Qs, but the gist of it was trying to pass around classes that implemented IDisposable. At seemingly random locations, there'd be using(instance){ }.
@cofiem passing references around without clear ownership (i.e. what is responsible for deleting) is just a way to create interesting defects
@Richard yup... glad that one is a distant memory.
@Lass
it was commenting that the codebase had different styles, hence future staff will have to get training to understand C# nex features
hum, I'm having some issues with the chat it seems, one of my message moved all the way to the top
08:18
@cofiem I like using() statement. I'm using it to be sure my objects are disposed in every case, including returns and exceptions. I rarely use explicit .Dispose() statements, but I'm convinced it is not the best solution in any case. Especially when involved object Dispose() implementation involves unknown costs or side effects... That's why I'm trying my best to use using() with object I know a little bit about their lifecycle and Dispose() implementation.
@Richard I regret vb.net did not default them to on :D
@controlbreak yes, it is certainly a good idea to use using, but just be careful with it. Make sure you know an object's lifecycle/lifetime, and that there is no built-in way to check if an object has been disposed.
@controlbreak I regretted it from VB5 :-(
@cofiem You're right. Talking about this, I think Reflector deserves a Nobel price. It helped me to understood strange things. What about an Atwood's price for such useful pieces of software ?
@controlbreak I'm assuming you mean prize?
08:40
@cofiem Yes :) Sorry about the typo
I just had to explain to some coleagues how String and string in C# are exactly the same. They inist on saying that there's an article on MSDN that states the differences.
There's a difference in what the words are, but not what they mean
So you could both be right
@Philippe They're right, String starts with an uppercase letter, and string not ;)
sigh, first visit to the chat room and people discussing the case of string :)
08:54
at least you know that you are in the right place :)
It's not so much as we discussing it, as we're discussing other people that was discussing it :)
feels like a linux chat room already
@Philippe They're right: `string` is a language keyword, `String` is the name of a BCL type. This is seen in syntax colouring.
You're right: they mean the same thing and can be used interchangeable.
meta discussing it, indeeed
@Richard yes I'm sure at some point someone will fallback on that argument to prove he was not wrong :)
good to know though - heres an interview question im never sure of, what makes a srting a primitive or a class
worded badly, what features make a string a primitive and what make it an object
08:58
I don't think that's a good interview question
Sure, there's a need to know the basics, but you should focus on whether the candidate can think on his feet, nor whether he can memorize some specification
@lass
@LasseVKarlsen A lot aren't. They are still asked
@burnt_hand Please try to respond by typing in the message together with the mention :)
@burnt_hand Yes, I know
I suggest the reply button to be placed elsewhere, an easier way to hit at
@LasseVKarlsen Yeah, I hit the enter key to select the person; sent the message
@burnt_hand I did exactly the same an hour ago :)
now I got used to the tab
09:05
@LasseVKarlsen I actually think it's a good question, not to know the answer, but t know that it acts as both
Again about string, we had a comment from MS saying that we had some "+" in the code, and that they should be replaced by calls to Concat, for "performance optimisations". I choked.
@Philippe wow. you paid those guys?
@burnt_hand no, we didn't. But our client did :) And they want all those points to be fixed so we are MS compliant!
@Philippe ah bureaucracy
@controlbreak it moved several times in the beta. The Chat Feedback room is here for such discussion
09:14
only to mention that those "+" where in a method called GetHelpMessage in a class that is a custom command for stsadm. Performances are indeed crucial there.
@Philippe where doesn't matter. The compiler converts + on strings to String.Concaternate where is cannot do the concatenate at compile time [I accept this might be stating well know facts -- unless you're one of the reviewers]
Yeah, that was my reaction too, converting + to String.Concat is just plain wrong, there's absolutely no need to do that for any reason
@LasseVKarlsen, because you come from C++ and you don't trust someone not to have redefined the + operator? :)
What? Not sure I understand how your response applies to my response
What does irritate me, though, is that resharper insists that this ToString() is redundant:
09:18
What? You didn't use stringbuilder for your UI messages! ;)
string s = "abc" + someInteger.ToString() + "def";
@MarcGravell it's not?
that is not a redundant ToString(); it changes the overload of Concat that gets called
interesting
It goes from concat(string, string, string) to concat(string, object, string) or something similar
09:19
indeed
boxing + unboxing
In the end, ToString will be called, but the path to get there is different
yay, learning is fun
string s = "abc" + someInteger + "def"; uses Concat(object,object,object) instead of Concat(string,string,string)
@Richard, @LasseVKarlsen: indeed, that why I choked :)
yup, so there is boxing
@LasseVKarlsen I don't think it ever unboxes
09:20
Perhaps not
What about string.format("abc{0}def", someInteger) ? I prefer this
boxes also
For most scenarios that'll be fine (but again, boxes) - but I'm just not sure that I want the engine looking for {n} all the time.
I was tempted to write a pre-compiled string.Format handler - any offers?
@MarcGravell I think inside ValueType.ToString() there will be unboxing, but inbuilt types are probably special cased to avoid the unbox
i.e. new StringFormatter("This is {0} a {1:###,###} formatted string") which you can store and re-use, but which does the parsing etc once
09:23
@Marc I'd help with that
@MarcGravell: intresting :)
then formatter.ToString(someX, someY)
It would be interested whether the displaying of x.ToString() / `x.ToString(format)`or the parsing of the format was the major overhead
Or you could just get a delegate for it
formatter(x, y)
@LasseVKarlsen that too; so Func<DateTime,int,string> formatter = StringFormatter.Create<DateTime,int>(format)
09:24
It should probably use Reflection.Emit to build up code that did this
And some heuristics whether to use string.concat or a stringbuilder
good job I've done an insane amount of Reflection.Emit lately ;p
I expect the answer is: it depends. So StringFormatter would only provide a measurable net performance improvement where the ToString calls on the parameters are trivial.
Yeah, but there's a difference between building reusable framework code and application code
agreed - first thing to do is to measure the two versions; see if it is worth it
In application code, I'm all for not doing premature optimization
In reusable framework code, for general usage, I'm all for a bit of optimization
09:26
hardware is cheap. if the application doesn't run fast, upgrade the machine / server
I consider protobuf-net framework code; it does insane amounts to make the caller's life painless
Let me write up a simple test of two such formats
What's a good code posting site? We should probably make a pinned link to one such thing right off the bat
First day of chat and a project is already about to start, amazing :)
I love string.format("abc{0}def", someInteger). It quite helps me when my application are localizable : I can store "abc{0}def" as a resource string.
Yes, but that still works with the proposal
that we are even discussing this allows me to declare the C# room a success
09:31
:)
@MarcGravell I surprised a discussion about MS Compliance + a interview question, sorry, Concat("MS Compliance", "interview question") started an actual useful conversation
gist: Test project for measuring whether there would be a case for creating an optimized version of String.Format, 2010-10-15 09:37:31Z
private static int v1 = 10;
private static bool v2 = true;
private static DateTime v3 = DateTime.Now;
private static Decimal v4 = 10M;

void Main()
{
    const int IterationCount = 100000;
    
	// Warm up the JITter
    Format1();
    Format2();
    Format3();
    
    // Do the timings
    Stopwatch sw = Stopwatch.StartNew();
    for (int index = 1; index < IterationCount; index++)
        Format1();
    sw.Stop();
    Debug.WriteLine("1: " + sw.ElapsedMilliseconds + " ms");

    sw = Stopwatch.StartNew();
    for (int index = 1; index < IterationCount; index++)
        Format2();
    sw.Stop();
    Debug.WriteLine("2: " + sw.ElapsedMilliseconds + " ms");

    sw = Stopwatch.StartNew();
    for (int index = 1; index < IterationCount; index++)
        Format3();
    sw.Stop();
    Debug.WriteLine("3: " + sw.ElapsedMilliseconds + " ms");
}

static void Format1()
{
    string s = string.Format("abc{0}def{1}ghi{2:dd.MM.yyyy}jkl{3:c}", v1, v2, v3, v4);
    GC.KeepAlive(s);
}

static void Format2()
{
    string s = "abc" + v1.ToString() + "def" + v2.ToString() + "ghi" + v3.ToString("dd.MM.yyyy") + "jkl" + v4.ToString("c");
    GC.KeepAlive(s);
}

static void Format3()
{
    string s = new StringBuilder(30).Append("abc").Append(v1).Append("def")
        .Append(v2).Append("ghi").Append(v3.ToString("dd.MM.yyyy"))
        .Append("jkl").Append(v4.ToString("c")).ToString();
    GC.KeepAlive(s);
}
This will turn as a collaborative development platform
Please poke some holes in this, what did I do wrong? (I don't know that I did, but before we do any real work on this, make sure we're timing the right things)
(forget what I said : I just patented the idea ;))
09:39
To post code, use Gist, the chat system oneboxes it.
To easily test C# code, use LINQPad.
4
The output of that program gives me 309ms for String.Format, 230ms for +, and 248ms for StringBuilder, but some times StringBuilder is slightly faster than +
hmm... testing locally (independent test), string.Format doesn't do too badly
Nope, it doesn't
not worth it :(
oh well, scratch that idea then
Well. This is a good new anyway ^^ I'm using string.format a lot.
@LasseVKarlsen: String format is a bit slower for me too, but I have nearly the same results for 2 and 3
09:46
How much of an improvement did you see on your test @Marc?
independent test? hang on, let me swap the comments back out
If 309ms vs. 230ms is typical, it would be about 25% improvement, I could easily see investing a bit of time in exploring that idea further
But 25% improvement on this alone, doubtful that this part is a big part of some bottleneck somewhere
doing 1000000 iterations, 1808ms vs 1624ms. But that is such a crazy number of iterations, and such a small delta, that I can't get excited.
Doubtful that this would translate into useful speed improvements in a real project
Unless I was writing something like an xml/json/csv-serializer
@LasseVKarlsen agreed
09:49
@LasseVKarlsen I have an average of 25% improvement, nothing to get excited about :)
No, not on this alone
was intresting though
Hey, if this is a sign of times to come in this (and other) room(s), then it'll be interesting times ahead, that's for sure :)
I can see lots of good things happening
10:01
hello guys..
lol? concatinating with + performs best when I test
1: 192 ms
2: 142 ms
3: 162 ms
can I ask some advice/opinion about asp.net mvc
?
@Gideon, Don't use it :) just kidding! Of course you can
@Gideon Of course, but note that this is a C# room, there may or may not actually be any MVC or ASP.NET people in here
10:05
so i've been eyeing mvc so much and I checked the nerd dinner tutes and of course scott hanselmans vids...
and it may also be better as a SO question; but fire away, and then we'll know ;p
@Gideon look into IoC and dependancy injection
it seems so much nicer (As opposed to web forms) even after coming from windows dev i was always confused about web forms "magic"
so im very tempted to use mvc now, and I have a big project coming...
ive already decided to use silverlight 4 and WCF data services (which ive got upto speed with so far)
but now Im thinking maybe I should go MVC?
the question -> its a large, important project (inhouse LAN hosted web data app)
you can use all three as they complement each other
would it be a good thing to use mvc?
(the projects is still in the mockup and wireframe stage) dev will begin in about 2-3 weeks)
10:10
I can't speak for ASP.NET MVC, but I wouldn't recommend learning a new technology and using it on a large project straight away
learn MVC and use it on a throwaway project, then start again on the major one
@Lasse, I always like using this benchmarker ... stackoverflow.com/questions/1047218/… its pretty safe
@tim
@tim true!
@SamSaffron Yeah, that one looks really nice
since you've got a couple of weeks, maybe code a simple app where you can make mistakes
would it then be easy to bring the web forms app to mvc?
10:11
if you have written your program in a multi layered way
but you may have to scrap you ui
*your UI
@burnt_hand press the up arrow to edit your last message
ahh, brilliant - reading the help now
hmm one more thing... its a distributed sort of app... the real "app" is a windows desktop software that records lot of financial portfolio data and how this banks managers perform, how much they sell etc...
the data goes up to the server, and the asp.net app is there for mostly administration...
guys will hopefully log into the web app and see whats going on... and manage user logins etc..
maybe code it both ways then?
both ways?
webforms AND mvc?
10:15
if you write the admin interface code independently of the UI, then the UI should be pretty thin
If you dont grok ASP.NET's magic right now you're better off not grokking ASP.NET MVC's magic right now though.
hmm... maybe ill try and find something to do in mvc first!
im just typically geeky and very excited about it! lol
@MartijnLaarman grok. no one will believe me, when i use this word from now on, that it actually means something
the only problem i've always had with asp.net is the whole html/css/javascript world which is like chinese to me... and worst of all my main visual associate is taking a hike..so i've had to wade through css and html for the last 4 months like crazy! =S
@Gideon hmm... if you don't enjoy HTML, CSS or Javascript then I don't think ASP.NET MVC is going to be an improvement
10:21
anyway thanks so much guys!! =)
since it's even closer to plain HTML than ordinary ASP.NET
@MartijnLaarman we dont all carry the internet in our pockets here / not been snarky
10:36
I still can't tell whether you are calling me out or not, i am going to assume the positive though :)
I would have a smart phone, but I would rather have one that can last more than a day. Perhaps the Win 7 one so I can develop silverlight on it
with a car battery in the other pocket to make it last a week
11:08
many c# developers here from london by any chance? I want to know if there are any free conferences coming up in this region.
@burnt_hand DeveloperDeveloperDeveloper is at Reading 23rd Oct
@burnt_hand Sourcesence is doing a free lucene/solr conf in london too. sourcesense.com/en/events/searcheutour.html I'll be going to the amsterdam one.
 
2 hours later…
13:28
Anyone here near Colchester or Ipswich?
14:00
@HollyStyles Does Norway count?
Belgium is a bit closer...
hmmm...
east London?
hey guys : )
kewl interface : )
14:10
yeah, it's the new IRC :)
Not really, IRC has privacy ;)
its killer feature: it's not yet blocked by corporate web proxies
so what's this built in?
hello folks :) amazing stuff
14:12
I guess it's .Net/jQuery
tim. Just switch to another employer that trusts his people
by the looks of it and by the devs :)
@mstrickland, asp.net mvc and jquery
and I'm guessing it's using the polling setup in .net?
post on every 200ms
interesting
14:15
that's exactly what I was looking at :)
@mstrickland, polling setup?
hey hey hey
@mstrickland The polling is from the client (use fiddler, firebug, or something similar to see)
Looks like it polls at ~2s intervals.
you guys looking at how this chat works or something?
@Smazy unfortunately 'trust' doesn't seem to apply to regulated industries...
14:30
hm... what is this for?
i just write a long message to test how this chat works under the hood..... sorry guys... http polling it is? .... more placeholder text ... bla bal
yeah its just posting with a json response from the server
it's using longpolling?
nope
the requests come back blank as soon as they're made
ic
14:33
Why are there two chat rooms for C#? Which one is the real one?
we just did this at here too, but the request blocks until it gets content
thats clever :-)
polling is nice b/c it doesn't tie up connections/sockets
curious at how you'd define this at such lowlevel but I don't wanne be the dumb one :p
but the polling could wait longer... at least like there is really an update from the server...
14:34
Hello
there's two chatrooms for c#?
Agreed, you just have to have a pretty responsive backend to keep up with so many polls. Especially when the interval is so short.
yeah, i mean thats the ideal solution
you make a js request to another handler, it blocks until it gets stuff to send to the client
when that happens, a new request is made as soon as you're done doing stuff in the browser w/ the response from the old request
@WillCharczuk "long poll"
but this just keeps hammering the server w/ no blocking
14:35
so you keep the connection to the server open, which is called the longpolling technique if I'm not mistaken
yeah
which is not what this is doing
what if you have a million users chatting at once
Long polling does eat up connections/sockets though, correct?
@Pandicus Yes. One subtitled "using StackOverflow.Chat.CodeDom.CSharp;" and one subtitled "C# talk".
14:35
doesn't this kill your server
yep long polling or comet
ow another peter, confusing
Comet is a web application model in which a long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it. Comet is an umbrella term, encompassing multiple techniques for achieving this interaction. All these methods rely on features included by default in browsers, such as JavaScript, rather than on non-default plugins. The Comet approach differs from the original model of the web, in which a browser requests a complete web page at a time. The use of Comet techniques predates the name Comet, and is also known by several other names,...
but you can have ~32,000 connections/sockets per port
so * 5 forward facing servers
thats a bunch of users online at once
we have 16 forward facing servers and its plenty for long polling
we use this technique with silverlight and it works quite well with ~2000 users on some decent hardware
14:37
cool
Yeah, that's a good point. I wasn't sure of the caps on stuff like that as I haven't really explored it. Good to know though.
which someone would write a blogpost explaining this whole thing :-) I would be so interested
wish* instead of which lol
and on the server runs .NET and not any of those toy languages :->
@herzmeisterderwelten LOL
Isn't node.js designed for this?
14:41
This is the related blog post tomasz.janczuk.org/2009/09/…
But the Silverlight client with WCF backend works a little different than this chat
Will just said the chat doesn't use long polling
it just sends a request at an interval, and gets a blank response when there's nothing new
@peter ... yes... not really long polling
that's how I build a flash chat app a decade ago, it killed the server when 50 users where online
the server side piece must be very light weight
yeah I always requested a php page that had the results for that specific user
must've been doing something wrong :-)
14:46
lol
maybe the SO guys wrote a fancy little c# console app that listens on port 80 and keeps all chat msg in memory
who knows :-)
although sql is bloody fast and also caches ur frequently requested stuff into memory
maybe they're using aan OODB
but still not fast enough to handle so many users and so many polls...
i post my csharp4 top5 features to keep this chat c# related ;-)Optional params, Named params, dynamic binding, Type variance Co+Contra
aan OODB would be I'd imagine
whats your favs?
our chat engine has a c# service that keeps all the chats together
and then a "log" timer that queues up messages and sends them down to the db in batches
rather than every time a user sends a msg
14:51
how many ppl can u handle?
all of our clients
so a couple hundred thousand ppl at once
have you done a loadtest?
damn
14:52
the bigger problem wasn't logging, it was just keeping all the servers sync'd
jealous
how many connections do u have currently?
like if you have 16 servers for socket/connection reasons, making sure user 1 gets a message from user 2 when they're on different servers
i'd have to ask
cool thx
could one of you guys takes the time to write it all out into a stackoverflow blogpost? I'll donate 50rep :P
or is this sort of a secret :D
14:55
nah, most of the concepts are covered by the comet wiki page, haha
i think 37 signals wrote something up about basecamp but i'm not sure
@Will: well done! as we expect it from you SO guys!!
I agree, I'd be very interesting in hearing how the backend service works. We're doing a similar thing at my work. Using GWT as a front end to communicate to a .NET backend. We were initially talking directly to SQL Server, which was painfully slow - so we put in a Memcache middle layer to take off some of the load, but it's still not the best setup. We didn't want to dive into long polling either. So maybe a C# service sitting in between the WebService and SQL would be better a route.
I'll take a look at the aforementioned comet wiki though.
i mean, comet is just the methodology for having a client talk to your servers
it would be cool to have a more central reference on how to set up a chat server
Okay, I should brush up on my teminology then. I assumed comet was some component/flash thing. :P
You could also just wait till everyone has the HTML5 websockets support
14:59
I wish!
@Peter true
websockets would be a lot easier
iirc websockets isn't even part of HTML5
wiki says it's in the draft for html 5
on the comet wiki page anyway
I didn't realize C# was more popular than Haskell .... wow
15:01
I think it was at some point but was taken out into a separate spec, that Comet page may be outdated
nyway gotta run, keep up the good work Will & Co, truly amazing what you guys pull off :-)
Anyone got a good idea for a better tagline/description for this room?
@LasseVKarlsen what about 'there can only be one' ?
15:17
@LasseVKarlsen Anything is better than the current tagline/desc
Agree, let me change it, and please keep thinking about it :)
Also, since I created the room, I'm the only one, except for the moderators, that can change such details, we should probably come up with a couple of more people to keep the room in check
insert coin
Anyone know how to bring up the Asteroids EE? I'm bored. :D
That's the easter egg for the gaming chat site
Ahh, I suppose that would make sense.
You can always visit erkie.github.com and use the bookmarklet there, that way you can kill any site you want
15:24
Damn, chat messages can be edited and have a history? That's not...I don't even...
Ado.net or LINQ ?
@Mishgun_, what're you asking about?
try NHibernate
@LasseVKarlsen what do you prefer, ado or linq+something
Both
They don't exclude one another
2
I tend to use LINQ in my own projects now, but even in those, I have cases where SQL is better to use
Bulk updates for instance
15:28
@LasseVKarlsen ok, thx
is it not better to use sprocs on the DB rather than SQL in your code?
Typically, yes
Higher chance of caching the execution plan
@PiersMyers There are advantages and disadvantages to both. It also highly depends on your other processes (how you use the repo)
@PiersMyers that's a scary question
78
Q: What are the pros and cons to keeping SQL in Stored Procs versus Code

GuyWhat are the advantages/disadvantages of keeping SQL in your C# source code or in Stored Procs? I've been discussing this with a friend on an open source project that we're working on (C# ASP.NET Forum). At the moment, most of the database access is done by building the SQL inline in C# and calli...

and by scary, I mean it always leads to religious wars
interesting
15:35
@TimRobinson - Thanks for posting that. I hadn't checked out "help" yet and didn't realize you could inline SO questions. Excellent feature.
I hate maintaining SQL in sprocs
2
I hate having two languages deployed in two different ways
@TimRobinson yeah, 4 ways is too much
Hi everyone
hello @Anonymous
15:41
i was wondering if i can check in a web service if a method exist or not
hi tim
like a C# method?
bool exists = typeof(YourClass).GetMethod("YourMethod") != null;
cool thanks
thanks @ tim
I have a Winforms GUI question, if there are any experts here that can help please join the 'GUI Phooey' room so I can ask it :)
15:56
Need link. :)
@TimRobinson What LINQ without stored procs leads to is databases which are wide open and tightly coupled to code. If you actually thought about the services your database would be providing and who gets what kind of access to it, SPs are a natural way to implement and describe that interface and allow your database to be refactored (tables partitioned vertically or horizontally) without changing code.

GUI Phooey

User Interface design discussions
@TimRobinson I think the religious wars come from language monoculture bias. I imagine we would see more bias against JavaScript if there was a C#Script available for client-side coding so that people could learn the one and only true language C#.
07:00 - 16:0016:00 - 00:00

  last day (5167 days later) »