Tagged Questions
17
votes
4answers
2k views
Best way to pass parameters to Factory class?
So I have a series of objects, which I will call Impl1, Impl2, and Impl3. They each implement an interface, called IImpl. I have a Factory class who's task is to retrieve the ImplX which is ...
17
votes
4answers
14k views
EF Code First with Repository, UnitOfWork and DbContextFactory
I am about to >explode< :) due to amount of reading on this subject...
My head hurts, and I need some honest opinions...
There is a similar question/review that I noticed, but I believe my approach ...
15
votes
4answers
7k views
Interface for unit of work pattern and repository pattern
I'm trying to design a well defined yet simple interface for the unit of work and repository patterns. My UoW's are exposed to services and services then "get repositories" that it needs to query. I ...
10
votes
2answers
566 views
UI repetitive code - what pattern to use?
I have two different windows forms project which contain forms with similar UI/code. For example, I have several forms that have 98% code tha same, the only difference is that one they call different ...
9
votes
6answers
657 views
Multiple Inheritance and Composition with Java and C# (Updated)
The following article explains the usage of the composition design pattern in environments that do not allow multiple-inheritance of classes. Note: All code examples are written in C#.
In Java and ...
8
votes
1answer
777 views
best design pattern for refactoring a set of classes that do calculation base on many parameters
I'm refactoring a set of classes which does some price calculations.
the calculation is done based on many parameters.
The code is :
public interface IParcel {
int SourceCode { get; set; }
...
8
votes
2answers
585 views
Improve a OOP design
I'm having a hard time creating a design (due to my lack of experience). I need a little of help to create the Model.
It's a mathematics system. I've created an IProblem interface with a function ...
7
votes
3answers
316 views
Is this a good example of the strategy pattern?
I've been reading The Pragmatic Programmer for a few days and I've come across a reference to the strategy pattern. Looked it up in Design Patterns and figured I could refactor a piece of code I'm ...
7
votes
1answer
2k views
Generic repository and unit of work code
I am writing a WPF application that needs to access information from a database (I am currently using Entity Framework code first, so data access is via DbContext).
My ViewModels directly ...
6
votes
2answers
126 views
Handle static objects using custom adapter
I have read some articles discussing about why static is bad, some of them refering static as not-testable, non-mockable, has state (non-stateless) and everything else.
However I have encountered ...
6
votes
2answers
8k views
Entity Framework Generic Repository Pattern
Thought 1
public interface IRepository<T> : IDisposable where T : class
{
IQueryable<T> Fetch();
IEnumerable<T> GetAll();
...
6
votes
1answer
261 views
combining 4 CRUD functions into 1?
I have a console application that I'm trying to make with minimal redundant code.
I have 4 functions, Create, Read, Update, and Delete.
is it possible or practical to combine the four functions ...
6
votes
3answers
838 views
Composite and Visitor patterns for tree-based survey functionality in C#
I have written some survey functionality for a project. Basically, a generic survey form that can be composed of sections and questions.
I have a Survey class, Questions and Sections. The Survey is ...
6
votes
1answer
1k views
What do you think of my EventAggregator implementation in C#?
I was looking for a simple EventAggregator to use in my app but i find people get very complicated very quickly, so i thought this was easy enough to write myself it seems to work but i was wondering ...
6
votes
1answer
270 views
How can I make this C# code better so it more closely follows DDD principles? Am I using factory correctly?
I've been working on converting some legacy code from T-SQL stored procedures. My aim is to use DDD to make the transition. Below is an attempt to do this. Any comments on how well this is following ...