« first day (836 days earlier)      last day (4095 days later) » 

2:00 PM
well, string interning consumes ram in a particularly dangerous way: it's not garbage collected.
The advantage is that comparing two interned strings is very fast (pointer comparison only required)
and it can save memory if you end up getting lots of copies of the same string from different sources.
typicial example could be something like html parsing - there's only a limited number of html tag names, so if you intern all the tag names, they can each share a copy of the name., whereas if you just keep the substring from the parse, you've got tons of copies of identical tag names.
 
@Magikarp As am I, just having trouble with many to many query
 
Hi, does anyone know if its possible to have following file structure
Root/Sources/Main.cs
Root/Projects/HelloWorld.csproj (any .proj actually, i use vs only for managing files and intellisense)

i dont know how to add references to source files so that they wont be only link (then i cant rename them)
 
@Kayra If I had a many to many relationship database I normalize it so you got a 3rd table with a 1-to-many relationship with the 2 tables
 
@SteffenWinkler it's probably good advice not to use interning unless you really know what you're doing.
 
@Magikarp The databases are fine it's just querying them
0
Q: Code First Many to Many query

KayraI have a code table: public class Code { [Key] public int CodeID { get; set; } [Required] [StringLength(30)] public string Title { get; set; } [Required] [StringLength(150)] public string Description { get; set; } public DateTime DateAdded { get; set; } ...

 
2:14 PM
@Kayra mmm maybe this will help:
 
@Magikarp how often do you use "splash"?
 
@Neal as often as i can... nothing happens though. nothing gets impregnated. if you know what i mean
 
hmmm idk if I do.
 
@Neal splash = wank off
 
ahhh haaaa..
 
2:19 PM
goddamn are even my jokes ineffective?!
 
It seems.
 
Neal is grass
 
@Kayra eh?
 
@Magikarp i got a joke for you
What separates men from animals
 
@EamonNerbonne well it seems like that strings that are combined aren't interned?
 
2:22 PM
@Cylen lemons
 
@Cylen the mediteranean sea
 
lol magi, thats the non pc answer!
"Divorce"
 
lol kendall
 
2:25 PM
@Cylen :D
 
:)
 
@Cylen someone was watching community
 
RSPCA would have been a better answer ;)
 
i prefer mine
 
Didn't quite help Magi but thanks anyway
 
2:32 PM
@SteffenWinkler indeed, they're not. But you can explicitly intern them anyhow - which I'd recommend not doing unless you're well aware of all the consequences (and even then only if you need to). Memory leaks are nasty.
 
@EamonNerbonne yeah, when I read the article first, I thought that every string got interned. I'm still not that happy about how it is but at least it's not as bad as I thought it was
 
@SteffenWinkler Well, what's the problem with the status quo? In practice, few people ever explicitly intern, so it should never cause problems - it's mostly used internally, for e.g. compile-time string constants.
Hey, I'm experimenting with an in-C# technique for quickly making small html fragments. But it's a bit of a matter of taste as to the right API. What do people think of this?
Fragment.New
    .html
        .body
            .div["asda asdf"]
                .span._id("someid")._class("asdasd")[
                    "asd"]
                .End
                .b.i["asdfasdf"].End.End
                [fragment]
            .End
        .End
    .End;
 
ugh. html.actionlink is stupid
 
this is something else - it doesn't emit a string, it emits a compiler checked type. So, e.g. if you forget to nest correctly, you'd get a compiler error, not a runtime error (or worse, no error at all)
behind the scenes it uses generics to keep track of the nesting level
unmatched tag openings or endings aren't possible.
 
interesting idea @EamonNerbonne
 
2:42 PM
Yeah, I'm just kind of curious about first impressions
I mean, the syntax isn't ideal, but you're restricted by C#, so there's only so much you can do.
 
Eve
What are those, even, ExpandoObject properties?
 
no, they're real properties...
 
i dont really like that style. I'd rather use templating like razor's engine myself.
 
well, the problem with razor is that it's all-or-nothing
if I'm in an MVC context - OK, it works!
 
it works without being in an mvc context.
 
2:44 PM
but very unhandily
 
look at the razor.engine project, i think its called.
 
nothing like this
 
how so? you give it a template string, and a model, and off it goes.
 
Lot
s of problems
 
it doesn't give you compile time checking for the markup like your method describes though
 
2:45 PM
first of all, it's not type checked. You can easily make invalid nestings, and I've seen it happen, and it's often not obvious
then, it compiles into an assembly
 
yes, thats all true.
 
this is like string interning - a memory leak
It's also a slow process
 
Ok then
 
Then I still can't easily mix and match
like, I'd want to call a template from code
without needing a seperate file, or needing a seperate assembly
 
you asked my opinion. I gave it. I am not saying your idea is terrible. You don't need a separate file for your template. its just a string.
 
2:47 PM
Well, but that's even worse - you don't even get syntax highlighting
But thanks for the feedback
I'm honestly not sure what to do
 
It's just a bit of a mess
I really wish razord were more like VB's XML literals
 
id say don't reinvent the wheel. if you want that style syntax, look at the haml engine.
 
@EamonNerbonne look at CL-WHO in common lisp and consider doing something like that in F#
 
F# has the scarily complete looking WebSharper
but I'd need to use this in projects that are already C#
the whole point is for it to make little bits of html
that I can later reuse
 
2:50 PM
@EamonNerbonne you can reference F# from C#, F# is a .NET compliant lang
 
sorry for interrupt :S
I asked a question about wcf about a hour ago.
but no one answered!
my question is in the following link
Thanks :)
http://stackoverflow.com/questions/14583936/wcf-upload-stream-the-remote-server-returned-an-unexpected-response-400-bad#comment20356216_14583936
 
Yeah, I know - and F# is definitely a better language for this kind of thing
but I'm trying to see what I can do with C# so it's usable by other devs
But I guess the consensus here is: don't do it.
 
Well it depends, I wouldn't say don't do it even if you end up in a dead end you will have learnt something
 
thats true.
 
2:53 PM
But also time is money :)
 
there is also the fact that some people DO want that sort of API. The people here just don't happen to be the ones that do
and this is a VERY small segment of the population.
 
of course
but better than just me alone :-)
 
someone someplace would die to have that as a viewengine in mvc, im sure of it.
 
I'm not too worried about the time - I wrote a PoC in about an hour, and the technique works.
it's really simple, really.
 
Most leaps forward are dismissed out-of-hand only realised as sparks of genius much much later
 
2:55 PM
Yeah, but I'm particularly interested in using it where MVC is not an option.
(i.e. outside of IIS)
 
You mean outside of ASP.NET
 
you are. but if you get the markup writer out of the way, post it on github so that someone can turn it inside of a viewengine.
 
and given that I don't particularly want to need a heavyweight razor engine with interop issues for something as trivial as marking up a bit of text.
 
im just saying release your lib as is on github, explaining what you used it for, and what it does. someone will fork it and build a view engine out of it.
thats all
 
2:57 PM
I think I'll give it a shot. Worst case I'll lose a few hours.
(in case people think these ideas are interesting, there's also sharpdom.codeplex.com or citylizard.codeplex.com)
 
same kind of thing?
 
Yeah, but they have a little nicer syntax, a little worse intellisense, and need you to inherit from some abstract base class
 
that last one is the dealbreaker for me.
 
yeah, that's the reason I'm hesitant
but basically, that's exactly the problem with razor too :-)
 
yeah you have to inherit from viewpage
sorta.
 
3:00 PM
yeah
and then razor goes on to reinvent lots of wheels
 
you technically don't have to. thats not the templating, thats the viewengine.
 
instead of functions, you have html helpers
instead of objects you've got user controls
 
again, thats the viewengine. not the templating language
 
all of which makes it rather complex for integrating into something that's not necessarily primarily a view engine
sure, but if you mean purely the syntax, then aren't you missing those features?
 
maybe. it depends on your use case.
if all you want to do is write out slightly templated html, then thats a fine use case. you could slurp your razor files into resource strings if you wanted to.
i don't know how much of the tooling you'd get that way though.
 
3:03 PM
no, I'd use it for a complex user interface with lots of dynamic behaviour
 
who is your targeted template builder?
 
C# devs
some people who know html fairly well, others don't
 
if its c# devs most will be comfortable with your syntax.
 
the typical case would be some generic user form that was written with strings in mind
and now upgrading that to support html content
 
if its c# webdevs, then they will be comfortable with razor.
 
3:07 PM
so it's still generic, and it's still mostly in code
it's basically view-prepping.
scaffolding?
anyhow. that :-).
I'm sure they'd be comfortable with razor
 
or haml or whatever. :)
 
but the problem is lots of library calls assume that whatever the dev wrote fits into a paramater - a string, an XElement, an html fragment - something.
and razor doesn't play nice with that
it renders tag soup - which is fine if your output isn't processed further, but not so fine if some other dev wants to append something in some generic format and re-escapes the tag-soup or forgets to escape his new addition
 
indeed
 
it's just not a nice abstraction to work on. Ok for output, not so much for intermediate processing.
 
yeah, there's truth there
 
3:12 PM
so e.g. the current application has a bit of generalized security processing that actually inspects the html tree and ensures no scripts or other dangerous tags are in it.
that would be very hard to do with razor since there's no intermediate tree.
 
yeah, with your method, you can walk your object graph before output
 
So I want to replace the legacy stuff (XML) with somethign a little friendlier, but razor just is not quite there.
 
that makes more sense
 
I wish it were, since it has the huge advantage of the vast microsoft platform that supports it well
anyhow, that's the background - replacing xml+xslt with somethign else.
 
people don't want to work with a dom in html.. even though it is. i think the js api for the dom left a lot of bad taste with people.
I can understand that to a degree. I want full control over my markup. I had too many issues with first webforms, and even now HtmlHelpers suck in a lot of ways.
there are a lot of abstractions for that kind of stuff that do not give you enough control over the html generated.
 
3:20 PM
(brB)
 
Hey all any tips on binding WPF to a list of dynamic objects - binding works fine for exisiting objects but when I try to add a new item I get "Property path is not valid on ExpandoObject+MetaExpando"
 
3:50 PM
@ChadRuppert yeah - I want that control too. But I don't need control over the syntax. Let me make "invalid" html or use attributes the system doesn't know of; but let the system handle the well-standardized stuff like serialization.
Oh, and finally there's one more (big) reason I'm not willing to invest in razor
 
yeah, that works.
 
And this one's a biggy (for me):
I don't think it's the future.
We've just deployed our first few single-page applications
 
its more the future than webforms syntax.
 
so, json-api's, almost all html generation client-sied
 
yeah, i do that when i can as well
 
3:52 PM
and that's just so much better all around, I think we'll end up doing that everywhere.
So then the goalposts shift a little
 
entirely.
 
sometimes I want to embed a little html in the api response
e.g. marked-up text such as this very post.
 
i gotcha.
 
and if I generate that markup with razor...
it's very hard to embed in a Web API.
 
I asked this earlier, and I'm going to ask again. Anyway uses/used Junnark AspxFormsGen 4.0 ?
 
3:53 PM
@AndréSilva not me
the name sounds interesting though.
 
A lot..
I don't want the trial version and I can't afford the paid one.. I wanted to know if anyone had any "experience" with that..
 
ah
@ChadRuppert So the last webapp I wrote ended up using razor exclusively to embed Json in the html. That's it! The rest was pure Knockout (lovely lib, btw). And hence this whole saga of html generation - because razor was mostly in the way there, not actually useful; and it doesnt' even address the small bits of html-wrapped in json that might end up being more common.
 
@andre download a cracked version nd check. you need to be brutal if you have no other go ..!
 
No crack in the net.. I wanted to get winsock packet editor
 
@EamonNerbonne yeah, i agree. if you are going the SPA route, razor is not needed. most of the MVC stuff isn't needed. other than as a host for webapi or whatever you are building the services in.
 
4:01 PM
:-(
 
@AndréSilva Whaddya mean, no crack in the net?
 
If it is a non-free program, there is a cracked version on the internet. Somewhere.
 
@KendallFrey I even tried 94FBR and nothing.. Just lot of viruses..
I WENT TO THE THIRD PAGE IN GOOGLE FOR CRYING OUT LOUD
2
 
Google has a 3rd page?
3
 
4:10 PM
Amazing, I know...
 
If I don't find it on the first or second, I give up and leave the internet for the day.
 
If it's not in the top three, I revise my search and try again.
 
lol @bracket n @kendall..
 
AspxFormsGen 94fbr didn't work.
 
Pff, far too proactive.
 
4:11 PM
Junnark AspxFormsGen 94fbr didn't work.
AspxFormsGen 4.0 94fbr didn't work.
:( Feels sad.
 
I would find it in a minute if its anything illegal ..
 
Do you have the dark web indexed?
 
@KendallFrey Me ?
 
no, codebrain
 
When you're writing extension methods for string, do you think the most expected results of a null being passed in would be to: Pass null back out? Pass string.Empty out? Or throw an exception? (If exception, NullRef or ArgNull?)
 
4:13 PM
Depends on the method.
 
I know it's case dependent, but I'm thinking NullRef.
 
@Bracketworks Wonder what the deepest anyone have ever drilled down a google search is. Google probably have stats, would be an interesting factoid.
 
Definitely not passing empty out, or the NRE.
 
@JohanLarsson Probably; I wonder where the cusp of unrelativity is.
@KendallFrey Not NRE?
 
Never throw a NRE manually.
 
4:14 PM
@KendallFrey Convention or further reason?
 
I'd lean toward ArgumentNull, but depending on the method, returning null may be appropriate.
 
If chained, returning null has a likelihood to NRE anyway.
 
@Bracketworks It's one of those things you just don't do. Sort of like you don't manually throw OOM.
 
NullRef or ArgNull would both be fine by me (or really any exception you want), and depending on the context perhaps some placeholder - almost certainly not string.Empty, however.
 
ArguNull is the convention for extension methods.
 
4:17 PM
@KendallFrey ...unless you're out of memory ;)
 
I don't think any built-in extensions would throw NRE
 
@kendal No, but a fact , its easy to find cracks, keygen, serials ..wtver than a working sample code in msdn ..
 
@Bracketworks "... manually throw ..."
 
@KendallFrey Fair enough, I wouldn't argue the convention; however I still see it as sensible, only to replicate system behavior.
 
@KendallFrey Well, it sort of is a null reference, just not one the compiler detects. I don't think it really matter, it wouldn't make debugging any harder, nor maintainability, so while ArgNull may be a little more conventional, if a coworker used NullRef I wouldn't bother to mention it.
 
4:18 PM
@KendallFrey That's what I meant ;)
 
@Bracketworks What bracketworks says: "I still see it as sensible, only to replicate system behavior."
 
If you have the option to throw it, you're not out of memory.
I see it as insensible, because NRE results from dereferencing a null pointer, which you didn't do.
 
@KendallFrey sure, but that's getting a little sidetracked compared to the NullRef issue.
 
if (checkmem() < 1) {
    // @todo: i forget
}
@KendallFrey I know, I was j/k
 
Hey!
I have a question
can you help me about it?
the question is in the following link
http://stackoverflow.com/questions/14583936/wcf-upload-stream-the-remote-server-returned-an-unexpected-response-400-bad
 
4:20 PM
Happy stressful day guys!
 
Thanks :)
 
@KendallFrey I see your point, and ArgNull is fine, but normally I like my API's to be consistent - so if I'm emulating an instance method, I'd want instance method behavior
 
I like APIs to be consistent too. I've never used an API that threw NREs in extensions.
 
@KendallFrey Understandable. However given the context that the method is syntactically invoked on an instance, given it weren't sugar, it would NRE.
@KendallFrey Of course. I'll ArgNull.
 
?
is there anyone wants to help me?
 
4:22 PM
I tried google now, capped at 78 pages for two different searches
 
put it this way: if you implement an interface that normally throws NonsensicalException when .BlargyFloop() is called, it's easiest to do the same in your implementation even if it's not ideal for your particular case. It's more important to integrate with the calling code that it is to have the api work the way you want.
 
Are you saying that throwing NRE manually is not ideal for the specific case?
 
I'm saying it's defensible.
 
Throwing NRE is never ideal.
 
it's not ideal
 
4:24 PM
2
Q: Is it necessary to throw a NullReferenceException from an extension method?

MattDaveyIf I define an extension method such as this: static public String ToTitleCase(this string instance, CultureInfo culture) { if (instance == null) throw new NullReferenceException(); if (culture == null) throw new ArgumentNullException("culture"); return culture.Text...

tl;dr: Don't
lol... Linked question:
2
Q: Who is responsible for checking for NullReferenceExceptions?

TysonFor example if you pass a car into a sub that makes use of a car who should be checking for null references? Should I even bother wrapping this code in the below if statement? It seems quite redundant, obviously I could have given a better example because I can't catch the exception and handle i...

A: Chuck Norris.
 
> You should never throw a NullReferenceException manually. It should only ever be thrown by the framework itself.
Exactly
 
Also defensible
 
define defensible
 
(as an aside, that answer isn't worth much - it just posits an opinion with no argumentation whatsoever)
I mean it'll behave well in practice
it'll be maintainable.
it'll work.
both solution will
 
@EamonNerbonne No, but the comments go into better analysis
 
4:28 PM
NO NO NO NO NO! DO NOT THROW A NULLREFERENCEEXCEPTION!
Thanks,
The rest of us.
 
is NRE sealed? (not that I'm going to extend it)
 
Probably.
 
which comment?
It's not sealed.
I think the key point here is that if null is not a valid receiver and you did not check for null, you might encounter an NRE
 
You should check for null.
 
@EamonNerbonne Just discussion that NRE is not suitable (framework reservations aside) because while syntactically it's sugared to look like an instance call, its still actually a static call with a null argument: NAE. (I've switched sides here, I would've defended against this point a minute ago)
 
4:31 PM
obviously - but the caller apparently did not
 
If you don't, you should not make APIs.
 
otherwise this whole discussion is moot
@Bracketworks but that's a really terrible argument
what you're saying is that even though you're pretending to be an instance method, the caller still needs to be aware of the implementation details when it comes to behavior
 
Here's an interesting point. What if you call SomeClass.SomeMethod(null)? Would you expect a NRE or an ANE?
 
@EamonNerbonne How so? FooX.Bar(null) shouldn't sensibly throw NRE.
 
@EamonNerbonne You're not 'pretending to be an instance method'
 
4:33 PM
sure you are - that's the point of an extension method.
 
@EamonNerbonne See, that's why I thought it was a good idea at first, to abstract them away.
 
you make em so people can use em as if they were instance methods.
otherwise, why are you making an instance method?
 
Since you can call an extension method the normal way, would it make sense to get a NRE from it?
 
Let me put it this way: if I implemented the interface IList and the method Add actually prepended elements, that would be Very Surprising - and possibly break generic algorithms written for IList.
if you pass null, you should always be prepared for NRE.
 
What does that have to do with this?
 
4:36 PM
the point is that I have a call somewhere in my code:
myVariable.SomeMethod()
 
@EamonNerbonne You should also be prepared for a StackOverflowException. Anything can happen. Your point is invalid.
 
and some later maintainer sees that code he might well expect an NRE when myVariable is null.
 
As a side note, what if instance methods didn't fail on null? There's no reason they couldn't.
 
it's just the principle of least surprise.
personally, I'd love to see null go the way of the dodo
 
@EamonNerbonne The principle of least surprise says that you should never throw a NRE manually. That would be very surprising.
 
4:38 PM
and all this is pie-in-the-sky fun argumentation, because of course .NET isn't actually that consistent with exceptions
so you can't really predict which exception is thrown
 
Er, what.
 
@KendallFrey definitely not! The important actor here is the caller not the implementer
 
The caller should expect ANE from an extension method.
If he doesn't, that's his own problem.
 
the implementer happened to implement that method using an extension method rather than an instance method, but that's transparent to the caller - because you cannot tell an instance from an extension method at the call point.
 
It is not all all transparent.
 
4:39 PM
(not without some refactoring tool)
you mean the implementation isn't transaprent.
the code is.
but in any case, you need to be prepared for an NRE because not all methods validate all arguments.
so it's all a bit moot anyhow
 
That means nothing, because any exception could be thrown.
 
not really.
 
Including NRE, OOM, SO, ThreadAbort, etc.
 
are you saying it's turing complete - anything can happen>?
the point is that assuming simple receivers, an NRE is quite likely.
 
Turing completeness? What does that have to do with this?
 
4:42 PM
your argument reduces to that:
you're saying the receiver could do anything, so a ThreadAbort is just as conceivable as an NRE
when that's plainly false.
 
You are plainly false.
 
obviously, anything is possible - but not equally likely.
no, I'm not a boolean :-)
well, if you experiment with a new API, and null is not documented to be a valid argument value
what would surprise you more : a ThreadAbort or an NRE?
 
All I have to say is, NullReferenceException is thrown when code tries to access a member of a null reference. It should never be thrown in any other case.
 
That's not an argument, it's a statement of principle
 
@EamonNerbonne I'm not saying ThreadAbort would be caused by the null.
 
4:44 PM
It's just code. Why that principle?
 
To avoid confusion.
 
no exactly, so it may be somewhat unfortunate, but when you pass null, a common bug might be NRE
 
If we didn't have principles, where would we be?
 
you're in undocumented territory anyway by passing an argument that's not supported nor documented.
By convention it's friendly to check the argument, but that's not always done - sometimes for good reasons.
and if you cause undefined behavior, you've got no right to much of any expectations (as you say), but nevertheless some behaviors are more surprising that others.
 
If it throws ANE, it's a good API. If it doesn't check, and as a result causes a NRE, it's a bad API. If it throws a NRE manually, it's an evil API.
 
4:46 PM
and passing an undocumented, unsupported null could cause an NRE in very many situations.
OK, thanks for that statement!
 
@EamonNerbonne But according to the principle of least surprise, it should be ANE.
 
Yeah, no objection - not saying you shouldn't throw an ANE, just that an NRE isn't terrible.
 
As an API consumer, by all means be ready for a NRE. As an API writer, do not throw NRE.
 
but back to your statement real quick:
 
@EamonNerbonne Yes it is.
 
4:48 PM
Labelled:
(A) If it throws ANE, it's a good API.
(B) If it doesn't check, and as a result causes a NRE, it's a bad API.
(C) If it throws a NRE manually, it's an evil API.
 
Perhaps ANE should've inherited NRE. Provided exceptions were catchable by interface, they could share a marker.
 
All I'm saying is that B and C are the same
 
Ew how.
 
@EamonNerbonne Not under the hood.
And an API's quality is all under the hood.
 
4:49 PM
there's no observable difference, and that the only thing that matters
the rest is just clever programming
or terrible programming
or weird programming
but it just doesn't matter.
 
There could very well be an observable difference.
 
In some alternate universe - in practice, no.
 
In practice YES.
 
even the stack trace will be the same
 
No.
Not always.
 
4:50 PM
but you'd be very unwise to rely on the stack trace in any case because it's a common pattern to use helper methods to create exceptions.
 
Of course.
 
i.e. you know SomeMethod will be in the stack, not whether it will be the last
 
I'd love to continue to tell you how stupid you are, but it's lunch time.
 
@KendallFrey so you acknowledge that the exact stack depth cannot be relied upon, then what difference do you think there is from the consumers point of view between a VM NRE and a manual NRE?
And of course, there is no stack depth difference.
Thus: whether an NRE is VM generated or user generated is not observable, and thus not relevant.
You've got this principle that NRE's should never be thrown, and there's nothing particularly wrong with that idea - it's just not necessary.
 
I'm back.
You know, it's not necessary to structure your code into separate classes.
It's not necessary to comment your code.
 
4:59 PM
I don't think you're wrong to suggest an ANE
 

« first day (836 days earlier)      last day (4095 days later) »