|
|
Sounds like someone has a case of the Mondays.
|
|
|
|
|
As long as the pink hearts aren't yellow... 
|
|
|
|
|
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<User> 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<User> FetchAllUsersWhereAgeGreaterThan( int minimumAge )
Is this a known pattern? I've run out of obvious words to Google.
Ta,
Nick
|
|
|
|
|
shouldn't it be
List<User> users = FetchAllUsersWhereAgeGreaterThan( int minimumAge )
that is called OOP.
|
|
|
|
|
Shouldn't that be
List<User> users = FetchAllUsersWhereAgeGreaterThan( int minimumAge );
I assumed it was originally the method declaration, rather than the use, myself.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Yes, it was - thanks
|
|
|
|
|
Call it the Nick Fetch Pattern.
Make it part of the Nick Sterling Framework.
Trade mark it, develop some course work, cash in on consulting.
Developer 1: What framework are you using?
Developer 2: I'm using the Sterling Framework.
Developer 1: Was that the one developed by Nick?
Developer 2: Heck ya.
Developer 1: I wish I could afford it.
Developer 2: With the student discount it's only $899.00
Developer 1: Swwweeeeeeet!
Don't worry about content.
That's why there is marketing.
|
|
|
|
|
Excellent idea - ta
Do you think "Nick Needs Sterling" is giving too much away?
Nick
|
|
|
|
|
Nicholas Butler wrote: List<User> users = DAL.User.FetchAll( where: user => user.Age > 21 );
Sadly, I like it!
|
|
|
|
|
leppie wrote: Sadly, I like it!
Thanks leppie . The more I use it, the more I like it too
Just can't find a good name for it...
Nick
|
|
|
|
|
It's known as PNAMUT - Pretentious Name for Muddling Through.
Sorry
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".
(before anyone barks back please consider that I nowhere endorsed or condemned either method)
|
|
|
|
|
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
|
|
|
|
|
When you pronounce it quickly, you can make it sound almost like "PEANUT".
|
|
|
|
|
How about "Pin A Mutt"? Kind of like "Pin the tail...", however I'm thinking along the lines of blindfold, crochet(sp?) needle, and a live dog running around. PETA may have a problem with that.
PS When I had a dog, I'd never have volunteered him for this "game".
|
|
|
|
|
The closest version of this that I could see without contemplating my navel would be an Identity Map. It's not a 100% fit, but it does fit some of your intent.
|
|
|
|
|
Interesting. I have also implemented this in my framework, but I just called it caching.
Nick
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
Like AJAX, we were doing that "call the server without reloading the page" years before they came up with the name, first using hidden frames, then iFrames and finally XmlHttpRequest!.
And Ajax will always remain a cleaning product for me, not a programming thing.
|
|
|
|
|
Agreed. Some 10 years ago, when I designed an architecture and had it reviewed, I've been told that I've implemented an Observer Pattern. I had to ask what he was talking about - I had never heard of Design Patterns before!
After reading up about them I realized they only really described a ton of things I already knew and did use.I just didn't think to come up with a name for these patterns and write a book! 
|
|
|
|
|
I like to call it poor programming. But I am outnumbered in the MS world.
|
|
|
|
|
Suggestion:
Predicated Queries/Query
Henry Minute
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
Cogito ergo thumb - Sucking my thumb helps me to think.
|
|
|
|
|
Henry Minute wrote: Predicated Queries/Query
I like it - thanks Henry
Nick
|
|
|
|
|
You can design any method to use a predicate like that. It isn't rocket science - it's LINQ:
IEnumerable<T> Fetch<T>(Func<T, bool> predicate){
return repository.Where(predicate);
}
...as long as you are using the repository that contains type `T`.
|
|
|
|