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. Because Reasons

Because Reasons

Scheduled Pinned Locked Moved The Weird and The Wonderful
helpquestion
19 Posts 10 Posters 0 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.
  • L loctrice

    I'm trying to figure out how some code wires up, but it's a spider web. I'll leave all the goodness out and just get right to the point - I'm cruising around through files and notice, upon going to definition, there's an empty interface. I'm in the habbit of cleaning up code, so I remove it. Compilation error. Why ? Because all this stuff implements this interface for no other reason then to be passed around "generically" through the code.......

    Elephant elephant elephant, sunshine sunshine sunshine

    Sander RosselS Offline
    Sander RosselS Offline
    Sander Rossel
    wrote on last edited by
    #6

    I once used a marker interface for some third party component. The component COULD edit, save, cancel, delete, etc. (through a method named DoAction(string)). If an action was supported was decided by some method ActionSupported(string) or some such. I created an empty marker interface IThirdPartyComponent, and then interfaces like ISave (with Save method), IEdit (with Edit method) etc. that all inherited IThirdPartyComponent. That worked a lot better than DoAction(string) and ActionSupported(string), especially since I was able to built some strong typed additional tooling around it :)

    Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

    Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

    Regards, Sander

    L B 2 Replies Last reply
    0
    • Sander RosselS Sander Rossel

      I once used a marker interface for some third party component. The component COULD edit, save, cancel, delete, etc. (through a method named DoAction(string)). If an action was supported was decided by some method ActionSupported(string) or some such. I created an empty marker interface IThirdPartyComponent, and then interfaces like ISave (with Save method), IEdit (with Edit method) etc. that all inherited IThirdPartyComponent. That worked a lot better than DoAction(string) and ActionSupported(string), especially since I was able to built some strong typed additional tooling around it :)

      Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

      Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

      Regards, Sander

      L Offline
      L Offline
      loctrice
      wrote on last edited by
      #7

      I think I short circuited my own post by "I'll leave out the goodness and just get to the point". It's possible that this is the marker pattern, although it's not - it's more likely it wasn't intentionally any pattern, just something thrown in to get it working. It's hard to tell though, in the multi-thousand line code files that I'm digging through. Also, the marker pattern seems to imply[^]

      I would argue first-off that Serializable and Cloneable are bad examples of marker interfaces. Sure, they're interfaces with methods, but they imply methods, such as writeObject(ObjectOutputStream). (The compiler will create a writeObject(ObjectOutputStream) method for you if you don't override it, and all objects already have clone(), but the compiler will again create a real clone() method for you but with caveats. Both of these are weird edge cases that really aren't good design examples.)

      something like meta-data[^] or methods in many cases.

      1. Looking carefully on marker interface in Java e.g. Serializable, Clonnable and Remote it looks they are used to indicate something to compiler or JVM. So if JVM sees a Class is Serializable it done some special operation on it, similar way if JVM sees one Class is implement Clonnable it performs some operation to support cloning. Same is true for RMI and Remote interface. So in short Marker interface indicate, signal or a command to Compiler or JVM. Read more: http://javarevisited.blogspot.com/2012/01/what-is-marker-interfaces-in-java-and.html#ixzz4Esj4dLCe

      I don't feel like what was done here is a good use for that, especially in the junk it's tied up in. If it was intentional, it was done to avoid a good refactor in a steaming pile.

      Elephant elephant elephant, sunshine sunshine sunshine

      1 Reply Last reply
      0
      • L loctrice

        I'm trying to figure out how some code wires up, but it's a spider web. I'll leave all the goodness out and just get right to the point - I'm cruising around through files and notice, upon going to definition, there's an empty interface. I'm in the habbit of cleaning up code, so I remove it. Compilation error. Why ? Because all this stuff implements this interface for no other reason then to be passed around "generically" through the code.......

        Elephant elephant elephant, sunshine sunshine sunshine

        J Offline
        J Offline
        johannesnestler
        wrote on last edited by
        #8

        In a Project I had to use Marker Interfaces to make base-class varialbes for MEF Imports/Exports "handlable" - some MEF (ManagedExtensibilityFramework) in your Project?

        1 Reply Last reply
        0
        • L loctrice

          I'm trying to figure out how some code wires up, but it's a spider web. I'll leave all the goodness out and just get right to the point - I'm cruising around through files and notice, upon going to definition, there's an empty interface. I'm in the habbit of cleaning up code, so I remove it. Compilation error. Why ? Because all this stuff implements this interface for no other reason then to be passed around "generically" through the code.......

          Elephant elephant elephant, sunshine sunshine sunshine

          R Offline
          R Offline
          Ravichanadeepakarandescarar
          wrote on last edited by
          #9

          You could spend all that time defining a way to use JIRA to slow down work, and get more credit and would be easier

          L 1 Reply Last reply
          0
          • R Ravichanadeepakarandescarar

            You could spend all that time defining a way to use JIRA to slow down work, and get more credit and would be easier

            L Offline
            L Offline
            loctrice
            wrote on last edited by
            #10

            I'm not sure what you're getting at? We use JIRA to make things easier ? I don't really care about gettin credit. I mean, everyone likes credit or being noticed, but I just like to code.

            Ravichanadeepakarandescarar wrote:

            use JIRA to slow down work,

            JIRA is a good tool !?!

            Elephant elephant elephant, sunshine sunshine sunshine

            R 1 Reply Last reply
            0
            • L loctrice

              I'm not sure what you're getting at? We use JIRA to make things easier ? I don't really care about gettin credit. I mean, everyone likes credit or being noticed, but I just like to code.

              Ravichanadeepakarandescarar wrote:

              use JIRA to slow down work,

              JIRA is a good tool !?!

              Elephant elephant elephant, sunshine sunshine sunshine

              R Offline
              R Offline
              Ravichanadeepakarandescarar
              wrote on last edited by
              #11

              It all depends on the process flow and reduce the number of swivel chairs to reduce siloing resulting from diverged non-constrained islands of excellence as opposed to organization encompassing SME confluences.

              L 1 Reply Last reply
              0
              • R Ravichanadeepakarandescarar

                It all depends on the process flow and reduce the number of swivel chairs to reduce siloing resulting from diverged non-constrained islands of excellence as opposed to organization encompassing SME confluences.

                L Offline
                L Offline
                loctrice
                wrote on last edited by
                #12

                yeah, you sound pretty familiar. I see you just joined.

                Elephant elephant elephant, sunshine sunshine sunshine

                1 Reply Last reply
                0
                • D Duncan Edwards Jones

                  Except marker interface can be used as constraints in generics...attributes can't.

                  S Offline
                  S Offline
                  Super Lloyd
                  wrote on last edited by
                  #13

                  yeah, what good does it do, to constrain on empty interface?! :O

                  A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

                  1 Reply Last reply
                  0
                  • L loctrice

                    I'm trying to figure out how some code wires up, but it's a spider web. I'll leave all the goodness out and just get right to the point - I'm cruising around through files and notice, upon going to definition, there's an empty interface. I'm in the habbit of cleaning up code, so I remove it. Compilation error. Why ? Because all this stuff implements this interface for no other reason then to be passed around "generically" through the code.......

                    Elephant elephant elephant, sunshine sunshine sunshine

                    V Offline
                    V Offline
                    Vander Wunderbar
                    wrote on last edited by
                    #14

                    Quote:

                    I'm trying to figure out how some code wires up...

                    Quote:

                    ...there's an empty interface...

                    Quote:...Because all this stuff implements this interface...

                    I tell you this. You need subtle knowledge to understand it. Meditate, Hummmmmmm

                    1 Reply Last reply
                    0
                    • Sander RosselS Sander Rossel

                      I once used a marker interface for some third party component. The component COULD edit, save, cancel, delete, etc. (through a method named DoAction(string)). If an action was supported was decided by some method ActionSupported(string) or some such. I created an empty marker interface IThirdPartyComponent, and then interfaces like ISave (with Save method), IEdit (with Edit method) etc. that all inherited IThirdPartyComponent. That worked a lot better than DoAction(string) and ActionSupported(string), especially since I was able to built some strong typed additional tooling around it :)

                      Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                      Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                      Regards, Sander

                      B Offline
                      B Offline
                      Brisingr Aerowing
                      wrote on last edited by
                      #15

                      What component? That single DoAction method is a horrible design, and any component that uses such patterns goes straight into the trash, never to be looked at or used again.

                      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???

                      Sander RosselS 1 Reply Last reply
                      0
                      • B Brisingr Aerowing

                        What component? That single DoAction method is a horrible design, and any component that uses such patterns goes straight into the trash, never to be looked at or used again.

                        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???

                        Sander RosselS Offline
                        Sander RosselS Offline
                        Sander Rossel
                        wrote on last edited by
                        #16

                        It was part of the DevExpress WinForms controls. It's really not THAT horrible as you have little choice but to use string codes for your UI. So basically there was this button bar and whenever you clicked a button some component would raise DoAction(string). I simply wrote a custom component that translated DoAction(string) to Save, Edit, etc.

                        Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                        Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                        Regards, Sander

                        B 1 Reply Last reply
                        0
                        • Sander RosselS Sander Rossel

                          It was part of the DevExpress WinForms controls. It's really not THAT horrible as you have little choice but to use string codes for your UI. So basically there was this button bar and whenever you clicked a button some component would raise DoAction(string). I simply wrote a custom component that translated DoAction(string) to Save, Edit, etc.

                          Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                          Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                          Regards, Sander

                          B Offline
                          B Offline
                          Brisingr Aerowing
                          wrote on last edited by
                          #17

                          I use DevExpress Winforms controls and have never seen that method on any of them.

                          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???

                          Sander RosselS 1 Reply Last reply
                          0
                          • B Brisingr Aerowing

                            I use DevExpress Winforms controls and have never seen that method on any of them.

                            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???

                            Sander RosselS Offline
                            Sander RosselS Offline
                            Sander Rossel
                            wrote on last edited by
                            #18

                            I don't work for that company anymore, so I haven't done WinForms or DevExpress in a while, but there was this navigation button bar control to which you could hook some IIDontRememberWhat. It was that interface which had the method :)

                            Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                            Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                            Regards, Sander

                            B 1 Reply Last reply
                            0
                            • Sander RosselS Sander Rossel

                              I don't work for that company anymore, so I haven't done WinForms or DevExpress in a while, but there was this navigation button bar control to which you could hook some IIDontRememberWhat. It was that interface which had the method :)

                              Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                              Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                              Regards, Sander

                              B Offline
                              B Offline
                              Brisingr Aerowing
                              wrote on last edited by
                              #19

                              Located the interface (INavigatableControl) and the method now takes a NavigatorButtonType enum as the parameter. At least it isn't stringly typed anymore.

                              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???

                              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