« first day (725 days earlier)      last day (4228 days later) » 

12:00 AM
I plan on it. I don't think I like the idea of manual Garbage Collection.
 
That's the least of your worries.
 
I hardly remember to take out my trash, let alone deallocate memory for the variable I used once.
3
 
Me either. Manual garbage collection is for serfs and the like!
 
Undefined behavior everywhere..
@SpencerCole LOL
 
@Lews - want to see undefined behavior? I should post my overloaded version of JavaScriptSerializer
 
12:02 AM
One of the guys at work is attempting to learn to program using machine code.
 
mov ax,bx;
goto: hell
 
Lol
@TravisJ Are you using unsafe code?
 
Er, Assembly. My bad.
 
@Lews - unsafe? LOL, that would be the day... :P
let me get a pastebin to show u the hack going on atm
 
Unsafe code? Need a code condom?
 
12:03 AM
@SpencerCole you probably have to be really good to beat a compiler
 
Well crap, Sim City 4 is already downloaded and I've still got 5 minutes left on Eclipse... Plus installing all the android stuff... Crap.
I'm gonna be installing and playing Sim City 4 at the same time.
This'll be fun.
 
at your own risk: pastebin.com/Efz6FFri
 
lol
0
Q: How to make JavaScriptSerializer ignore [ScriptIgnore] tags?

Travis JI need to make JavaScriptSerializer ignore [ScriptIgnore] tags. I think I can do this with a custom JavaScriptConverter. However, I am not so sure. All I need to do is ignore the attribute, and the rest can be done with the base definition. You can see the code for JavaScriptSerializer here. I a...

 
@Pheonixblade9 Pretty much :(
..
 
12:09 AM
My cat keeps kneading my back. She wants out now, after my door was open ALL DAY, and she's trying to get me to get up. Too bad I gotta tell her she has to wait till I need to go to the bathroom... And I just went.
 
The funny thing is, in .net 4.5 microsoft tried to do what I just did in this customization but they failed horribly and mine actually works
Mine allows for customization beyond ignoring all scriptignore tags. It will allow for ignoring individual tags. It rocks
 
@TravisJ maybe a little late but could an extension method have been sufficient?
 
@JohanLarsson - Uhm, no, because I had to overload the recursive nature of the class
If you see a way that an extension could be used then I am all ears though
This code is ridiculously hard to read
It is one convoluted mess of pure awesome
100% working, freaking sweet
 
write a qouple of tests for that maybe?
 
I tested it with our live data
 
12:22 AM
just so something fails if you touch it by accident
 
this.AddDirective("ParentField", "ChildField",false);//enforce scriptignore
this.AddDirective("ChildField", "ParentField",true);//ignore scriptignore
It worked on a rather complex scenario. So stoked, I have been wanting something like this for a while
 
nice
do you notice difference in performance compared to the std serializer?
 
No, not really. They are both super fast.
It took 900ms to pull out 25 objects in a complex graph.
And most of that was probably from hitting the database
I can test though
@Johan - lol, it took 990ms to get the object graph and serialize it to the view. without serializing it, it took 978ms.
 
ok, not an issue then
 
nah, I am soooo happy lol
I am going to go home early and get a beer
thanks for helping out by pasting that class @Johan :)
Couldn't have finished it without that
 
12:32 AM
np
 
Okay, it's Dishonored time.
See you duders in under 11 hours.
 
I think that I'll go to sleep. Night everyone :)
 
12:45 AM
Night
 
So many things to get working before I can get started with Android... Ugh!
 
1:24 AM
Anyone here understand how/when to use yield return and can tell me if my understanding of it is correct or not?
 
What is your understanding of it?
 
@LewsTherin Here's me explaining it:

Let's say the method `ConsumeLoop()` processes the items returned/yielded by `ProduceList()`:

        void ConsumeLoop() {
            foreach (Consumable item in ProduceList())      // might have to wait here
                item.Consume();
        }

        IEnumerable<Consumable> ProduceList() {
            while (KeepProducing())
                yield return ProduceExpensiveConsumable();    // expensive
        }

    Without `yield`, the call to `ProduceList()` might take a long time because the list is completed before returning:
It's sort of the case where I found a SO question about it and didn't immediately understand the top voted answer
but after reading a few other sources, came to this conclusion, and although the top voted answer makes more sense now, I'm still not completely certain.
 
Brb a sec
I don't think yield increases efficiency in terms of speed.
Without yield, you get all your data at once..
yield return defers execution. Which means you get the data when you want it.
I'm not an expert so I shouldn't be talking :)
 
agh ok
 
You are kinda of correct. Basically, ProductList is entered for each loop, continuing where it left off
 
1:37 AM
Yes, it continues where it left off. Thanks to enumerator. Doesn't make your execution any faster though.
Well I don't see how it could.
 
No, it defers the cost
 
@David that's kind of what I was trying to envision, and it ended up feeling like rearranging the code execution, which is what i was trying to convey with the "pseudo-assembly"
 
It's useful but also dangerous at the same time
We had a fairly large bug in MEF where we were storing the resulting IEnumerable<T>, and iterating over it multiple times
 
I would guess part of the danger is if data has been modified at some point.
 
ie:
var foo = ProductList();
 
1:41 AM
while reading up on yield return, there was this site: dotnetperls.com/yield that talked about execution speed improvements
 
foreach (var bar in foo)
{

}

foreach (var bar in foo)
{

}
 
@DavidKean How's that the cause of yield return?
 
@DavidKean Why would it be dangerous? I thought you aren't supposed to modify enumerables while iterating through anyway
 
It's not about modifying the enumerable
It's that you can end up executing the method multiple times
The bug in MEF was similar to this:
var types = GetTypes()
foreach (var type in types)
{
// Do Something with types
}

...

foreach (var type in types)
{
// Do something else with types
}
and then GetTypes looked like this:
IEnumerable<Type> GetTypes()
{
foreach (Type type in assembly.GetTypes())
{
if (SomeExpensiveCalculation(type))
yield return type;
}
}
Basically, what happens that the entire method executes twice, one for each foreach
If you use something like Reflector to look at the code gen that the compiler spits out, you'll see why this happens
 
@DavidKean just for clarification, the entire GetTypes() executes twice, one for each foreach() { /* Do something */ }
 
1:51 AM
@Kache exactly
We hit this early in MEF, but it was a terrible bug - because it walked a rather large chain of assemblies, looking at every type, looking at every attribute
 
how the heck does the yield work inside that if
 
Basically, the method "pauses" after each yield
and you enter the body of the foreachg
of the caller
until the method hits a yield, it executes like normal
 
oh, okay
so the consuming foreach only consumes the expensive ones, because of that if
 
Well, yeah
 
i'm surprised the yield property persists like that
especially since it's assigned to a variable var types = GetTypes()
 
1:56 AM
The code gen underneath if basically a state machine
*is
When I used to encounter new magic keywords like this, I liked to look at the "real" code gen underneath to see what its really doing
Have you used Reflector before?
 
not in a way that demonstrates I understand what it's really doing
heh
 
:)
how long have you been using C# for?
Do you like it?
 
I'm kinda new as a professional programmer, it's the only language I've used "in the industry" besides a little bit of other stuff here and there
today just happened to be reading up on some functional programming stuff
in short, the topic chain was like: monads -> call-with-current-continuation -> continuations -> functional "equivalents" of goto -> examples in C# -> yield return
 
yes, effectively that's what it is, a continuation
async/await is a very similar concept
These are new keywords we introduced for .NET Framework 4.5
 
I feel like I got a good grasp of continuations, but not so much for call-with-current-continuation
 
 
4 hours later…
5:37 AM
good morning guys!
 
To Parse XML, which one should I prefer, XElement or XDocument? Why?
 
6:09 AM
good morning @RobAngelier
 
6:20 AM
@MRS1367 good morning
 
7:07 AM
Morning fellas :)
 
morning!
 
Good morning
I have a thought exercise
Anyone want to hear it?
 
bring it on :)
 
Let's say you have a Person object with arbitrary properties, e.g. income, shoe size, weight, favorite color.
You have a group of Persons called a Company. This also contains some arbitrary information.
At some point, you find that you need to extend Company to provide you with an aggregation of all its constituent persons.
For example, average income. Most favorite color.
This information will be used at different times in your program.
 
mhmm..
 
7:15 AM
...
waiting
 
Waiting for what?
How do you do it?
 
what??
 
you didn't ask that
 
How do you implement this thing
 
where's the climax of the story
 
7:16 AM
Oh, I'm sorry.
 
you just told me something
:)
 
I was messing around with stylebot
lol
 
Anyway, so how do you do it.
The above extension.
 
7:17 AM
yea, thinking
 
Okay I think I successfully changed the font to Consolas
 
ok, i'll bring in a mindf**k, i heard one long ago
just a sec
 
can't you create another class called CompanySummary and derive it from Company. At the properties you need, for eg. AverageIncome, FavoriteColor etc.
 
Yay, changed the font size too.
Of course you can.
 
domain design not my best practise, but just thinking out loud
 
7:20 AM
But what, do you cache that?
 
aah ok
that's your question
 
You can just have a static method
If you want one
 
are you requesting alot of info?
that would be the main reason for me to cache this
 
It's an operation over the entire group. Many you need to perform a bunch of steps per group.
*per person. And you need to use it at different times during the program.
I mean, let's say you're working with just a List<int> and you want the sum. You would go about calling Sum more than once, right? You'd cache the result.
Well, it's the same thing with Company, except that you need Sum at different times, so you can't cache it locally.
 
for me personally... i'm not caching everything i need more than once, it depends on how itensive the query is.
 
7:24 AM
What do you mean, not caching it more than once?
 
you say that if you have a list of int's and you need to sum them more than once inside your application, you would cache this operation, right?
 
Yup.
I mean, in the context of the method.
 
allright
 
Company is in the context of the application, since its lifetime extends far beyond any method, and so does the usefulness of its summaries.
 
allright. Then you could cache this operation
 
7:28 AM
So you would make a subclass, e.g. CompanyWithASummary, and have a property called Summary that would perform the operation lazily -- just once, and then cache it.
 
yea, i would. If you have just two properties, can't you add them to the Company class?
since it belongs to the company
 
Well, that requires editing the source code and recompiling. And we know that has problems. But wait, what if someone changes the Company? Suzy gets fired, for example. Or Bob gets a pay raise.
 
you should update you cache after these modifications
 
How do you do that? I mean, we don't know how modifications will affect are arbitrary caches.
/s/are/our
 
what platform are you developing for?
asp.net, winforms, wpf
?
 
7:33 AM
It's a thought exercise, not a question :P
 
ohh sorryu
haha
 
morning
 
hey there
 
morning!
it really depends actually
just one sec
 
Maybe I should just write the whole thing down instead of conveying it like this. There is a major point here. Something people miss, and something I realized just yesterday.
 
7:35 AM
hello el
 
I'll give you the short form. If you have an immutable object -- that is, if you know that Company can't change during its lifetime, and that in order to perform 'modifications' you have to create a new instance of Company that includes structural sharing,
you can define and store arbitrary information on every Company object.
You can extend it and let it store information from outside.
You don't need to define a new class of type Company. You just define operation Summary. And it will implicitly store the result in Company. And if Company undergoes a modification, you can adjust Summary because it is an incremental operation.
When company undergoes a modification, I mean, you get a new instance of type Company that is just a bit different, in its constituent persons, from the old one.
Like, imagine you define a normal class Company and leave a special field. A special 'hole' called, I don't know, Hole.
Hole is mutable, but if you assure that you mutate it in atomic and predictable ways according to the rules, using it to store aggregate information on the entire company, it will always be consistent.
 
sorry, a colleque called. started reading now
 
And that, is one of the amazing strengths of functional programming. It's far better than sub-classing. There are no class hierarchies to worry about. All operations are reversible, and you can incrementally deduce the cached result of a given summary by the transition between the old Company object and the new Company object.
 
@GregRos your right. Much better
:)
good to know!
 
lol
 
7:44 AM
haha, it sounds very logical
 
The problem is, that your difficulty is now designing Company itself :P
Designing an object that is immutable but can still be used reliably is tricky, though a lot of information on it exists.
 
i'm not getting the part is tricky to design, can you explain this?
 
Well, remember I said that you can only do this if a particular instance of Company remains the same, forever?
 
since the Summary operation needs to update readonly variables?
 
A summary operation needs to store its information on an instance of Company. But the only way that a single Company can have a real and consistent Summary is if the Company never changes.
Otherwise, the summary can just be out of date. There is no point in storing it. Are you going to try to figure out how Company changed? What if several changes occur at once?
The reason you can store the Sum of a List<int> inside a method is that you know that nothing changed the List<int> after you were done summing it. But that's in the scope of just one method.
Who knows what's going on in the application itself.
 
7:54 AM
okay, that's true.
 
Since Company an instance of Company can never change, if you want to fire Suzy from Company, you need to create a totally new instance of Company.
 
samy hows the memory leak issue?
 
When you fire her, because Summary is incremental, it's also reversible. Computing Summary without Suzy is also simple.
E. L. was that to me?
 
no samy S.Rathore
 
oh okay. I thought you were addressing a memory leak issue in what I was saying :P
 
7:56 AM
you right. Like i said, design is not my best practise :-), so it's good to listen to people that are more experienced in this.
 
:)
 
thanks for the explanation
:)
 
No, this isn't standard practice!
Most people don't do it like this :P
 
then i'm already ahead of them after today :P
 
Anyway, there is a lot more to say. Maybe I'll write something about it.
 
7:57 AM
you should
 
8:15 AM
Morning, can someone provide me best tutorial for c# string manipulation and should be in detail
e.g. if string username = "domainKeepChanging//UserNameRandom"

then how can I get just userNameRandom I need tutorial on it please
 
Regular Expression is what you are looking for i quess
or just a simple string.split
on the "//"
 
cheers, i give it a try
 
8:41 AM
           string a = "dddddddddomain\\userrrrrrrrrrrrr";

           string[] ama = a.Split("\\");

            Console.WriteLine(ama[0]);
doesn't work :(
 
i think you need to escape those character, not sure though.
string[] arrResult = strUsername.Split('\\');
try this
 
@TimeToThine I believe \\ becomes \
Not sure.. Ah nvm
 
8:56 AM
Hi all
 
hi @MRS1367
 
Hi @RobAngelier
@RobAngelier -> I need help
I hope that you can help me in my new problem
 
we both hope
whats up
 
@RobAngelier Lol
 
I add an expandable property to my custom control.
 

« first day (725 days earlier)      last day (4228 days later) »