design-patterns

How can I simplify hierarchical class structure resulting in chained method calls?

I have the following hierarchy of classes in a problem that I am working on. DiscountEvent DiscountGroup ProductFamily Product where each class contains a collection of next one (e.g. DiscountEvent contains a collection of DiscountGroups, etc) This kind of a somewhat deep hierarchy results in many chained calls from the h...

Default value of Version class: null or (0,0)?

Hello, we identify client software using Version class and use these values extensively, we also store these values in database. How would you store unknown version value? We can get unknown version value if we wasn't able to successfully query client version. I ask because I'm fond of Null object pattern, I don't like constant checks...

Adding access control in GWT based applications.

I have a GWT based application. I want to add access control to it. Is there a way to add custom access control for GWT components? My idea about adding access control/permissions would be as following. Add access control annotation (if there exists one) to the class (GWT component) for which I need to add access control. When this ...

Design Issue: Good or bad to make the cached entities mutable?

Hi guys, Here I need to cache some entites, for example, a Page Tree in a content management system (CMS). The system allows developers to write plugins, in which they can access the cached page tree. Is it good or bad to make the cached page tree mutable (i.e., there are setters for the tree node objects, and/or we expose the Add, Remo...

JS add callback to run next function?

How do I add some sort of call back so that I can run further code after render() has completed? function next(){ target = max; render(); //When render complete, do some more //change values.... //render(); } function prev(){ target = min; render(); //When render complete, do some more } var timer; ...

In the end aren't all designs hard to maintain?

I have looked and thought about good and bad points of my past designs and considering my next venture and what it should be. Everyone says MVC and others say one design doesn't fit all. Frameworks don't help me a whole lot for my projects, mostly because of legacy databases, and my past ideas weren't terribly horrible for the time. O...

How to reduce duplication in code - If statements vs separate class

Let's say you have a website that lets you build an account with up to three different account owners. Each entry page for the owner is a separate aspx page. The first person has very different business rules than the second and third owners. The first will have more fields as well and different ones will be required for them but not f...

What's the point of a logging facade?

There are a bunch of different logging libraries to choose from, each with their own set of quirks and advantages. (.Net examples: log4net, System.Diagnostics.TraceSource, nLog, etc.) The natural inclination is to abstract away those quirks and use a logging facade. (examples: Castle.Services.Loigging, Common.Logging, Simple Logging Fa...

Java Map anti-pattern?

Edit: I've gotten a couple of answers that say what I already said in the question. What I am really interested in is finding corroborating reference material. I am looking at a code sample that more or less follows this pattern: Map<String, List> getListsFromTheDB() { Map<String, List> lists = new HashMap<String, List>(); //eac...

Is Data Mapper a more modern trend than Active Record

I've come across a couple of ORMs that recently announced they are planning to move their implementation from Active Record to Data Mapper. My knowledge of this subject is very limited. So a question for those who know better, is Data Mapper newer than Active Record? Was it around when the Active Record movement started? How do the two r...

Dynamic object creation pattern - I love

Hi, Recently I came up with the idea of simple pattern for dynamic creation of object. And I real love it. I am sure that that "wheel" was invented and named. Could someone could point to some GOF pattern? Problem: have huge number of objects that I don't want to have all initialized at the beginning. All are instances of one class. I...

Should the Managed Extensibility Framework be used to consume external plugins?

I think i get the MEF model. But I'm having a hard time seeing if it fit's with what I'm trying to do. I have an app which will call out to third party plugins to do some video processing. The plugin can be FFMPEG.exe or x264.exe, doesn't matter. The process of calling the plugins is via the ProcessStartInfo (basically through the co...

How to design a html form to feed something like hirachical

in html Every node have it's subnode [not required] can be have parent node. i want to design a webform which can be used to feed something and after submission i update them using json. after that i need that without going anywhere he can feed his childnode and parent node. how i can make a webform who can solve this issue for me ...

delegation vs aggregation vs consultation

hello, everyone what is the difference between these terms, can you give please small examples thanks in advance ...

What good patterns for a web framework are out there?

What are design patterns that would be useful for a web framework besides MVC, the Rails-induced frenzy? Not saying it's a bad thing, but it is now practically ubiquitous in web frameworks. Ideally the pattern should make easier: Separation of concerns Modularity / reusability of code Unit testing What patterns fit the bill? Are the...

Have you ever seen someone try to implement the MVP pattern with ASP.NET Web Forms?

Have you ever seen someone try to implement the MVP pattern with ASP.NET Web Forms? And if so, how did they do it? I'm working with a code base that is more than 10 years old. Before I arrived, somebody tried to implement the MVP pattern with ASP.NET Web Forms. I'm just wondering if this is unique to my code base or if other...

Assembly reference error with C# EF4 and a layered design.

Hi all, I'm finally getting around to checking out the latest EF release and I'm running into some troubles with my testing. So, my DAL layer holds my .EDMX file and I'm using the MS POCO template so I also have the generated .TT files and classes. I have a generic base class in the TestProject.DAL I've created that those classes deri...

delegation vs consultation

hello everyone, can somebody explain me what is the difference between those two terms, found some information here http://javalab.cs.uni-bonn.de/research/darwin/delegation.html but can't understand thanks in advance ...

Can the model, view, and controller be in one physical code page?

Reference this question I asked: http://stackoverflow.com/questions/3833324/how-do-you-pass-values-between-php-pages-for-mvc Based upon the answers it seems everything can be in one page and it's only separated by classes and object in a logical sense. Can MVC be one physical page but three logical parts and still be "MVC"? Of the fr...

Strategy Pattern with no 'switch' statements?

I've been doing some reading on the Strategy Pattern, and have a question. I have implemented a very basic Console Application below to explain what I'm asking. I have read that having 'switch' statements is a red flag when implementing the strategy pattern. However, I can't seem to get away from having a switch statement in this exam...