0
votes
1answer
34 views

C# Implementing filtered Iterator without using yield return

I'm trying to display elements of a list with filter and without filter. Here, I use the filter in such a way to display the elements which are divisible by 3. I'm going to use Enumerable and ...
0
votes
1answer
118 views

Onion Architecture Structure

I am looking to understand and implement the Onion Architecture and have a vague idea on how to structure everything but need help to clear up some of my confusion. Based on different examples and ...
2
votes
2answers
168 views

Best patterns for variable-scope disposables

I have Client which uses a disposable Connection for talking to a remote service. A Connection is somewhat expensive to set up and needs to be Dispose()d properly. I want to allow multiple methods ...
0
votes
1answer
86 views

What design pattern should I use for import, update, export

I need to create a simple payments validator. On the following class diagram, I tried to present the model of payments. As you can see, each payment type inherits from Payments class. Now I want ...
1
vote
2answers
123 views

Sanity check for design pattern used with an intricate calculation model

I am working on a project that generates technical brochures in batch. The 3rd party API that is being used expects POCOs with property names that match field names used in each of the brochure ...
4
votes
5answers
1k views

Is this a good practice or not?

I have a colleague who has come up with a way of 'genericizing' information from a database so that all his web application's drop-down lists can share the same object in his MVC.NET C# code and ...
0
votes
1answer
94 views

Confused on how to properly employ a Repository Pattern with Service/Business Layer on top

I'm building a ASP.NET Web Api 2 solution for learning purposes, and I've hit a snag. I was wondering if anyone could tell me what exactly it is that I'm missing. My Web Api solution has 4 Layers: ...
1
vote
1answer
78 views

Implement Generic DataSet Builder with C#

I want to create a data access library that can build a DataSets with relations which can easily be written to XML with dataset.WriteXML(). This is a get to know C# endeavor that will hopefully gain ...
3
votes
1answer
51 views

Pattern to use to relate multiple data sources to different user data widgets

I have an client x server intranet application the basically gets data from the server, format it and send that data to the client for display. At the server we are using ASP.NET C# running on IIS ...
0
votes
0answers
62 views

does class reference itself static anti pattern in prism

I have an application and my desing approach look like this: class Manager { public int State; static Manager _instance = null; public static Manager Instance { get { return ...
0
votes
0answers
156 views

What's the best way to expose a Model object in a ViewModel?

In a WPF MVVM application, I exposed my model object into my viewModel by creating an instance of Model class (which cause dependency) into ViewModel. Instead of creating separate VM properties, I ...
0
votes
2answers
232 views

How to design console application with good seperation of UI from Logic

Is it considered an overkill for console application to be design like MVC , MVP or N tier architecture? If not which is more common and if you can link me to simple example of it. I want to ...
2
votes
1answer
188 views

Best practice to collect information from child objects

I'm regularly facing following pattern: public abstract class BaseItem { BaseItem[] children; // ... public void DoSomethingWithStuff() { StuffCollection collection = new ...
2
votes
2answers
470 views

A small project but I want to use design patterns to do it right

I've got a project coming up, a very a small system, but one that needs to be extended in the future. Here's how I've designed it so far. It's 3-tier: presentation, business and data. For the ...
1
vote
2answers
293 views

Correct way to inject dependencies in Business logic service?

Currently the structure of my application is as below Web App --> WCF Service (just a facade) --> Business Logic Services --> Repository -> Entity Framework Datacontext Now each of my Business logic ...
2
votes
1answer
68 views

Use adapter pattern for coupled classes

I need (for unit testing purposes) to create adapters for external library classes.ExchangeService and ContactsFolder are Microsoft's implementations in its' EWS library. So I created my adapters that ...
0
votes
2answers
133 views

Optimization ended up in casting an object at each method call

I've been doing some optimization for the following piece of code : public void DrawLine(int x1, int y1, int x2, int y2, int color) { _bitmap.DrawLineBresenham(x1, y1, x2, y2, color); } After ...
1
vote
3answers
147 views

Relative encapsulation design

Let's say I am doing a 2D application with the following design: There is the Level object that manages the world, and there are world objects which are entities inside the Level object. A world ...
1
vote
1answer
163 views

Should I use inheritance or an interface?

So in a nutshell I have an abstract class : public abstract class Member { public string PCode { get; set; } public string Reference { get; set; } public DateTime? ElectedDate { get; set; } } And ...
0
votes
3answers
381 views

What is the main goal of MVVM pattern? [closed]

Could you tell me what is the goal of the MVVM pattern? What are the arguments or the reasons I can give to a team and product owner to respect and develop according to this pattern? I would like a ...
0
votes
2answers
76 views

Container/Item pattern without `friend`

I have a class Container containing objects of type Item. They are different classes, and especially they have no common base class (e.g. a Container does not itself have a Container).: class ...
0
votes
0answers
89 views

How to design modular “screen configurator” for database application

I am currently working with a product that is effectively a glorified CRUD application. (It is a C# .NET 4.0 desktop application backed by an Oracle 11gR2 database.) The client program presents a list ...
2
votes
6answers
335 views

Design pattern for method to accept one of several static items in C#?

I want to illustrated my question by way of a (hopefully) representative example. Lets say I have a situation where I am developing a class library in C# to be used in some simulations. I want to ...
1
vote
0answers
99 views

Run a function when a function in a list is executed?

Goal: I'm currently doing an MVC project and I have this method to update the ViewBag (based on previous actions of the user). I would like to call this function whenever a certain list of MVC Actions ...
4
votes
2answers
387 views

Should I expose a “computed” value as a property or a method?

I have a C# class that represents a content type in a web content management system. We have a field that allows a web content editor to enter an HTML template for how the object is displayed. It ...
2
votes
1answer
129 views

Does a repository belong in this project?

I have a project that gets all of its data from API calls. The server that hosts this API connects with it's own database (not even sure what DB it is, etc). More or less the idea of a repository is ...
3
votes
2answers
164 views

Is it an acceptable practice to Get a property, that involve parsing binary, that might throw an exception?

I have a property that is loaded lazily, any time after the ctor is called. It is possible that the binary that my property relies on is invalid. If invalid I might have to throw an exception. ...
0
votes
3answers
168 views

Is the Adapter the correct design pattern for this situation?

I have an instance of a class UntouchableClass of which I need to access the member variables to use in my DotLiquid template. Problem is, UntouchableClass has to inherit from Drop if I want to use it ...
2
votes
2answers
212 views

Pattern for multiple datasources

I've already read this question on CodeReview. I was hoping for general advice. I'm writing a service which will go to numerous data sources. Each source requires getting copious amounts of data ...
0
votes
1answer
297 views

Migrating old Asp.net 1.1 project to mvc 3 or 4

we have to migrate a very old project that are having more than 500 web forms and 400 tables and it is hugely depends on stored procedures, the current specification is: Asp.Net : .NET version 1.1 ...
0
votes
4answers
535 views

What is this design pattern called? [closed]

I have some code: /// <summary> /// Represents Record Locator class /// </summary> public class RecordLocator : IRecordLocator { /// <summary> /// The Record Locator string, ...
4
votes
3answers
590 views

Extension method naming convention [closed]

We are using some utility methods in our company to simplify programming. So we have following string extension: public static bool IsNoE(this string s) { return string.IsNullOrEmpty(s); } ...
3
votes
2answers
515 views

Choosing the right Design Pattern

I've always recognized the importance of utilizing design patterns. I'm curious as to how other developers go about choosing the most appropriate one. Do you use a series of characteristics (like a ...
1
vote
1answer
212 views

ASP.NET MVC SoC when dealing with back end objects (design decision)

I had a discussion with some peers and even some technical leads in the team around this and Im all for the purist MVC approach. Especially when the project is in its infant stages (its easy to ...
0
votes
1answer
89 views

What is the shortcoming of custom factory comparing to generic factory [closed]

I have a factory method as given below public class AutomobileFactory { Dictionary<string, ICar> internalFactory = new Dictionary<string, ICar>(); public AutomobileFactory() { ...
2
votes
1answer
230 views

DI or Factory Pattern ? Both ? or a different apprach?

Lets say we have an abstract class called BaseSwitch, inherited by concrete implementations Switch A and Switch B, Each Switch representing a real-life switch (A telephony tool which among its ...
1
vote
3answers
252 views

Pattern for costly precondition check before acting

Let's say I have a method DoTheThing() which requires the precondition-check CanTheThingBeDone() to return true. The latter method is time consuming as it accesses the database. I'm finding it hard ...
3
votes
1answer
311 views

State pattern vs Inheritance

In the following image for the State Pattern from Applying Domain-Driven Design and Patterns: With Examples in C# and .NET I'm trying to persist the SalesOrder entity into the database. Normally I ...
0
votes
1answer
189 views

Need an OOP pattern or strategy for “pluggable” property

I'm using OOP and MVVM in a WPF c# application. The goal is for the resulting object (data-bound to user interface) to accurately represent a product. One specific area of the product is highly ...
1
vote
2answers
889 views

Why separate class CommandHandler with Handle() instead of handling method in Command itself

I have a part of CQRS pattern implemented using S#arp Architecture like this: public class MyCommand { public CustomerId { get; set; } // some other fields } public class ...
3
votes
2answers
231 views

Help with inheritance hierarchy design

I'm having trouble designing an inheritance hierarchy. In the figure: Base class: This uses the Template Method. Contains core logic/algorithm that calls virtual/abstract methods Derived ...
3
votes
1answer
86 views

Development console commands registration

I have a DevelopmentConsole class. I am making functionality to register console commands for the subsystems. I don't want the console to know about them but also I don't want them to contain a debug ...
4
votes
5answers
220 views

Loose coupling and shuffling dependencies

I have a bunch of classes that look something like this: public class MyGame() { private Graphics graphics; private Player player; public MyGame() { graphics = new ...
0
votes
1answer
506 views

State design pattern: best implementation for my case?

Me and a mate have a discussion about what would be the best way to implement the pattern state for managing several screens for an application we are developing. We have a ScreenManager (I guess the ...
1
vote
3answers
297 views

Problems with Facades and then evolution in software

I initially started a project with Facades and Polymorphism as a way to create simple extensible design following SOLID Principles. Here is a sample code: public interface IInterface { void ...
0
votes
4answers
379 views

Problem regarding DRY principle and Polymorphism

I have a class that is 99% identical to its counter part. Sample code goes below: public abstract class BaseClass { void Method1() { } void Method2() { } void Method3() { } public ...
5
votes
2answers
2k views

MVC + 3 tier; where ViewModels come into play?

I'm designing a 3-tiered application using ASP.NET MVC 4. I used the following resources as a reference. CodeProject: MVC + N-tier + Entity Framework Separating data access in ASP.NET MVC I have ...
2
votes
6answers
2k views

Design Patterns - Why the need for interfaces?

OK. I am learning design patterns. Every time I see someone code an example of a design pattern they use interfaces. Here is an example: ...
1
vote
2answers
1k views

Design pattern for an ASP.NET project using Entity Framework

I'm building a website in ASP.NET (Web Forms) on top of an engine with business rules (which basically resides in a separate DLL), connected to a database mapped with Entity Framework (in a 3rd, ...
0
votes
1answer
3k views

Entity Framework 5, separating business logic from model - Repository?

I am working on my first public-facing web application and I’m using MVC 4 for the presentation layer and EF 5 for the DAL. The database structure is locked, and there are moderate differences ...