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

4:00 PM
@CadeRoux I would agree except when it comes to Cloud architectures there are some things that you're forced to handle in code. For example, you cannot link one Sql Azure DB to another. That means your sharding/distribution strategy must be in the code.
 
I didn't know links to rooms did that

F#

let rec stack x = overflow x and overflow x = stack x
 
@Cade Roux erm Silverlight? isn't that c# on the client side?
 
@TimRobinson There's plenty of sites, including this one, that will "onebox" an url, pulling in some information and making it look good
 
sure, I just didn't know about links to rooms :)
 
4:07 PM
@Vyrotek Of course, there are exceptions - as soon as you are going across database boundaries, you are going to have chaining permissions issues even in the traditional environment.
@Vyrotek Of course, that also means distributed transactions etc. But the fact that the perimeter of a "database" is the unit of backup and integrity need to be kept in mind from an architectural point of view. I still would define each database's interface only in terms of sprocs/views/TVFs and use LINQ against the result sets.
@HollyStyles Indeed. Silverlight's uptake is slow. JavaScript mustn't be hated enough yet. It's also still procedural, whereas SQL is declarative and the cognitive dissonance is larger. I personally like to have the separate contexts - SQL for DB, C# for systems architecture, JavaScript for client execution - it makes things clearly layered.
 
I am reading CLR via c# and the author feels properties is not a very good feature, and how often you use it in your code? I'm new to c#
 
@yesraaj "not a very good feature" - where does it say this?
virtually every .NET class I've seen has had a property on it
 
mornin
 
Properties are great to use. Directly accessed public fields are not.
 
One thing I don't get about C# automatic properties, is there any way to access the underlying private field?
 
4:16 PM
@pnewhook no
if you wanted to see the field, why would you make it an automatic property?
 
You can access the field, but it's more work, and slower code, than just making it use a backing field to begin with
 
The field can be accessed? Eenteresting.
 
@TimRobinson pg242, under heading Defining Properties Intelligently, thought it's authors personal opinion
 
@Chris it's just syntactic sugar
the field is still there
 
The field is added through compiler magic
So it is there, it has a funky name though, but you can reach it using reflection
 
4:18 PM
@Tim but then why not just use a public field?
 
@yesraaj the Richter book? Which chapter?
@pnewhook because fields and properties aren't the same thing
9
Q: C#: Public Fields versus Automatic Properties

I. J. KennedyWe're often told we should protect encapsulation by making getter and setter methods (properties in C#) for class fields, instead of exposing the fields to the outside world. But there are many times when a field is just there to hold a value and doesn't require any computation to get or set. Fo...

 
@TimRobinson It's Ch -10, Properties
 
Anybody ever write a winforms app which consisted of nothing but partial classes to "Form1"? Seems to work well for a small app...
 
gist: Dumping fields, including backing fields for automatic properties, through reflection, 2010-10-15 16:21:08Z
void Main()
{
	Test t = new Test { Text = "Test" };
    t.AccessFields();
}

public class Test
{
    public void AccessFields()
    {
        foreach (var f in GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
        {
            var value = f.GetValue(this);
            Debug.WriteLine(f.Name + " = " + value);
        }
    }
    
    public string Text { get; set; }
}
Outputs:
<Text>k__BackingField = Test
 
@yesraaj I see - it's chapter 9 in my copy
@yesraaj Jeffrey Richter is definitely in the minority here
@Suan as opposed to?
 
4:22 PM
Which page?
 
bah, I've put the book away again
towards the end of the chapter on properties - "Defining Properties Intelligently"
 
@Tim, I dunno, a more "better practice" way such as using the MVP pattern or similar
 
In "CLR via C#"?
Ah, found it
 
@Suan sure, you could use MVP, but nobody's forcing you to
 
Ok, I agree, that is, I disagree with the sentiments he's posing in that book
 
4:26 PM
@TimRobinson Sure, just wondering how often it was done... you get the benefit of source code organization without the overhead of having to actually refactor your code... :P
 
And to be honest, I personally don't like it when people say "don't do X", and don't care to say what they should use instead, he's apparently not doing that
 
@LasseVKarlsen C++
 
What?
Use C++ instead of properties?
Isn't that like, use a car instead of eating an apple? That's not even the same thing
 
:)
Jeff Richter comes across as a real low-level guy
which is great for a book like "CLR via C#"
 
Sure, and I both disagree and agree with some of his sentiments
 
4:27 PM
@TimRobinson Thank tim, that clears it up
 
I'd read a different book for advice on OO design
 
The fact that you have something that looks like something else, is bound to cause confusion
But, to be honest, I think people would be more confused to find a class that has lots of public fields than one that has lots of public properties, in .NET
 
Anyone else's screen flashing for new messages?
 
"flashing"?
 
flashing white
 
4:28 PM
What browser/version?
 
I have Chrome, and the tab does that Chrome flash thing for new messages, if that's what you mean.
 
FF 3.5 Win
 
I believe it does that when it detects that the title of the page has been changed without a reload, never bothered to confirm that though,.
 
@Skawful I have FF 3.6 Win and it's not "flashing"
 
Anyone knows where I can find list of current C# MVP's ? List + links to their blogs would be awesome (mvps.org/links.html have one but it doesn't seem to be updated / complete)
 
4:39 PM
FF 3.6.10 / W7. Flickering like mad here.
 
@ChrisSmithzzZZ What you seeing?
 
I think there is an issue with FF and the right hand side panel
 
@CadeRoux Occasionally the display flickers when refreshing. Almost like the send button doesn't veto the event and refreshes the page.
 
I see the right hand panel update, but I wouldn't say flashing.
@ChrisSmithzzZZ I just saw one, but it's not happening with any regularity - the RH panel is updating, but not flashing.
I'm not sitting on the tab though - I've got other work going on on this and other monitor...
 
Ok - sure it'll get ironed out in time :-)
 
4:47 PM
it's a CSS bug in FF3 as far as I understand, maybe it will be fixed in FF4. There was a tweak you could do using Firebug but it meant the right hand panel was at the very end of the page but it no longer flickered
 
5:19 PM
@kyrisu this looks up to date: mvp.support.microsoft.com/communities/mvp.aspx
 
oh woaw
we have chat
with code blocks?!?
>>>>> IRC
 
@LouFranco thx.. somehow I missed this list on the site while I was googling it with bing ;)
 
@kyrisu Re MVP; it is not compulsory to be listed: opt-in in fact
 
5:49 PM
Is it possible to serialize an object with it's type data and then deserialize it back to that object without knowing the type? I'd like to use the DataContractJsonSerializer if possible.
 
if you use javascript serializer to create/consume the json, you don't need to know the type
the object will just be a bunch of object and object[] types, but if you already know the structure you'll be okay
 
You know what I love, Extension Methods
 
it's not optimum, but it seems like it's what you need
 
well I thought I had seen the serialize put a {__type : "mytype"} field on the json object before.
 
maybe. i can't say from actual experience
serialize your object to a file and look at it
 
5:56 PM
@msarchet: at first I thought: heck.... monkeypatching!
But then: it gives a great way to create a core functionality class, and extend it with loads of utility functions.
Without having to touch the class itself, hence not introducing any bugs.
 
@xtolf Or doing little things that just hide complicated pieces of code, aka Abstraction
 
@msarchet: how did you manage to mistype xtofl :)???
Hiding complicated pieces of code, though, can be done using... functions.
 
@xtofl which is all an extension method is, sometimes typing PhoneNumber.IsValidPhoneNumber is better than IsPhoneNumberValid(PhoneNumber)
 
I'm not sure I ever met an extension function I didn't like. Handy, those things are.
 
That's right: but still, it's syntactic sugar. Sweet.
But some places you simply complicate things unnecessarily using member-method-like syntax, like max( a, b ) looks much worse than e.g. {a,b}.max(). (Not that that's valid C#, though, but you get the point)
 
6:06 PM
i've defined an interface called IHierarchical<T> - its members are T Parent and IEnumerable<T> Children - and then created the extension methods GetAncestors(), GetSiblings(), and GetDescendants(). I cannot tell you how useful this has turned out to be.
3
 
@xtofl It is syntactic sugar but it enforces a little more than functions do
 
Hmm, SO-Chat needs some syntactic coloring for usernames. ;-)
Do you get rep for starred transcripts?
 
@choudeshell ha, I wish
 
@Vyrotek You should have the __type property in your JSON representation if you're using the standard ASP.NET serialization, which has the fully qualified type name. So for a DataTable, it's __type: "System.Data.DataTable".
 
@WesleyJohnson So using JavaScriptSerializer or DataContractJsonSerializer won't add that?
 
6:22 PM
@Vyrotek Whether or not you can do - "var myObject = new JavaScriptSerializer.Deserialize( JSONReprsentation )" without knowing the type, I don't know?
@Vyrotek Good question, I don't know off the top of my head.
 
NetDataContractSerializer and BinaryFormatter include the type meta, which is exactly what is wrong with them :)
IMO, much better to always know what you are meant to be processing before you start.
 
Perhaps I should back up and ask the real reason I need it. Basically I'm serializing multiple types of objects to a string to stick them into the same Queue. But when I pull something out I don't know what kind of object it was.

So the hack I'm doing right now is prefixing the serialized data with "MyType|" + json data.
 
2
Q: JavaScriptSerializer with custom Type

balintHi, I have a function with a List return type. I'm using this in a JSON-enabled WebService like: [WebMethod(EnableSession = true)] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public List<Product> GetProducts(string dummy) /* without a parameter, it will not go through ...

 
And that doesn't mean you need to know the type - but the contract must match.
If the set if types is finite and known, any serializer that handles inheritance might help. Pesonally I'd go pb-net plus base-64 since you want a string, but i may be biased
 
7:11 PM
Biased doesn't mean incorrect :)
 
To easily test C# code in a web browser, try DotNetPad.
2
 
nice one, good to know
 
Thought I'd mention it since the current highest starred message was a download :)
 
LINQPad is what I use too for testing snippets
but then again, it's great to have something there on any system
 
@DanielJennings very nice, but I can't write code without syntax highlighting and autocomplete :)
 
7:21 PM
that is one failing of C#
you're not supposed to need an IDE
 
failing of C# or a failing of being brought up on VS?
i say that being guilty myself...
 
yeah, I can't add up without a calculator, can't write without a wordprocessor and my hair won't dry without a hair dryer :)
 
I should probably say .NET, not C#.. I can write simple stuff just fine without VS
same story with Java
btw, is this chat thing going to eventually show up on Google?
 
oh hair... those were the good old days (heh)
 
@TiberiuAna probably, everything else does
 
7:25 PM
nasty, gotta keep it to the point then, kinda kills the conversation
IRC ftw
 
A lot of IRC ends up on Google, too. It's not as if StackOverflow invented channel loggers.
 
IDEs are productivity tools.. nothing requires an IDE
 
@BenjaminPollack it's a matter of having my full name in here versus a random nick
 
Yeah, I don't get the arguments here
I can write code in notepad, if that's what I have to do
But it is easier and faster in a tool that produces syntax coloring and intellisense
 
any horribly long-winded framework pretty much asks for an IDE
not that it's impossible to use it without one, but still
 
7:29 PM
@Lasse agreed; also easier to grok an api (at least for me)
 
@TiberiuAna Ah yes, the Facebook Conundrum. :)
 
@Tiberiu - use any name (within reason) you like; just update your SO profile
 
unless you are insecure about how smart people think you are... but then you should probably stick to man pages and stop using google too ;)
 
Intellisense (I know this is named differently to people with different IDE's) is about both speed (help me complete the words) and discoverability (what does this object have of members)
 
7:30 PM
Are a lot of you .net programmers or something else?
 
Ditto refactorings; doable by hand, but mechanical; let the CPU do it
Well this is a c# room...
 
a framework is mostly just code preventing you from re-inventing the wheel. you can roll your own... if you think that makes it less "long-winded"
 
@obsoleteModel81 not much else you normally use C# for
 
refactorings are also easy to mess up...
 
Yep, I absolutely love ReSharper 5
 
7:31 PM
i let resharper save me from myself
 
refactorings are for the weak :)
 
Actually, I beg to differ
Refactoring code is a bold move, you trust that you won't screw it up
So I postulate the opposite: Refactorings are for the brave
 
indeed, you need a lot of trust in the IDE to refactor correctly
 
Of course, brave is sometimes followed by the foolhardy
 
as long as you have unit testing to back you up
 
7:33 PM
if you have no unit testing in place...
 
And you need a lot of trust in your unit tests to ensure it did it correctly
 
It is also good practice re keeping clean logical manageable code, rather than letting something grow and rot because it looks hard to change
 
... but I see we're on the same page here :)
 
hard not to be, unless you argue that the dirty way out (no unit tests, etc) saves enough time to be worth it
the duct tape programmer stuff
 
Well, there's a fine balance to be reached :)
I've met programmers who seemed to think unit tests was more important than production code
to the point where they didn't actually meet their deadline
but golly, did they have high code coverage on their unit tests
 
7:37 PM
well recently I've been doing a lot of CRUD applications and I still haven't figured out just how far I'm supposed to go with testing
setting up a test database vs ignoring database access which is half of the whole app
 
isn't that where mocking comes in so handy?
if you have to set up a test db you're likely in the realm of an integration test
 
Also depends on sector. Banks, factories, etc need more CYA for when it screws up, so it can't be argued professioanally incompetent
Or negligent
 
Speaking of IDEs, anyone ever have an issue with VS2008 locking up when opening a project in a solution file?
 
right, but when you're dealing with things like dynamic SQL or creating/removing database objects then what do you mock
if I abstract the whole database layer, I'm left with nothing to test
 
7:42 PM
Cover Your Ass
 
repository pattern + linq makes it trivial to abstract the database
 
your business logic shouldn't be in your database layer..
 
linq + repository pattern is a god send
 
and w/ interfaces, you should be able to test it independently also
 
yup
 
7:45 PM
exactly
 
To post code, use Gist, to test C# code locally, use LINQPad, and to test C# code in a web-browser, use DotNetPad.
61
 
inversion of control!
 
@markt not so easy, you can't just bring half the database over to your business logic and only then go about it
also, stored procedures are business logic, aren't they?
 
depends what they are doing, if only simple CRUD then likely no...
 
depends .. why would they need to have logic ? shouldn't they just perform isolated functions, while your business logic manages order or instructions, orchestration, etc
 
7:47 PM
@Jimmy Ever? The last job I worked at had some relatively complex stuff (as least I think) going on for business logic and it seemed like the database was the easiest place for it. Of course, everything was in the DB there because the code was around since classic ASP, but I digress.
 
the difficulty in testing SPs and the logical (?) separation between them and code is a large part of the reason why I try not to use SPs for anything complex
but, as with everything, there are exceptions to that... some processes are vastly easier/faster to do in an SP
 
I know people who claim the exact opposite, no SQL in the application, all of it in SPs
 
@TiberiuAna, I'm working on an application like that right now :/
 
of course that also leads to a big mess if applied fanatically
 
that's not a valid choice: you don't have to have SQL in the app or SPs
 
7:50 PM
It's very small scale currently, but the number of SPs is growing and making me sad
 
@TiberiuAna I feel like I would prefer that as well (everything in SPs), but I've never had the pleasure of working on a properly tiered .NET application with no SPs and everything in code.
 
another thing that I find difficult is keeping the database objects under (source) control and the database itself properly versioned between multiple people
 
At my last job they required everything to be done in SP and had DBAs sit and review every SVN commit to review the code and reject it if was bad. It was complex stuff and there was no way we could have had our SQL reviewed had we kept it all in code.
 
Can I just say how pleased I am to see this proactive (rather than reactive q&a) programming conversation. Makes it all worthwhile. Thanks folks.
 
7:51 PM
Wes, try out some asp.net mvc with some linq to sql goodness
 
and to complete the picture, TSQL is a bit of a straight jacket
 
haha
 
@MarcGravell I'm sure there will be plenty of Q&A too
 
Jimmy, I'd like to on my next project.
 
I think the chat is a great new feature
it's a breath of fresh air
especially moving from webforms and the page lifecycle
 
7:52 PM
some way of threading live chat would be great for support channels
where a question can get lost in the noise
 
@TiberiuAna I prefer SQL to be code-genned, complex SQL to be maintained and versioned in the database by dedicated SQL developer/DBA. That defines the interface to the database. The role security etc can be done on the SPs. Gives you a good solid understanding of what data is consumed where by what. The database matures much more quickly than the app and data lives forever.
 
@Jimmy wasn't LINQ to SQL supposed to be on its way out?
 
Never heard anything about that?
 
Last I heard, EF4 and L2S were to be maintained side by side, at least for now
 
the opinions seem to be split on this one
but then again WPF was supposed to be dead too :-)
 
7:55 PM
haha
 
@CadeRoux that might work for large projects, but I can't see how it would apply for a small web app split between 2-3 people
 
I wouldn't like to see linq to sql die out, I much prefer it to the entity syntax
 
SP ?= Serivce Provider
 
My friend works on the EF team and keeps telling me to drop LinqToSQL. I told him not until he finally add Enum support... I guess its coming soon.
 
I work with large third party databases that I have no control over, I guess I'm not in the main ORM target audience
 
7:57 PM
SP = Stored procedure
 
@TiberI bet you could bend NHibernate to your will
 
@Jimmy - Thx
 
@Vyrotek, I worked with entity framework doing some enhancements on a recent project, I did like some features but the syntax just seemed off-putting to me compared to linq2sql
 
@TiberiuAna I do it on last two-developer projects. Code in SPs, list of SPs in the app.config. We had no control over the underlying data warehouse, we had processing SPs and control SPs. The processing SPs performed all the millions of rows of processing. The control SPs launched/monitored all the jobs etc, the client front end used them to monitor/control.
 
@CadeRoux all T-SQL SPs or CLR objects?
 
8:00 PM
@TiberiuAna It takes a bit of discipline, just like splitting client-side and server-side code in ASP. Also, I think a lot of people are simply scared of SQL, they aren't as confident in their skills with it.
 
hmm, I wonder whether you can even do CLR SPs
 
@TiberiuAna All T-SQL, CLR was not allowed. If I had complete control of the architecture and database at that shop we would have used SQL Server Agent jobs, but the front end app was still necessary for nice graphical control of all the dependent processes.
@TiberiuAna As far as the unit-testing, this was a case of data regression testing each month, so it was straightforward - real-life production data testing after every change, run after run after run.
 
it does sound like Big Project stuff
 
Howdy, all.
 
@JonErickson lo
 
8:07 PM
Has anyone seen Jon Skeet today, in chat I mean?
 
@TiberiuAna I guess so - it was a lot of data (already provided in the data warehouse), but small team in terms of our project.
 
Saw some chatter about nhibernate; who else also needs to have fluent nhibernate in that same mix?
 
I'm just learning c# and I'm converting over some code from VB.Net to C# and I noticed that Page_PreRender isn't on the drop down of events on my C# page... Do I have create that manually or is there a trick to adding it (or should I use something totally different)?
 
@JeffV probably just wasn't auto generated when you created that page
just defining the method (and making sure AutoEventWireup=true in your markup) should make it work
although i don't really like autoeventwireup
 
so it is supposed to generate when a new page is created?
 
8:13 PM
from what i remember all VS does is generate Page_OnLoad for you
 
Yep. :)
 
Page_OnlLoad was there.
 
my preferred workflow was to override the event raisers
OnInit, OnLoad, OnPreRender, etc
and then OnInit is where you would explicitly setup event handlers for your controls (btnBlah.Click +=)
properly using DataBinding is going to be the best thing you can do as web forms dev
 
k - thanks
 
yeppers, good luck!
 
8:23 PM
Can rep be given/lost in chat?
That would be kind of cool, in regards to answering questions etc
could lend itself to abuse
 
not in the sense you're thinking.
 
only one way to find out! tries to nuke jimmy
 
but you can lose rep due to spam/offensive flags i believe.
 
yeah probably
just curious
 
@rchern I've added you as room-owner since you don't appear to be a moderator. This is not to say that you will be the only one we add, but since I'm about to log off, I thought it prudent to add someone I trust for the time being :) We'll figure out who else will function in this respect as this room grows.
 
8:31 PM
hehe i'm only a mod on WebApps, not on SO (:
 
That smiley always makes me think of Hayao Miyazaki, or rather his movies
is a Japanese manga artist and prominent film director and animator of many popular anime feature films. Through a career that has spanned nearly five decades, Miyazaki has attained international acclaim as a maker of animated feature films and, along with Isao Takahata, co-founded Studio Ghibli, an animation studio and production company. The success of Miyazaki's films has invited comparisons with American animator Walt Disney, British animator Nick Park as well as Robert Zemeckis, who pioneered Motion Capture animation, and he has been named one of the most influential people by Tim...
For some reason, the (: smiley makes me think of someone with a very wide smile, whereas :) doesn't, not in the same way :)
Anyway, g'night
 
8:56 PM
Seems like the chat slows down when people start heading home from work (5 PM EST), hrm...
 
still here.. working in the west ;)
 
same, "working"
 
Seems like the chat slows down when people start heading home from work (5 PM EST), hrm...
 
9:32 PM
still have half an hour to go here.
 
hi guys
 
howdy
 
9:47 PM
Hi guys, anyone know of a good xmpp library that allows you to use anonymous sasl login?
 
Damn, chat is working!
 
@Newbie, this is a bad thing?
(;
 
I need some advice on getting the time difference between overlapping days....i have two time stamps Process Start : 23:58:26.734
Proces End : 00:01:10.609
Process Difference is -23:-57:-16.-125
 
TimeSpan class has the - operator defined, should be easy
- means "minus"
 
10:02 PM
even if i have to subtract 00:01:10.609 - 23:58:26.734
 
if you don't have to worry about time zones, DateTime, and TimeSpan are actually pretty good constructs
 
yea cause i dont have any dates just pure time
 
what type are your "timestamps"
because that is going to make all the difference
 
these are just strings in a log file
 
DateTime start = Convert.ToDateTime("10/15/2010 23:58:26.734");
DateTime end = Convert.ToDateTime("10/16/2010 00:01:10.609");

TimeSpan difference = end - start;
Console.WriteLine(difference);
 
10:04 PM
aahhh yeah, you're going to want to record not just Time, but Date as well
so that you can later parse and compute like @rchern just pointed out
 
yea thats the problem
there doesnt seem to be any dates
so i dont think i can perform that conversion
would it be easier to define lets say a midnite timedate
 
oh, you don't have the dates?
 
you don't have control over how these log files are generated?
 
then subtract 23:58:26.734
no
 
weak
you're going to have to figure that out yourself
 
10:06 PM
could i do (midnite datetime) - 23:58:26.734 + 00:01:10.609
 
then what's to say there isn't an additional 24 hours in there?
 
yep exactly
 
oh ok
 
or even an additional 72 hours?
 
err i figured that was gonna be rough
 
10:06 PM
etc
 
go yell at whoever is generating those log files :-)
they are worthless
 
haha ok
 
you tell them someone on the internet said they are WRONG
if you're curious though
 
Duty Calls
2
 
this isn't going to help you solve your current problem, but it might be useful
my friend wrote a little date time library thing just for funs : github.com/kevingorski/NDueTime
might be some good stuff in there you don't know about yet
and @rchern that is exactly what i thought of
 
10:08 PM
awesome thanks alot
 
testing
 
ill take a look at it
 
yeah man, good luck!
 
how's anything going to help without the date part?
 
in that link? oh nothing will :-)
but i figure can't hurt to expose people to neat stuff!
that whole thing is interesting though
the "tell them they are wrong thing"
 
10:17 PM
@ecoffey you are wrong.
 
:-P
i think you and i talked about this the other day @bryanwatts
as nerds we generally have a hard time accepting stuff at face value, and like to reason through it and convince ourselves one way or the other concerning its validity
but somewhat paradoxically we get really annoyed when others don't accept our assertions at face value: "but i did all the thinking for you! just swallow the damn pill and agree with me!"
 
well, I trust my ability to reason
yours, not so much
:-)
 
exactly though!
you know you can reason!
but you have to trust that i can based on my external behavior!
how annoyingly convoluted!
 
10:49 PM
I can change my behavior and approach to a problem, but I can't change yours. Refactoring your worldview is a lot more expensive when others are involved.
 
11:45 PM
Ninjas are cool.
 
I wouldn't know, I've never seen one. ;)
 
Derp Derp Derp
I'm not sure I like this interface
Joel is in the house
 
hi Joel!
 
Definitely like the user icons on the top right
cool idea
 
don't mind me
 
11:51 PM
where was that ignore link again?
q:
 
hah
I wish I had a c# question
to ask here
So did anybody read about the rumor of MS buying Adobe?
I wonder if there is any truth to it.
 
07:00 - 16:0016:00 - 00:00

  last day (4932 days later) »