design-patterns

When is Inversion of Control useful and when shouldn't it be used?

I've recently been bitten by code that uses Inversion of Control when it's not appropriate. Lately, I'm of the opinion that IoC is among the patterns that have the worst effect when misapplied. This is because it tends to create a coupling of classes that can cause a lot of shotgun surgery if you run into a circumstance that's a little...

Physical world examples of design for testability and test driven development

I'm going to be doing a presentation on unit testing and in doing so I will touch on "design for testability" patterns. In other words using IOC containers, Dependency Injection, avoiding static methods etc. I have a feeling my team will be cold to starting to code differently to accommodate for testing. So I was wondering if anybody ...

What is the correct way to make web form input safe for a variety of contexts?

What do you all think is the correct (read: most flexible, loosely coupled, most robust, etc.) way to make user input from the web safe for use in various parts of a web application? Obviously we can just use the respective sanitization functions for each context (database, display on screen, save on disk, etc.), but is there some gener...

Does .Net RIA Services introduce a coupling between Presentation and Application/Business Logic?

I'm new to .Net RIA Services, but I think, its essence, is to target RAD what Microsoft usually cares about. But, does not that introduce more coupling between Presentation and Application/Business Logic? How can this new technology help increasing number of developers who are interested in OOAD Best Practices and concepts like SOLID, GR...

Set parent's status bar text?

I can set the parent's status bar text with this function I wrote void EditorWindow::setStatusBarText(const QString& text) { statusBar()->showMessage(text); } Called like this (from child) ((EditorWindow*) parent())->setStatusBarText(tr("%1, %2").arg(mousePos.x(), 0, 'f', 2).arg(mousePos.y(), 0, 'f', 2)); But I'm pretty sure th...

Can MVVM gives any advantage if databinding is not used between view and viewmodel?

In MVVM, The ViewModel is a model for the view. And the real power comes in when we bind ViewModel to View in WPF. However, if third party control does not support data-binding (not supporting all functionality), in that case is it worthwhile to use MVVM? ...

Which pattern for adding a comment to a wiki page?

Which pattern could be used in web projects? I am developing a wiki project with ASP.NET. In my structure every wiki entry could have comments. Which way is the best : wikiEntry.AddComments(newComment); wikiEntry.Comments.Add(newComment); entryManager.AddComment(wikiEntry, newComment); ...

making a windows forms validation library for own use

I wish to make controls like textbox, combobox, listbox and other user editable controls to be bound with validation, so i thought of extending the existing controls and make a new VTextBox, VComboBox, VListBox which have a validationregex property and an error provider component attached with them. My prime aim is to have validation att...

How do you use Presentation Model with Winforms?

Would Like to know how best to implement the Presentation Model pattern. I have read about MVVM but does not apply to me as I'm not using Silverlight or WPF. ...

Confused by Django's claim to MVC, what is it exactly?

So what exactly is Django implementing? Seems like there are Models Views Templates Models = Database mappings Views = Grab relevant data from the models and formats it via templates Templates = Display HTML depending on data given by Views EDIT: S. Lott cleared a lot up with this in an edit to a previous post, but I...

When do i need to stop using design patterns?

My colleagues are going crazy because i keep on wanting to rewrite code that already works because i would like to replace some legacy design with design pattern. Although i feel like it will help improve the existing code, I do feel like i am getting a little paranoid about it and try to use them everywhere and even replacing one design...

Repository pattern: Strategy for listing members

I'm building a set of CRUD screens for a Repository. The member objects are large enough that I'd rather not load lots of them into memory all at once - as when generating search results. Since all I need for search results are a couple of properties - e.g., "name" and "id" - I could just query the underlying database - but I don't want...

States and controllable game objects

We are making a game with a playing character that will have several different states. In most examples I see a switch statement in the controllable charactor based on the state. Is this the standard way that things are done for most games? Or is it better to create a set of states that handle the animation and logic of that state. It se...

C# Property System

Update Sorry. I didn't mean the whole reflection library was off limits. I just meant the insanely slow *.Invoke() stuff. Hi, I need to implement a property system in C# that allows both normal property access [property_attribute()] return_type Property { get; set; } and access by string SetProperty(string name, object value); obje...

Web App architecture questions

Background: I am an intermediate web app developer working on the .Net Platform. Most of my work has been defined pretty well for me by my peers or superiors and I have no problem following instructions and getting the job done. The task at hand: I was recently asked by an old friend to redo his web app from scratch. His app is extreme...

MVC / MVP / MVVM What the Heck?

I recently worked on a .Net WPF project to build a retail point of sale system where I used the MVP pattern for the first time. It took me a little while to wrap my head around the change of approach but once I did that I thought that the concept rocked! My question is this: what is the distinction between MVC, MVP and MVVM? If there is...

Understanding Adapter Pattern

I am trying to understand Adapter patter and its use in real world. After going through various articles on internet and www.dofactory.com, I created this sample code. I just want to know whether my understanding is correct. In the sample below I have created MSDAO object in the Adaptor class. Later I changed it to OracleDAO. class Clie...

Deploying a big test disguised as a program

If someone has created a small diagnostic, internal web app that uses (unit) tests as its logic, is there ever a valid reason to do that? Keep in mind that Nunit has to be deployed as well where ever this website goes. I'm of the view that programs should contain their own logic and possibly reusable parts (if available) but not wrap t...

What's Alternative to Singleton

We have a class that holds configuration information for the application. It used to be a singleton. After some architectural review, we were told to remove the singleton. We did see some benefits of not using singleton in the unit testing because we can test different configurations all at once. Without singleton, we have to pass the i...

What Belongs in a Repository and What Doesn't?

In an ASP.NET MVC application implementing the repository pattern I am curious if it is appropriate to place non-data related methods in the repository if they still pertain to the general focus of a given repository. For example, suppose a ProductsRepository that has methods for adding and deleting ProductImages which have a partial rep...