I've been trying to come up with a way to write generic repositories that work against various data stores:
public interface IRepository
{
IQueryable<T> GetAll<T>();
void Save<T>(T item);
void Delete<T>(T item);
}
public class MemoryRepository : IRepository {...}
public class SqlRepository : IRepository {...}
I'd like to w...
Is there a catch or hidden problem in using a DisposableBase base class instead of recoding the Dispose pattern on every class?
Why aren't everyone using such a relevant class?
Edits:
I naturally only meant classes that implement IDisposable
I know it uses up the option for inheritance, but I'm willing to pay the price (at least when...
Can this be done without MVC?
Is there an easy way to abstract or encapsulate navigational logic?
I currently have quite a lot of the following in my code behinds (and I know it's probably not the best thing to be doing):
protected void btnNext_Click(object sender, EventArgs e)
{
...
if (condition1)
{ Response.Redirect("~/N...
I am implementing an asynchronous command pattern for the "client" class in a client/server application. I have done some socket coding in the past and I like the new Async pattern that they used in the Socket / SocketAsyncEventArgs classes.
My async method looks like this: public bool ExecuteAsync(Command cmd); It returns true if the e...
If you read other people's source code, how do you approach the code? What patterns are you looking for (datatypes, loops, use of control flow, ... )? How long can you read other people's code without getting bored? What is the most exciting patterns that you have discovered so far?
...
C# 3.0 Extension methods add extensions to the base Type making calling that method on all instances of that Type legal.
Now, JavaScript I know implements IDispatchEx through which it's possible to add methods to a specific instance.
So how do I add a set of methods to an 'instance' of a C# class? I know this is a Dynamic vs. Static L...
What's the general consensus?
If you need to change the database after a given action, do you use an observer pattern and let the framework / application handle the update for you? Or do you bypass the application and delegate the update to a database trigger?
Obviously the trigger is faster, but is it worth it?
...
I've recently asked a question on StackoverFlow about the MVC: Can the MVC Design Pattern / Architectural pattern be used in Desktop Application Development?
Based on the answer provided I started research on how this would be implemented in a Windows form Application. I came upon the following CodeProject article: http://www.codeprojec...
Ever since the publication of Enterprise Integration Patterns people have been using the notation introduced in that book for documenting asynchronous heterogenous messaging systems.
But our shop is more or less standardized around a proprietary documentation tool that does exclusively UML. Is one of the standard UML diagrams appropriat...
Hi, I noticed a number of cases where an application or database stored collections of files/blobs using a has to determine the path and filename. I believe the intended outcome is a situation where the path never gets too deep, or the folders ever get too full - too many files (or folders) in a folder making for slower access.
EDIT: E...
I wish to put some text on a page and hide some data in that text. Does anybody know of any methods / patterns that have been used in the past to solve this problem?
Example: I have the following text:
"The cat sat on the dog and was happy."
I also have the number 123. I want to hide this number in that sentence such that the sentence ...
Hi,
I've got some entities which have decimal properties on them. These entities' properties are displayed in multiple places throughout my UI.
Currently I'm finding myself doing:
litWeight.Text = person.Weight.ToString("0.00");
all over the place.
Now I know for a fact that in several instances, and am suspicious of many others tha...
I'd like to get some feedback on a class I wrote for encapsulating the lazy-load pattern. Usually, when I do lazy-loading, it looks something like this:
private SomeClass _someProperty;
public SomeClass SomeProperty
{
get
{
if(this._someProperty == null)
{
// run code to populate/instantiate _someProp...
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?
...
At my job, I have to implement web forms for loan applications with sometimes up to a hundred different input fields, and then save the application into the database for later retrieval.
The person whom I replaced created a sql table with 100s of columns where each row represents a loan application and there is a column for every field....
Hi,
I am in the process of refactoring our BI layers to make our code more "loosely coupled" and I was interested to hear what you guys thought might be interesting improvements to make?
At present, our API is something like the following:-
// Fetch a collection of objects
ProductCollection prods = Product.GetProducts();
// Load an i...
Are there set design patterns or does each individual sufficiently skilled software developer recognize and reduce their code to develop new patterns. Effectively creating their own "design" patterns.
Edit - Thanks for the responses. In reality I'm just refactoring and/or reducing code where the problem should have first been compared...
I'm creating an API for a module and after I created several methods inside my classes, I asked myself this question.
Right now, and as an example, I'm doing this:
public Company GetMonitoredCompany( String companyName ) { ... }
public List<Company> GetMonitoredCompanies( ) { ... }
But I realize that for several times that I use othe...
Duplicate
Modifying A Collection While Iterating Through It
Has anyone a nice pattern to allow me to get around the inability to remove objects while I loop through an enumerable collection (eg, an IList or KeyValuePairs in a dictionary)
For example, the following fails, as it modifies the List being enumerated over during the forea...
I have been using Zend Framework in a MVC configuration, read about ruby on rails and plan de check other MVC frameworks in Python(Django?)... i really like the way it isolates some parts of the logic, security and validation. But after just 1 year using it i read an answer here saying almost everyone have wrong definition of MVC and tha...