6 Replies Latest reply: Aug 18, 2010 5:41 PM by 800330 RSS

    what kind of design pattern is this?

    652628
      Hi ,

      I am just learning the designpattern. So when I went through different kinds of design pattern, I got some doubts as it looks same some design patterns. could anybody please tell what kind of design pattern is the following one?
      public interface IExporter{
      
           void export();
      }
      public class ExcelExporter implements IExporter{
      public void export(){
      //TODO implementation
      }
      }
      public class CVSExporter implements IExporter{
      public void export(){
      //TODO implementation
      }
      }
      thanks in advance..
        • 1. Re: what kind of design pattern is this?
          800387
          At least as far as I can tell the only 'design pattern' you are demonstrating is inheritance, which is not really a design pattern at all. BTW, you have 'questions' not 'doubts' regarding this topic. My advice is to learn more of the language fundamentals before trying to learn patterns. Patterns are really more about communication than design.

          - Saish
          • 2. Re: what kind of design pattern is this?
            843853
            Well - in structure, it is nearest to the Command pattern as far as I can tell but it differs in so much as its motivation is to polymorphically allow the use of different exporters rather than provide a set of action commands.
            • 3. Re: what kind of design pattern is this?
              jduprez
              Well - in structure, it is nearest to the Command pattern as far as I can tell
              Or Strategy. Or Builder. Several design pattenrs may share the same class structure, the difference is in the context, forces, and the parts one want to be flexible. And if someone wants to make it explicit which pattern is applied, they should name things accordingly.

              As Saish said this example shows little more that inheritance at work. Not a pattern in itself, but a core element of the language. Trying to "identify" a pattern that is not obvious from the context is either:
              - a sign that the original coder completely missed the point of using a pattern (which is, as Saish said too, assentially about communication)
              - a sign that the maintenance coder is looking for patterns where there aren't
              - an exercise question
              but it differs in so much as its motivation is to polymorphically allow the use of different exporters rather than provide a set of action commands.
              That shouldn't count as a difference, merely as an "application" (it's perfectly valid to have a hierarchy of commands all devoted to exporting, although, as stated, if the original coder applied the Command pattern, he should have made it explicit, by renaming the interface, e.g. to ExportCommand).
              • 4. Re: what kind of design pattern is this?
                843853
                My reading is that the Strategy pattern requires a Context to 'inject' the strategy into. The context is not evident from the question, though I agree the IExporter may be considered an injectable strategy into some higher level object.

                I concur with Saish's sentiments too.
                • 5. Re: what kind of design pattern is this?
                  796280
                  public interface IExporter{
                  
                  void export();
                  }
                  public class ExcelExporter implements IExporter{
                  public void export(){
                  //TODO implementation
                  }
                  }
                  public class CVSExporter implements IExporter{
                  public void export(){
                  //TODO implementation
                  }
                  }
                  Looks like a combination of the 'Skellington' and 'Commentington' patterns.
                  • 6. Re: what kind of design pattern is this?
                    800330
                    Very funny, Thok! Can you give a twist to the CSV vs CVS spelling too?