design-patterns

Is it an example of decorator pattern?

Hi, I've an example please tell me whether it is Decorator pattern or not? public abstract class ComputerComponent { String description ="Unknown Type"; public String getDescription() { return description; } public abstract double getCost(); } public abstract class AccessoryDecorator { Computer...

How to manage interface segregation when using an IoC container?

I'm currently designing a small system and i'm currently using structureMap as IoC. I just recently got the point of interface segregation...and I'm wondering now. If I have a certain business object, that will implement say, three interfaces... how should I handle this in the configuration and instatiation of code? Assuming I have two...

Features of a robust WinForm application

[Based on the strong comment below (dated April 7 and 8, 2010) from when I originally posted this question, I took a hard look at what I wrote and asked myself "Huh? What am I really after here?" I decided drastic action was called for: discard the original text, make the question simpler and cleaner, and focus on what I really want to g...

good way to implement NotSpecification: isSpecialCaseOf?

I'm implementing the specification pattern. The NotSpecification seems simple at first: NotSpecification.IsSpecialCaseOf(otherSpecification) return !this.specification.isSpecialCaseOf(otherSpecification) But it doesn't work for all Specifications: Not(LesserThan(4)).IsSpecialCaseOf(Equals(5)) This should return false instead of...

Circular Dependency Solution

Our current project has ran into a circular dependency issue. Our business logic assembly is using classes and static methods from our SharedLibrary assembly. The SharedLibrary contains a whole bunch of helper functions, such as a SQL Reader class, Enumerators, Global Variables, Error Handling, Logging and Validation. The SharedLibrary ...

Naming convention for non-virtual and abstract methods

I frequently find myself creating classes which use this form (A): abstract class Animal { public void Walk() { // TODO: do something before walking // custom logic implemented by each subclass WalkInternal(); // TODO: do something after walking } protected abstract void WalkInternal(); } class Dog : Animal { ...

design using a readonly class in c#

Hi Small design question here. I'm trying to develop a calculation app in C#. I have a class, let's call it InputRecord, which holds 100s of fields (multi dimensional arrays) This InputRecordclass will be used in a number of CalculationEngines. Each CalculcationEngine can make changes to a number of fields in the InputRecord. These chan...

Repository pattern with lazying loading using POCO

Hi, I'm in the process of starting a new project and creating the business objects and data access etc. I'm just using plain old clr objects rather than any orms. I've created two class libraries: 1) Business Objects - holds all my business objects, all this objects are light weight with only properties and business rules. 2) Repository...

design pattern for related inputs

My question is a design question : let's say i have a data entry web page with 4 drop down lists, each depending on the previous one, and a bunch of text boxes. ddlCountry (DropDownList) ddlState (DropDownList) ddlCity (DropDownList) ddlBoro (DropDownList) txtAddress (TxtBox) txtZipcode(TxtBox) and an object that represents a dataro...

My User control belonging to which Design Pattern??

Hello, I am creating a reusable component in C#.net. For that i have started a Control Library project and added a Control. Class MyControl : Control{} My user control just displays some images which will be used in many Windows Applications. Can you please tell me which design pattern i am using here. I am unable to decide which pa...

How to switch easily between ajax-based website and basic HTML website?

Hi, I have a website ( based on JSP/Servlets ,using MVC pattern), and I want to support AJAX-based website and basic HTML-based website. website visitors should be able to change the surfing mode from Ajax to basic HTML and vise versa, - as it applies in Google-mail. The Questions : What is the best way to achieve this goal easily? Sh...

When do we use MVVM?

I have been hearing a lot of hype about MVVM for WPF. When do we use it? Is it a use for everything or does it only have specific uses? Is it worth it for every project? ...

Service Layer Pattern - Could we avoid the service layer on a specific case?

Hi, we are trying to implement an application using the Service Layer Pattern cause our application needs to connect to other multiple applications too, and googling on the web, we found this link of a demonstrative graphic for the "right" way of apply the pattern: martinfowler.com - Service Layer Pattern But now we have a question: wh...

Could someone in simple terms explain to me the visitor pattern's purpose with examples if possible

Hi, I'm really confused about the visitor pattern and its uses. I can't really seem to visualize the benefits of using this pattern or its purpose. If someone could explain with examples if possible that would be great. =) Thanks in advance ...

Which is the most memory leak safe approach.

I have a table of frequently updated information. This is presented using a container div with a div for each row, each row containing 10 divs. I am using setInterval to call a an asmx webservice that returns some json formatted information. On the success callback I call $("#myContainer").empty(); on the container div and recreate the...

What pattern to use in this scenario?

Hi, We have got many forms(windows app C#) in our application.We have similar steps in most of them - user adds a new object(in a grid),fills values and save.On,save,we validate,and save if everything ok,else show message.Now,adding of object usually means we add a new row with some default values. ...

ASP.net Integration Pattern - examples

Recently lot of interviewers are asking "What are the integration patterns are you familiar with?". I know design patterns,what is integration pattern then? ...

Linq to sql Repository pattern , Some doubts

I am using repository pattern with linq to sql, I am using a repository class per table. I want to know , am i doing at good/standard way, ContactRepository Contact GetByID() Contact GetAll() COntactTagRepository List<ContactTag> Get(long contactID) List<ContactTag> GetAll() List<ContactTagDetail> GetAllDetails() class Co...

Question about design (inheritance, polymorphism)

Hi, I have a question about a problem I'm struggling with. Hope you can bear with me. Imagine I have an Object class representing the base class of a hierarchy of physical objects. Later I inherit from it to create an Object1D, Object2D and Object3D classes. Each of these derived classes will have some specific methods and attributes....

Example with Visitor Pattern

public class Song { public string Genre { get; protected set; } public string Name { get; protected set; } public string Band { get; protected set; } public Song(string name, string band, string genre) { Name = name; Genre = genre; Band = band; } } public interface IMusicVisistor { void V...