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. The Lounge
  3. Is this a known pattern?

Is this a known pattern?

Scheduled Pinned Locked Moved The Lounge
csharpregexquestion
54 Posts 33 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.
  • B BobJanova

    I'm thinking condition-based programming. I'm not sure if I just made that up right now though. Also, isn't that exactly the type of thing you can already do with a Linq query? It is elegant, just like Linq, and it's a good thing to do as long as you can implement it in such a way that the condition is only executed as little as possible, and you don't have to load the whole potential result set into memory and then filter it. It's more functional programming than declarative, I think. In languages where functions are first class objects (e.g. Javascript) it is more common to pass filter functions or other types of function (for example a sort order comparator) around and potentially declare them locally as you have done here. What you're passing in the 'where' parameter is a pure function.

    N Offline
    N Offline
    Nicholas Butler
    wrote on last edited by
    #19

    BobJanova wrote:

    Also, isn't that exactly the type of thing you can already do with a Linq query?

    Yes, it's certainly like Linq :-D The difference is that it may or may not cause a Linq-to-Entities query to run and hit the database server.

    BobJanova wrote:

    It's more functional programming than declarative, I think.

    Yes, I suppose it is. I was focused on making it easy to use rather than the programming paradigm. Thanks, Nick

    www.NickButler.net

    1 Reply Last reply
    0
    • N Nicholas Butler

      I'm having difficulty finding a name for a style of programming. You can make one up if you like, but I'd prefer something that is already documented :) I've written a layer over the Entity Framework that allows the application code to pass parameters into the data layer that shape the returned result sets. So you can write something like this:

      List users = DAL.User.FetchAll( where: user => user.Age > 21 );

      It's declarative programming, but I was looking for a more specific name. Something like "locality of intent". Basically, you say what you need in the place where you need it. It's the opposite of having a data layer method like this:

      List FetchAllUsersWhereAgeGreaterThan( int minimumAge )

      Is this a known pattern? I've run out of obvious words to Google. Ta, Nick

      www.NickButler.net

      T Offline
      T Offline
      TheGreatAndPowerfulOz
      wrote on last edited by
      #20

      I don't know if it's known or not. You could call it "Query Mapper"

      If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
      You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

      1 Reply Last reply
      0
      • P Pete OHanlon

        Nicholas Butler wrote:

        I just called it caching

        Most people do. First law of patterns. They are a fancy name for stuff you already do.

        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

        My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

        N Offline
        N Offline
        Nicholas Butler
        wrote on last edited by
        #21

        Pete O'Hanlon wrote:

        First law of patterns. They are a fancy name for stuff you already do.

        Along with the first law of programming ( "it's already been done" ), I was hoping someone had already come up with the fancy name. Nick

        www.NickButler.net

        1 Reply Last reply
        0
        • N Nicholas Butler

          I'm having difficulty finding a name for a style of programming. You can make one up if you like, but I'd prefer something that is already documented :) I've written a layer over the Entity Framework that allows the application code to pass parameters into the data layer that shape the returned result sets. So you can write something like this:

          List users = DAL.User.FetchAll( where: user => user.Age > 21 );

          It's declarative programming, but I was looking for a more specific name. Something like "locality of intent". Basically, you say what you need in the place where you need it. It's the opposite of having a data layer method like this:

          List FetchAllUsersWhereAgeGreaterThan( int minimumAge )

          Is this a known pattern? I've run out of obvious words to Google. Ta, Nick

          www.NickButler.net

          R Offline
          R Offline
          R Giskard Reventlov
          wrote on last edited by
          #22

          YAPNBUDP - Yet another pretentiously named but unnecessary design pattern :)

          "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

          1 Reply Last reply
          0
          • P Pete OHanlon

            As an alternative, it also looks a bit like a Query Object - mapping onto a Repository pattern.

            *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

            "Mind bleach! Send me mind bleach!" - Nagy Vilmos

            My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

            V Offline
            V Offline
            Vivi Chellappa
            wrote on last edited by
            #23

            There you have it: QORP!

            1 Reply Last reply
            0
            • N Nicholas Butler

              peterchen wrote:

              It's known as PNAMUT - Pretentious Name for Muddling Through.

              Correct, but not very catchy :)

              peterchen wrote:

              The purpose of the data layer method (as you call it) is to protect the application against changes; e.g. a new privacy regulation mandates you may not track age, only states such as "above minimum drinking age".

              That was a contrived example but I agree: it's certainly not High Church. Nick

              www.NickButler.net

              P Offline
              P Offline
              peterchen
              wrote on last edited by
              #24

              When you pronounce it quickly, you can make it sound almost like "PEANUT".

              FILETIME to time_t
              | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

              K 1 Reply Last reply
              0
              • N Nicholas Butler

                I'm having difficulty finding a name for a style of programming. You can make one up if you like, but I'd prefer something that is already documented :) I've written a layer over the Entity Framework that allows the application code to pass parameters into the data layer that shape the returned result sets. So you can write something like this:

                List users = DAL.User.FetchAll( where: user => user.Age > 21 );

                It's declarative programming, but I was looking for a more specific name. Something like "locality of intent". Basically, you say what you need in the place where you need it. It's the opposite of having a data layer method like this:

                List FetchAllUsersWhereAgeGreaterThan( int minimumAge )

                Is this a known pattern? I've run out of obvious words to Google. Ta, Nick

                www.NickButler.net

                B Offline
                B Offline
                Baxter R Pearson
                wrote on last edited by
                #25

                I use this stuff all the time, and love it !! Linq, Lamdas, Linq with Lamdas.. It saves a lot of time with EF.

                N 1 Reply Last reply
                0
                • N Nicholas Butler

                  I'm having difficulty finding a name for a style of programming. You can make one up if you like, but I'd prefer something that is already documented :) I've written a layer over the Entity Framework that allows the application code to pass parameters into the data layer that shape the returned result sets. So you can write something like this:

                  List users = DAL.User.FetchAll( where: user => user.Age > 21 );

                  It's declarative programming, but I was looking for a more specific name. Something like "locality of intent". Basically, you say what you need in the place where you need it. It's the opposite of having a data layer method like this:

                  List FetchAllUsersWhereAgeGreaterThan( int minimumAge )

                  Is this a known pattern? I've run out of obvious words to Google. Ta, Nick

                  www.NickButler.net

                  U Offline
                  U Offline
                  User 3882831
                  wrote on last edited by
                  #26

                  'Specification Pattern' with only one logical chain.

                  1 Reply Last reply
                  0
                  • N Nicholas Butler

                    I'm having difficulty finding a name for a style of programming. You can make one up if you like, but I'd prefer something that is already documented :) I've written a layer over the Entity Framework that allows the application code to pass parameters into the data layer that shape the returned result sets. So you can write something like this:

                    List users = DAL.User.FetchAll( where: user => user.Age > 21 );

                    It's declarative programming, but I was looking for a more specific name. Something like "locality of intent". Basically, you say what you need in the place where you need it. It's the opposite of having a data layer method like this:

                    List FetchAllUsersWhereAgeGreaterThan( int minimumAge )

                    Is this a known pattern? I've run out of obvious words to Google. Ta, Nick

                    www.NickButler.net

                    N Offline
                    N Offline
                    Nathan Gloyn
                    wrote on last edited by
                    #27

                    Isn't it just a simple Facade pattern?

                    N 1 Reply Last reply
                    0
                    • N Nicholas Butler

                      I'm having difficulty finding a name for a style of programming. You can make one up if you like, but I'd prefer something that is already documented :) I've written a layer over the Entity Framework that allows the application code to pass parameters into the data layer that shape the returned result sets. So you can write something like this:

                      List users = DAL.User.FetchAll( where: user => user.Age > 21 );

                      It's declarative programming, but I was looking for a more specific name. Something like "locality of intent". Basically, you say what you need in the place where you need it. It's the opposite of having a data layer method like this:

                      List FetchAllUsersWhereAgeGreaterThan( int minimumAge )

                      Is this a known pattern? I've run out of obvious words to Google. Ta, Nick

                      www.NickButler.net

                      J Offline
                      J Offline
                      jim lahey
                      wrote on last edited by
                      #28

                      My favourite patterns in order are: Paisley, spirals and tiger stripes.

                      1 Reply Last reply
                      0
                      • N Nicholas Butler

                        I'm having difficulty finding a name for a style of programming. You can make one up if you like, but I'd prefer something that is already documented :) I've written a layer over the Entity Framework that allows the application code to pass parameters into the data layer that shape the returned result sets. So you can write something like this:

                        List users = DAL.User.FetchAll( where: user => user.Age > 21 );

                        It's declarative programming, but I was looking for a more specific name. Something like "locality of intent". Basically, you say what you need in the place where you need it. It's the opposite of having a data layer method like this:

                        List FetchAllUsersWhereAgeGreaterThan( int minimumAge )

                        Is this a known pattern? I've run out of obvious words to Google. Ta, Nick

                        www.NickButler.net

                        B Offline
                        B Offline
                        Brandon Ledbetter
                        wrote on last edited by
                        #29

                        I have been working with a pattern called "composite specification" that uses lambda expressions in this way. We are looking at combining it's use with NHibernate, which can turn the composed lambdas into SQL. Seems like a pretty powerful, flexible approach to me.

                        N 1 Reply Last reply
                        0
                        • N Nicholas Butler

                          I'm having difficulty finding a name for a style of programming. You can make one up if you like, but I'd prefer something that is already documented :) I've written a layer over the Entity Framework that allows the application code to pass parameters into the data layer that shape the returned result sets. So you can write something like this:

                          List users = DAL.User.FetchAll( where: user => user.Age > 21 );

                          It's declarative programming, but I was looking for a more specific name. Something like "locality of intent". Basically, you say what you need in the place where you need it. It's the opposite of having a data layer method like this:

                          List FetchAllUsersWhereAgeGreaterThan( int minimumAge )

                          Is this a known pattern? I've run out of obvious words to Google. Ta, Nick

                          www.NickButler.net

                          F Offline
                          F Offline
                          Fabio Franco
                          wrote on last edited by
                          #30

                          How about LOOP? LINQ-Object Oriented Programming

                          "To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson

                          1 Reply Last reply
                          0
                          • N Nicholas Butler

                            I'm having difficulty finding a name for a style of programming. You can make one up if you like, but I'd prefer something that is already documented :) I've written a layer over the Entity Framework that allows the application code to pass parameters into the data layer that shape the returned result sets. So you can write something like this:

                            List users = DAL.User.FetchAll( where: user => user.Age > 21 );

                            It's declarative programming, but I was looking for a more specific name. Something like "locality of intent". Basically, you say what you need in the place where you need it. It's the opposite of having a data layer method like this:

                            List FetchAllUsersWhereAgeGreaterThan( int minimumAge )

                            Is this a known pattern? I've run out of obvious words to Google. Ta, Nick

                            www.NickButler.net

                            A Offline
                            A Offline
                            Alessandro Degola
                            wrote on last edited by
                            #31

                            when you use lambda expression and delegates, these are a variant of the observer pattern.

                            1 Reply Last reply
                            0
                            • N Nicholas Butler

                              I'm having difficulty finding a name for a style of programming. You can make one up if you like, but I'd prefer something that is already documented :) I've written a layer over the Entity Framework that allows the application code to pass parameters into the data layer that shape the returned result sets. So you can write something like this:

                              List users = DAL.User.FetchAll( where: user => user.Age > 21 );

                              It's declarative programming, but I was looking for a more specific name. Something like "locality of intent". Basically, you say what you need in the place where you need it. It's the opposite of having a data layer method like this:

                              List FetchAllUsersWhereAgeGreaterThan( int minimumAge )

                              Is this a known pattern? I've run out of obvious words to Google. Ta, Nick

                              www.NickButler.net

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #32

                              List users = DAL.User.FetchAllUsersOfLegalDrinkingAge(); Then define a static list with all countries and districts with said age. I hate parameters. Edit: (And yes it may be the facade pattern)

                              _ 1 Reply Last reply
                              0
                              • B Baxter R Pearson

                                I use this stuff all the time, and love it !! Linq, Lamdas, Linq with Lamdas.. It saves a lot of time with EF.

                                N Offline
                                N Offline
                                Nicholas Butler
                                wrote on last edited by
                                #33

                                Baxter R Pearson wrote:

                                It saves a lot of time with EF.

                                Exactly :) I've sent you a PM - could you let me know if it doesn't come through ( sometimes they go missing. ) Nick

                                www.NickButler.net

                                1 Reply Last reply
                                0
                                • N Nathan Gloyn

                                  Isn't it just a simple Facade pattern?

                                  N Offline
                                  N Offline
                                  Nicholas Butler
                                  wrote on last edited by
                                  #34

                                  Nathan Gloyn wrote:

                                  Isn't it just a simple Facade pattern?

                                  It does hide a lot of complexity, but I think the difference is that the parameters passed are functions not values. I don't know if that makes it a different pattern, though :) Nick

                                  www.NickButler.net

                                  N 1 Reply Last reply
                                  0
                                  • N Nicholas Butler

                                    Nathan Gloyn wrote:

                                    Isn't it just a simple Facade pattern?

                                    It does hide a lot of complexity, but I think the difference is that the parameters passed are functions not values. I don't know if that makes it a different pattern, though :) Nick

                                    www.NickButler.net

                                    N Offline
                                    N Offline
                                    Nathan Gloyn
                                    wrote on last edited by
                                    #35

                                    From the all knowing Wikipedia: A facade is an object that provides a simplified interface to a larger body of code, such as a class library. A facade can: - make a software library easier to use, understand and test, since the facade has convenient methods for common tasks; - make the library more readable, for the same reason; Certainly sounds like its a facade based on that definition :)

                                    1 Reply Last reply
                                    0
                                    • N Nicholas Butler

                                      I'm having difficulty finding a name for a style of programming. You can make one up if you like, but I'd prefer something that is already documented :) I've written a layer over the Entity Framework that allows the application code to pass parameters into the data layer that shape the returned result sets. So you can write something like this:

                                      List users = DAL.User.FetchAll( where: user => user.Age > 21 );

                                      It's declarative programming, but I was looking for a more specific name. Something like "locality of intent". Basically, you say what you need in the place where you need it. It's the opposite of having a data layer method like this:

                                      List FetchAllUsersWhereAgeGreaterThan( int minimumAge )

                                      Is this a known pattern? I've run out of obvious words to Google. Ta, Nick

                                      www.NickButler.net

                                      J Offline
                                      J Offline
                                      Jonathan C Dickinson
                                      wrote on last edited by
                                      #36

                                      Technically it's a DSL (Domain Specific Language) implemented on top of a formal language. You can tell if it's a DSL if simply reading the words makes approximate sense in English: User fetch all where the user age is greater than 21. You could obviously improve it: Fetch all users where the user age is greater than 21.

                                      var users = Fetch.All.Users( where: user => user.Age > 21 );

                                      The paradigm you are using is very close to a fluent interface - technically fluent interfaces need to happen with method calls (DAL.Users().Where().Age().GreaterThan(21)) but there isn't any reason you can't violate that - especially if it increases clarity (which yours does).

                                      He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Chineese Proverb] Jonathan C Dickinson (C# Software Engineer)

                                      1 Reply Last reply
                                      0
                                      • B Brandon Ledbetter

                                        I have been working with a pattern called "composite specification" that uses lambda expressions in this way. We are looking at combining it's use with NHibernate, which can turn the composed lambdas into SQL. Seems like a pretty powerful, flexible approach to me.

                                        N Offline
                                        N Offline
                                        Nicholas Butler
                                        wrote on last edited by
                                        #37

                                        I've sent you a PM - could let me know if it goes missing? ( they sometimes do ) Nick

                                        www.NickButler.net

                                        1 Reply Last reply
                                        0
                                        • N Nicholas Butler

                                          I'm having difficulty finding a name for a style of programming. You can make one up if you like, but I'd prefer something that is already documented :) I've written a layer over the Entity Framework that allows the application code to pass parameters into the data layer that shape the returned result sets. So you can write something like this:

                                          List users = DAL.User.FetchAll( where: user => user.Age > 21 );

                                          It's declarative programming, but I was looking for a more specific name. Something like "locality of intent". Basically, you say what you need in the place where you need it. It's the opposite of having a data layer method like this:

                                          List FetchAllUsersWhereAgeGreaterThan( int minimumAge )

                                          Is this a known pattern? I've run out of obvious words to Google. Ta, Nick

                                          www.NickButler.net

                                          K Offline
                                          K Offline
                                          K Quinn
                                          wrote on last edited by
                                          #38

                                          Directed Expression Retrieval Pattern (DERP for short)

                                          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