109 Actions

Pattern for caching DAOs: strategy or decorator?@antonienko Some patterns are very similar, but with a different intent. That's the case of a proxy and a decorator yes. So, for me, your decorator working in that manner would be categorized as a proxy, at least in my opinion and understanding of the subject.

Dec24

comment

Pattern for caching DAOs: strategy or decorator?@Hey I think memoization is an alternative that uses a more functional approach. In this case functions are memoized by wrapping them into another function that is smart enough to use a cache when necessary. The proxy sounds more like OO approach. I guess depending on the implementing language one or the other could be more easily achieved.

Dec24

comment

Pattern for caching DAOs: strategy or decorator?Well, I am certainly not a world class expert on the subject, but I think the conceptual difference here is that the decorator is supposed to forward requests to its decorated component object. It may optionally perform additional operations, before and/or after forwarding the request, but the forward always happens. With a proxy the story is different, and in the case of a cache you may decide never to forward the request to the proxied object if the cache is still fresh and alive.

Why lambda/closures expressions came so late to C++?@Doval Precisely my point. Closures and lambda expressions were already pretty, pretty popular before LINQ. The fact that Java and C# are mainstream programming languages have simply make them more popular than they were to more programmers. Above all to those who have never programmed in other languages and were probably unfamiliar with the topics this might sound like revolutionary, but for many others there is not a big surprise here.

Dec24

comment

Why lambda/closures expressions came so late to C++?@SK-logic I have to disagree on the influence of LINQ. Closures are the oldest trick in the book. They existed before the first computer was ever created and they first appear in LISP in the late 50s, ML (70s), Haskell (80s) then other languages adopted them Python, Ruby, JavaScript, then a rebirth of functional programming in 2000 with Scala, Clojure and F# among others. Actually C# and Java are the oldest languages to adopt this. Now you are not going to say that LINQ popularized high order programming. This is just the result of the natural evolution of languages.

How to avoid programmers duplicating codeSee the problem from another angle, instead of thinking that the problem is the code duplication, we may consider if the problem originates in the lack of policies for code reuse. Recently I read the book Software Engineering with Reusable Components and it indeed has a set of very interesting ideas on how to foster code reusability at the organization level. I will answer in the related question.