design-patterns

What is difference between published and public methods / attributes?

According to Martin Fowler "Something can be public but that does not mean you have published it." Does this mean something like this: public interface IRollsRoyceEngine { void Start(); void Stop(); String GenerateEngineReport(); } public class RollsRoyceEngine : IRollsRoyceEngine { public bool EngineHasStarted { get; i...

Are design patterns in JavaScript helpful? And what exactly are they?

I have been learning more and more javascript; it's a necessity at my job. We have a web application that uses a lot of javascript and I will be doing more and more every day. I have read bits and pieces about design patterns, but was wondering if someone could just give me a cut and dry example and definition. Are they something that wo...

Notify panel similar to stackoverflow's

Remember the little div that shows up at the top of the page to notify us of things (like new badges)? I would like to implement something like that as well and am looking for some best practices or patterns. My site is an ASP.NET MVC app as well. Ideally the answers would include specifics like "put this in the master page" and "do th...

When to separate certain entities into different repositories?

I generally try and keep all related entities in the same repository. The following are entities that have a relationship between the two (marked with indentation): User UserPreference So they make sense to go into a user repository. However users are often linked to many different entities, what would you do in the following examp...

Real World Example of the Strategy Pattern

Hi All, I've been reading about the OCP principal and how to use the strategy pattern to accomplish this. I was going to try and explain this to a couple of people, but the only example I can think of is using different validation classes based on what status an "order" is. I've read a couple of articles online, but these don't usuall...

How do you implement constructor injection in a factory?

When you're using a factory pattern, how do you inject dependencies into constructors at runtime? I'm building Foos with different formats - boolean, array, freetext, matrix, etc. That format list will grow as we find different uses for Foo. Here's my basic core domain: public interface IFoo { FooFormat Format { get; } } public ...

When would you use the mediator design pattern

As the title states when would you recommend the use of the mediator design pattern and where do you see it used incorrectly? ...

Elegant way to prevent circular events in MVC?

The question, in brief: In MVC, how do you distinguish between a checkbox click (or a selectbox or listbox change) from a human meaning "Controller, modify the model", and a checkbox click (or a selectbox or listbox change) from the Controller meaning "I'm updating the view because the model has changed"? The example: I have a JS ap...

Examples of design pattern misuse

Design patterns are great in that they distill a potentially complex technique into something idiomatic. Often just the fact that it has a name helps communication and understanding. The downside is that it makes it easier to try to use them as a silver bullet, applying them to every situation without thinking about the motivation behin...

Should I use the Model-View-ViewModel (MVVM) pattern in Silverlight projects?

One challenge with Silverlight controls is that when properties are bound to code, they're no longer really editable in Blend. For example, if you've got a ListView that's populated from a data feed, there are no elements visible when you edit the control in Blend. I've heard that the MVVM pattern, originated by the WPF development comm...

How many lines of code is in your custom jQuery script on your site? And how much is too much?

For our site, Im using a lot of jQuery - right now Im looking at 340 lines of jQuery code on top of the base library. How much is too much? I will be adding more, when do I start trying to condense the code and eventually move to OOP? ...

'Friends' equivalent for Java?

Hi guys, having a little architectural trouble here. In C++, we have the notion of 'friends,' where such friend classes can access private members. So, I'm deving a Java app and trying to adhere to the MVC architecture. I've got a controller class that manages graph connectivity between 'map_objects.' I'd like to hide the function in t...

DCI - Data, Context and Interaction (Successor to MVC?)

What is the best description of Data, Context and Interaction (DCI) to pitch it to an organization? There is no Wikipedia-article up on the subject yet. It's created by Trygve Reenskaug, the creator of the MVC-pattern. Is it really the successor to MVC or just another pattern? And what are its pros and cons? ...

What books have helped you get a grasp of n-Tier development

What books have helped you get a grasp of n-Tier development (Presentation Layer, UI Business Objects, Data Business Objects, and Data sets)? I'd prefer books, but blogs and other sites are welcome suggestions too. I've inherited a n-Tier designed application at a new job and although it's taken me some time to get used to it, I see ...

Avoiding Inheritence Madness

So, I have an API that I need to implement in to an existing framework. This API manages interactions with an external server. I've been charged with coming up with a way to create an easily repeatable "pattern," so that if people are working on new projects in the given framework they have a simple solution for integrating the API. ...

Pattern for UI: Same object, displayed differently

Hello all! I have an application for entering in serial numbers to a database. A serial number has a set number of attributes that defines it and the the user must/may provide them to generate. public class Serial { public string Number {get; set;} public string Part {get; set;} public string MfgOrder {get; set;} publi...

Getting Data From a Composite Control - Visitor Pattern?

I've got some rather complex forms, that need to be configured by web designers. I've been building some composite controls that appear to be doing the job. The top level control is simply a container, and the sections of the form are contained within. SubControls implement common interfaces, (i.e. NeptuneAddressControl and MarsAddres...

What is the Action Design Pattern?

What is the Action Design Pattern, I haven't heard of it before? I am suspecting it is the same as the Command Design pattern [wikipedia] but I can't find any resources on it. ...

Is there any good framework or library for c# snips of design-patterns?

We want to build a library of c# snips for .NET. We are looking around to see if there is something similar out there. The library will be open source and free to use and distribute. I see there is a similar question here, but is more theoretical than practical, I want to have Good Source of .NET Dsg Patterns. Any help will be grea...

What is a good design pattern to implement a dynamic data importer tool?

We are planning to build a dynamic data import tool. Basically taking information on one end in a specified format (access, excel, csv) and upload it into an web service. The situation is that we do not know the export field names, so the application will need to be able to see the wsdl definition and map to the valid entries in the o...