You are viewing a single thread.
View all comments View context
16 points

Your assumption that β€œusing reflection means the code is wrong” seems a bit extreme, at least in .Net. Every time you interact with types, you use reflection. Xml and Json serialization/deserialization uses reflection, and also Entity Framework. If you use mocking in test you are using reflection.

We have an excel export functionality on our sites that uses reflection because we can write 1 function and export any types we want, thanks to reflection.

permalink
report
parent
reply
3 points
Deleted by creator
permalink
report
parent
reply

A good sense of β€œcode smell” is one of the most valuable programming skills. I think your β€œprobably” is justified: if you’re doing X, you should look twice at how you’re doing it. Maybe it’s right, but usually it’s not, so it’s worth a pause and a thought.

permalink
report
parent
reply
1 point

huh, you’re right! I’m trained on a different kind of code. In C# in particular, which I use mostly to do sneaky stuff (patch/inject runtime code to, um, β€œfix” it) and when I see a project that it’s too clean it smells

I also see python code (I code regular stuff in it) that could be written much more cleanly using monkey-patching

permalink
report
parent
reply
2 points

Modern .NET is reducing dependence on reflection. System.Text.JSON and other core libraries have leveraged source generation to produce AOT + trim friendly, reflection free code. But yeah, it’s not a taboo like say dynamic, it’s perfectly normal to use reflection in idiomatic C# code.

permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 6.8K

    Monthly active users

  • 1.4K

    Posts

  • 32K

    Comments