Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Absolutely Horrific

Absolutely Horrific

Scheduled Pinned Locked Moved The Weird and The Wonderful
questioncomadobearchitecture
19 Posts 11 Posters 14 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Brisingr Aerowing

    Reaching for Private Parts - The Daily WTF[^] Modifying a class using reflection only in production... :eek:

    What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

    J Offline
    J Offline
    jlongo
    wrote on last edited by
    #10

    1- the link refers to Java, not .Net. MS has nothing to do with this. 2- if this fragment is required, the developer is doing it wrong. He is using the wrong class for the wrong job or has not properly configured the app ( a cache in this case) 3 - the class is defective, perhaps one of 100 open-source jars to choose from, perhaps another “vendor” is in order 4- is this H1-B code? That would explain it.

    1 Reply Last reply
    0
    • D Daniel Pfeffer

      PIEBALDconsult wrote:

      I wrote an extension method which fiddles about in the private parts of a .net class.

      There may be (extremely rare) cases when such perversions may be necessary, but a difference in behaviour between development and production?! :wtf: Isn't the whole idea of a development environment to be as close as possible to the production environment, but without changing production data?

      Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

      S Offline
      S Offline
      Slow Eddie
      wrote on last edited by
      #11

      Shouldn't there be a test database (recent copy of the production database) to test code against?:confused:

      1 Reply Last reply
      0
      • Greg UtasG Greg Utas

        Another flaw with frameworks is a monotonic increase in their surface-to-volume ratio. It stems from a reticence to introduce "breaking changes" when evolving the framework, because existing users who want to migrate to the next major release think it should be transparent. I have no sympathy for them. To me, a framework embodies a powerful object model, which means that it must typically be used as a whole, whereas a library is a collection of disparate classes whose collaborations are up to the user.

        Robust Services Core | Software Techniques for Lemmings | Articles
        The fox knows many things, but the hedgehog knows one big thing.

        H Offline
        H Offline
        honey the codewitch
        wrote on last edited by
        #12

        One of the reasons I keep falling in love with C++ over and over again is A) source level polymorphism B) selective linking leading to C) Frameworks that aren't frameworks as long as they aren't coded like garbage What I mean is you can have a bunch of things that all work together (the STL, a framework more than a library considering how many different things it covers, but all the core bits are used together) and you can only include bits you need. This encourages me to code even things that may be used rarely, because if you don't need it it's never compiled in. That leads to very little framework bloat. Plus it's as modular as you develop it to be. If you update <iostream> library you can theoretically, simply update that header as long as you don't change exiting source level interfaces

        Real programmers use butterflies

        Greg UtasG 1 Reply Last reply
        0
        • H honey the codewitch

          One of the reasons I keep falling in love with C++ over and over again is A) source level polymorphism B) selective linking leading to C) Frameworks that aren't frameworks as long as they aren't coded like garbage What I mean is you can have a bunch of things that all work together (the STL, a framework more than a library considering how many different things it covers, but all the core bits are used together) and you can only include bits you need. This encourages me to code even things that may be used rarely, because if you don't need it it's never compiled in. That leads to very little framework bloat. Plus it's as modular as you develop it to be. If you update <iostream> library you can theoretically, simply update that header as long as you don't change exiting source level interfaces

          Real programmers use butterflies

          Greg UtasG Offline
          Greg UtasG Offline
          Greg Utas
          wrote on last edited by
          #13

          Please elaborate. I think I might learn something. Source level polymorphism? Never heard of source level as an adjective for polymorphism. What's it mean? Selective linking? By this, do you mean that code that isn't used doesn't get linked into the .exe? I see the STL as being in a half-world between library and framework. Iterators, for example, cut across many of the classes, but the higher-level classes stand on their own. That's quite different from what I'm doing, where it's impossible to use any component on its own, because those in the same static library use each other freely. When I read about this dependency injection fetish in light of what I'm doing, I just throw up my hands and chortle at the endless boilerplate that would be needed. Besides, toy test harnesses will never exercise a framework as well as a few serious applications.

          Robust Services Core | Software Techniques for Lemmings | Articles
          The fox knows many things, but the hedgehog knows one big thing.

          <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
          <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

          H 2 Replies Last reply
          0
          • Greg UtasG Greg Utas

            Please elaborate. I think I might learn something. Source level polymorphism? Never heard of source level as an adjective for polymorphism. What's it mean? Selective linking? By this, do you mean that code that isn't used doesn't get linked into the .exe? I see the STL as being in a half-world between library and framework. Iterators, for example, cut across many of the classes, but the higher-level classes stand on their own. That's quite different from what I'm doing, where it's impossible to use any component on its own, because those in the same static library use each other freely. When I read about this dependency injection fetish in light of what I'm doing, I just throw up my hands and chortle at the endless boilerplate that would be needed. Besides, toy test harnesses will never exercise a framework as well as a few serious applications.

            Robust Services Core | Software Techniques for Lemmings | Articles
            The fox knows many things, but the hedgehog knows one big thing.

            H Offline
            H Offline
            honey the codewitch
            wrote on last edited by
            #14

            Greg Utas wrote:

            Never heard of source level as an adjective for polymorphism. What's it mean?

            It means if I have a template

            template struct A {
            T t;
            A() : t() { t.foo(); }
            };

            Then this will compile

            struct B {
            void foo() { printf("hello!\r\n"); }
            };

            A<B> c;

            but this won't:

            struct B {
            void bar() { printf("goodbye!\r\n"); }
            };

            A<B> c;

            template A will take any class "of a type" that exposes a public foo() method. This allows you to create a kind of polymorphism at the source level. There is no explicit binary contract like there is with traditional polymorphism. It's a source contract. You don't actually need a binary interface to be fulfilled for the class. The bottom line is, you don't inherit to do it. You just call the methods you need. It works because templates aren't resolved until they are instantiated. One of the chief advantages of this over traditional inheritance based polymorphism is that there's no source dependency on a base class. Most of the STL does it this way, preventing much of the cross header dependencies that would otherwise be needed

            Greg Utas wrote:

            By this, do you mean that code that isn't used doesn't get linked into the .exe?

            Yes. I don't know if there's a better name for it, that's just what i've always called it. It's so critical for so much of what i do in C++. My code I'm writing would be so not viable without it.

            Real programmers use butterflies

            Greg UtasG 1 Reply Last reply
            0
            • Greg UtasG Greg Utas

              Please elaborate. I think I might learn something. Source level polymorphism? Never heard of source level as an adjective for polymorphism. What's it mean? Selective linking? By this, do you mean that code that isn't used doesn't get linked into the .exe? I see the STL as being in a half-world between library and framework. Iterators, for example, cut across many of the classes, but the higher-level classes stand on their own. That's quite different from what I'm doing, where it's impossible to use any component on its own, because those in the same static library use each other freely. When I read about this dependency injection fetish in light of what I'm doing, I just throw up my hands and chortle at the endless boilerplate that would be needed. Besides, toy test harnesses will never exercise a framework as well as a few serious applications.

              Robust Services Core | Software Techniques for Lemmings | Articles
              The fox knows many things, but the hedgehog knows one big thing.

              H Offline
              H Offline
              honey the codewitch
              wrote on last edited by
              #15

              you should probably refresh. my first several edits were a mess. code was bad. i'm out of coffee. :laugh:

              Real programmers use butterflies

              Greg UtasG 1 Reply Last reply
              0
              • H honey the codewitch

                Greg Utas wrote:

                Never heard of source level as an adjective for polymorphism. What's it mean?

                It means if I have a template

                template struct A {
                T t;
                A() : t() { t.foo(); }
                };

                Then this will compile

                struct B {
                void foo() { printf("hello!\r\n"); }
                };

                A<B> c;

                but this won't:

                struct B {
                void bar() { printf("goodbye!\r\n"); }
                };

                A<B> c;

                template A will take any class "of a type" that exposes a public foo() method. This allows you to create a kind of polymorphism at the source level. There is no explicit binary contract like there is with traditional polymorphism. It's a source contract. You don't actually need a binary interface to be fulfilled for the class. The bottom line is, you don't inherit to do it. You just call the methods you need. It works because templates aren't resolved until they are instantiated. One of the chief advantages of this over traditional inheritance based polymorphism is that there's no source dependency on a base class. Most of the STL does it this way, preventing much of the cross header dependencies that would otherwise be needed

                Greg Utas wrote:

                By this, do you mean that code that isn't used doesn't get linked into the .exe?

                Yes. I don't know if there's a better name for it, that's just what i've always called it. It's so critical for so much of what i do in C++. My code I'm writing would be so not viable without it.

                Real programmers use butterflies

                Greg UtasG Offline
                Greg UtasG Offline
                Greg Utas
                wrote on last edited by
                #16

                Your first example makes sense. Instantiating the second A<B> will fail when it tries to resolve B::foo. It's like A is defining an interface that its template arguments must support. Not linking dead code into an .exe is great. It allows my main() to #include the subset of static libraries that are wanted in a build, which omits all the others without any fuss at all. It's gross to contemplate the code bloat that would otherwise occur.

                Robust Services Core | Software Techniques for Lemmings | Articles
                The fox knows many things, but the hedgehog knows one big thing.

                <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
                <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

                H 1 Reply Last reply
                0
                • H honey the codewitch

                  you should probably refresh. my first several edits were a mess. code was bad. i'm out of coffee. :laugh:

                  Real programmers use butterflies

                  Greg UtasG Offline
                  Greg UtasG Offline
                  Greg Utas
                  wrote on last edited by
                  #17

                  I gathered that, and refreshed. If I had coffee now, we'd be here all night. :laugh:

                  Robust Services Core | Software Techniques for Lemmings | Articles
                  The fox knows many things, but the hedgehog knows one big thing.

                  <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
                  <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

                  1 Reply Last reply
                  0
                  • Greg UtasG Greg Utas

                    Your first example makes sense. Instantiating the second A<B> will fail when it tries to resolve B::foo. It's like A is defining an interface that its template arguments must support. Not linking dead code into an .exe is great. It allows my main() to #include the subset of static libraries that are wanted in a build, which omits all the others without any fuss at all. It's gross to contemplate the code bloat that would otherwise occur.

                    Robust Services Core | Software Techniques for Lemmings | Articles
                    The fox knows many things, but the hedgehog knows one big thing.

                    H Offline
                    H Offline
                    honey the codewitch
                    wrote on last edited by
                    #18

                    I'm glad it made sense to you. It wouldn't have compiled, but it conveyed the idea, it seems, because you're exactly right about how it works. And it's bril, because you don't need to include a header for a common base to use it. I agree with you about the linking. I write a lot of IoT code, and i couldn't without it.

                    Real programmers use butterflies

                    1 Reply Last reply
                    0
                    • B Brisingr Aerowing

                      Reaching for Private Parts - The Daily WTF[^] Modifying a class using reflection only in production... :eek:

                      What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

                      I Offline
                      I Offline
                      Istvan Smrtnik
                      wrote on last edited by
                      #19

                      Building a web scraper I had the pleasure to abuse JavaFX's WebView browser module by modifying byte code to hook onto http requests and the trick of this post to get at the url in an intercepted UrlLoader call. I wouldn't care using it in production. But also in test, I'd like to mention.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups