Design Patterns

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mr.Tickle

    Design Patterns

    How can I impleement a singleton pattern in an abstract or interface for
    inheritance to an object so all the pattern rules are followed on all
    similar objects?


  • Rob Agar

    #2
    Re: Design Patterns


    "Mr.Tickle" <MrTickle@mrmen .com> wrote in message
    news:uayG3ANiDH A.1180@TK2MSFTN GP12.phx.gbl...[color=blue]
    > How can I impleement a singleton pattern in an abstract or interface for
    > inheritance to an object so all the pattern rules are followed on all
    > similar objects?[/color]

    I don't think you can in C#, until generics are added to the language (see
    http://msdn.microsoft.com/library/de...refeatures.asp)

    Rob


    Comment

    • Mr.Tickle

      #3
      Re: Design Patterns

      Bugger, so we have to do it on a class by class basis :|

      meh, how does Templates in MC++ and generics share when C# gets generics?
      Can C# then use the MC++ templates?


      "Rob Agar" <robagar@ukfsn. org> wrote in message
      news:blhieq$2he $1@news.ukfsn.o rg...[color=blue]
      >
      > "Mr.Tickle" <MrTickle@mrmen .com> wrote in message
      > news:uayG3ANiDH A.1180@TK2MSFTN GP12.phx.gbl...[color=green]
      > > How can I impleement a singleton pattern in an abstract or interface for
      > > inheritance to an object so all the pattern rules are followed on all
      > > similar objects?[/color]
      >
      > I don't think you can in C#, until generics are added to the language (see
      >[/color]

      t/html/vbconcprogrammi nglanguagefutur efeatures.asp)[color=blue]
      >
      > Rob
      >
      >[/color]


      Comment

      • Mickey Williams

        #4
        Re: Design Patterns

        Generics in .NET languages aren't (or won't be) the same thing as
        (non-managed) C++ templates. Having said that, it makes sense that there
        should be CLS rules that enable generics in various .NET languages to work
        together - otherwise it will be difficult to have generic collection
        containers in the new framework. Since the generic is written into IL in its
        generic form, then resolved when jitted, the intent is to have interop
        across languages.

        BTW, Eiffel has generics on .NET today - it's basically just an intelligent
        expansion of the generic Eiffel source code into non-generic IL.

        --
        Mickey Williams
        Author, "Microsoft Visual C# .NET Core Reference", MS Press




        "Mr.Tickle" <MrTickle@mrmen .com> wrote in message
        news:OswrOWPiDH A.3324@TK2MSFTN GP11.phx.gbl...[color=blue]
        > Bugger, so we have to do it on a class by class basis :|
        >
        > meh, how does Templates in MC++ and generics share when C# gets generics?
        > Can C# then use the MC++ templates?
        >
        >
        > "Rob Agar" <robagar@ukfsn. org> wrote in message
        > news:blhieq$2he $1@news.ukfsn.o rg...[color=green]
        > >
        > > "Mr.Tickle" <MrTickle@mrmen .com> wrote in message
        > > news:uayG3ANiDH A.1180@TK2MSFTN GP12.phx.gbl...[color=darkred]
        > > > How can I impleement a singleton pattern in an abstract or interface[/color][/color][/color]
        for[color=blue][color=green][color=darkred]
        > > > inheritance to an object so all the pattern rules are followed on all
        > > > similar objects?[/color]
        > >
        > > I don't think you can in C#, until generics are added to the language[/color][/color]
        (see[color=blue][color=green]
        > >[/color]
        >[/color]
        http://msdn.microsoft.com/library/de...us/dv_vstechar[color=blue]
        > t/html/vbconcprogrammi nglanguagefutur efeatures.asp)[color=green]
        > >
        > > Rob
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Mr.Tickle

          #5
          Re: Design Patterns

          So today I code the singleton design pattern into each object and wait for
          2004 generics then I can make a pattern and implement that on every object I
          need.

          It would be real nice to say here is my class, and its inheriting a pattern
          of usage from a Singleton class. Im supprised .NET doesnt come with built
          in design patterns. It really seems to be a rushed out web service prioroty
          release atm, half the shit aint managed, I always have to drop down to
          platform invoke for alot of functionality.

          When will we be getting serial communication rather than relying on pinvoke
          wrappers for one example.

          Is there a roadmap on what platform features that will be implemented in
          future releases so we can plan for that?


          "Mickey Williams" <my first name at servergeek.com> wrote in message
          news:ejTTE#PiDH A.2452@TK2MSFTN GP10.phx.gbl...[color=blue]
          > Generics in .NET languages aren't (or won't be) the same thing as
          > (non-managed) C++ templates. Having said that, it makes sense that there
          > should be CLS rules that enable generics in various .NET languages to work
          > together - otherwise it will be difficult to have generic collection
          > containers in the new framework. Since the generic is written into IL in[/color]
          its[color=blue]
          > generic form, then resolved when jitted, the intent is to have interop
          > across languages.
          >
          > BTW, Eiffel has generics on .NET today - it's basically just an[/color]
          intelligent[color=blue]
          > expansion of the generic Eiffel source code into non-generic IL.
          >
          > --
          > Mickey Williams
          > Author, "Microsoft Visual C# .NET Core Reference", MS Press
          > www.servergeek.com
          >
          >
          >
          > "Mr.Tickle" <MrTickle@mrmen .com> wrote in message
          > news:OswrOWPiDH A.3324@TK2MSFTN GP11.phx.gbl...[color=green]
          > > Bugger, so we have to do it on a class by class basis :|
          > >
          > > meh, how does Templates in MC++ and generics share when C# gets[/color][/color]
          generics?[color=blue][color=green]
          > > Can C# then use the MC++ templates?
          > >
          > >
          > > "Rob Agar" <robagar@ukfsn. org> wrote in message
          > > news:blhieq$2he $1@news.ukfsn.o rg...[color=darkred]
          > > >
          > > > "Mr.Tickle" <MrTickle@mrmen .com> wrote in message
          > > > news:uayG3ANiDH A.1180@TK2MSFTN GP12.phx.gbl...
          > > > > How can I impleement a singleton pattern in an abstract or interface[/color][/color]
          > for[color=green][color=darkred]
          > > > > inheritance to an object so all the pattern rules are followed on[/color][/color][/color]
          all[color=blue][color=green][color=darkred]
          > > > > similar objects?
          > > >
          > > > I don't think you can in C#, until generics are added to the language[/color][/color]
          > (see[color=green][color=darkred]
          > > >[/color]
          > >[/color]
          >[/color]
          http://msdn.microsoft.com/library/de...us/dv_vstechar[color=blue][color=green]
          > > t/html/vbconcprogrammi nglanguagefutur efeatures.asp)[color=darkred]
          > > >
          > > > Rob
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • William Stacey

            #6
            Re: Design Patterns

            In the constructor, can't you call up to base() that implements the
            singleton? Can't enforce child will call base, but you at least you don't
            have to implement it in all child classes.
            public abstract class parent
            {
            public parent()
            {
            //do singleton pattern
            }
            }
            public class child:parent
            {
            public child():base()
            {
            //base .ctor runs...
            //Do other child instance stuff...
            }
            }

            --
            William Stacey, DNS MVP

            "Mr.Tickle" <MrTickle@mrmen .com> wrote in message
            news:OswrOWPiDH A.3324@TK2MSFTN GP11.phx.gbl...[color=blue]
            > Bugger, so we have to do it on a class by class basis :|
            >
            > meh, how does Templates in MC++ and generics share when C# gets generics?
            > Can C# then use the MC++ templates?
            >
            >
            > "Rob Agar" <robagar@ukfsn. org> wrote in message
            > news:blhieq$2he $1@news.ukfsn.o rg...[color=green]
            > >
            > > "Mr.Tickle" <MrTickle@mrmen .com> wrote in message
            > > news:uayG3ANiDH A.1180@TK2MSFTN GP12.phx.gbl...[color=darkred]
            > > > How can I impleement a singleton pattern in an abstract or interface[/color][/color][/color]
            for[color=blue][color=green][color=darkred]
            > > > inheritance to an object so all the pattern rules are followed on all
            > > > similar objects?[/color]
            > >
            > > I don't think you can in C#, until generics are added to the language[/color][/color]
            (see[color=blue][color=green]
            > >[/color]
            >[/color]
            http://msdn.microsoft.com/library/de...us/dv_vstechar[color=blue]
            > t/html/vbconcprogrammi nglanguagefutur efeatures.asp)[color=green]
            > >
            > > Rob
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Willy Denoyette [MVP]

              #7
              Re: Design Patterns

              MC++ (Managed Extenstions for C++) wont have C++ templates, only generics are supported for all (MS) managed languages

              Willy.

              "Mr.Tickle" <MrTickle@mrmen .com> wrote in message news:OswrOWPiDH A.3324@TK2MSFTN GP11.phx.gbl...[color=blue]
              > Bugger, so we have to do it on a class by class basis :|
              >
              > meh, how does Templates in MC++ and generics share when C# gets generics?
              > Can C# then use the MC++ templates?
              >
              >
              > "Rob Agar" <robagar@ukfsn. org> wrote in message
              > news:blhieq$2he $1@news.ukfsn.o rg...[color=green]
              > >
              > > "Mr.Tickle" <MrTickle@mrmen .com> wrote in message
              > > news:uayG3ANiDH A.1180@TK2MSFTN GP12.phx.gbl...[color=darkred]
              > > > How can I impleement a singleton pattern in an abstract or interface for
              > > > inheritance to an object so all the pattern rules are followed on all
              > > > similar objects?[/color]
              > >
              > > I don't think you can in C#, until generics are added to the language (see
              > >[/color]
              > http://msdn.microsoft.com/library/de...us/dv_vstechar
              > t/html/vbconcprogrammi nglanguagefutur efeatures.asp)[color=green]
              > >
              > > Rob
              > >
              > >[/color]
              >
              >[/color]


              Comment

              Working...