On Thu, Jul 10, 2014 at 11:36 AM, Jonathan S. Shapiro <[email protected]>
wrote:
> So I think there are two kinds of reflection;
>
> 1. Out-of-program reflection, e.g. by a debugger. This is a case where it
> may make sense not to honor encapsulation boundaries, though that actually
> depends on the security model. It's a *little* bit like the notion of a
> design-time COM interface that is used by an interface builder.
>
Unit testing could come into this .. since you trust the development
environment like the debugger.
>
> 2. In-program reflection, in which the program is inspecting itself at run
> time in a way that bypasses the language protections. If you can bypass
> them, then they ain't protections.
>
> How much of what is currently done with reflection actually *requires*
> reflection?
> How much could be accomplished using only static reflection? What kinds of
> things are missing as first-class concepts that would help make reflection
> less necessary?
>
Proxy objects for Moq and OR mappers which lazy load etc ?
>
>
> In the limit, I'm mindful that C/C++ have *zero* reflection, and it
> really doesn't seem to slow them down all that much. But maybe I see it
> that way merely because *I* have never used it and don't perceive the lack.
>
It may have been ok 15 years ago but not anymore. Having to write custom /
templated serializers with friend is an annoying job when your used to
auto generated serializers..especially every-time you change fields.
compare boost serialize lib requirements to
public class XmlSerializerHelper<T>
{
readonly XmlSerializer serializer = new XmlSerializer(typeof(T));
public T ConvertFromXml(string xml)
{
return (T)serializer.Deserialize(new StringReader(xml));
}
public string ConvertToXml(T data)
{
var ns = new XmlSerializerNamespaces();
ns.Add("", ""); //strip namespace
var stringWriter = new Utf16StringWriter();
serializer.Serialize(stringWriter, data, ns);
return stringWriter.ToString();//.Deserialize(new
StringReader(xml));
}
Serialize any class with no dependencies , no attributes etc and because no
dependencies when the class changes fields there is no change to
serialization code. I use this frequently - want a custom xml data file ,
network message or config file and its 2 lines .
Regards,
Ben
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev