
How the .NET Runtime Loads a Type - matthewwarren
http://mattwarren.org/2017/06/15/How-the-.NET-Rutime-loads-a-Type/
======
bigdubs
This (somewhat) complicated process is also why generics can be fully reified
in the CLR.

~~~
NicoJuicy
I love generics! Simplifies all my api creations deeply, huge re-use of code
and very flexible implementations.

Eg. An API to a IoT cloud that lets user define their own type. The payload
that i fetch is <T> so users can define their own type.

Another one is an api where i take a generic approach, so my only code that i
write ( for every "class" / " model" ) is:

//every endpoint does a complete crud + jsonpatch + batch, also, all methods
can be overridden to customize code. This is the code i need to write every
time :p [https://pastebin.com/fp8MtpBu](https://pastebin.com/fp8MtpBu)

Note to myselve: extend the implementation to support expressions ( odata ) in
the url ( similar to sql on top of an API through changing url parameters) and
return the dto as response. :)

~~~
flukus
> I also use dto's in some endpoints. So i should extend the implementation to
> support linq on the domain model ( on odata) and return the dto as response.
> But this is for later i suppose

Please don't. I've ended up maintaining far too many abominations where
developers got excited about generics and linq rather than solving real
problems. You just end up with apps that should be simple and straightforward
being a nightmare to maintain.

Generics, linq and inheritance all have their uses but if they aren't used
sparingly they create more spaghetti.

Edit - at the very least, please be careful and use generics as sparingly as
possible.

~~~
wtetzner
Do you have any examples of how generics could create spaghetti code? Given
that they aren't control flow constructs, I'm having a hard time imagining
such a situation.

~~~
Quarrelsome
If you try to use generics too hard you make crazy shit. I'm working on a
system that has a Something<T, Y> but the Y inherits from the T and its all
just a mad mess that makes no sense at face value. I guess someone thought it
was a good idea at some point but the end result is just confusing as hell.
Then you realise its just sitting upon 5 really simple Sql tables and you
realise its really convoluted.

Its all about stepping back and going: "am I trying too hard?". Like that last
10% of making the code base 100% elegant is what ruins it.

