• 2 Posts
  • 45 Comments
Joined 1 year ago
cake
Cake day: July 2nd, 2023

help-circle
  • It’s the capability of a program to “reflect” upon itself, I.E. to inspect and understand its own code.

    As an example, In C# you can write a class…

    public class MyClass
    {
        public void MyMethod()
        {
            ...
        }
    }
    

    …and you can create an instance of it, and use it, like this…

    var myClass = new MyClass();
    myClass.MyMethod();
    

    Simple enough, nothing we haven’t all seen before.

    But you can do the same thing with reflection, as such…

    var type = System.Reflection.Assembly.GetExecutingAssembly()
        .GetType("MyClass");
    
    var constructor = type.GetConstructor(Array.Empty<Type>());
    
    var instance = constructor.Invoke(Array.Empty<Object>());
    
    var method = type.GetMethod("MyMethod");
    
    var delegate = method.CreateDelegate(typeof(Action), instance);
    
    delegate.DynamicInvoke(Array.Empty<object>());
    

    Obnoxious and verbose and tossing basically all type safety out the window, but it does enable some pretty crazy interesting things. Like self-discovery and dynamic loading of plugins, or self-configuration of apps. Also often useful when messing with generics. I could dig up some practical use-cases, if you’re curious.




  • Shit shit shit, I just remembered I haven’t attended English class all semester.

    Shit shit shit, I can’t remember my locker combination, and I can’t find the orientation sheet that has it, also I can’t find my class schedule, I have no idea what class I’m supposed to be in right now.

    Plus a few other variations. All High School. I dunno why the focus on High School, I’m 34. I get one of these once or twice a month.



  • Agreed, my wife and I had that conversation recently, as it happens. Though, for some things, there are other benefits. Herbs is the best example, even the fresh, packaged herbs that you can buy at a grocery will be noticeably not-as-good as something that you picked fresh in the backyard 2 minutes ago. Dill, basil, thyme, mint, what have you. I’ve found the same to be true of things like bell peppers and jalapenos.













  • There’s literally no such thing as a one-lead voltage meter. Voltage is, by definition, the difference in potential energy between two points.

    Any tool that can give a voltage reading with one probe has a second probe you’re not considering, or is estimating voltage based on a some assumptions about current or some other factor being measured.