Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c#]

C# is a multiparadigm, managed, garbage-collected object-oriented programming language created by Microsoft in parallel with the .NET platform

2
votes
2answers
751 views

Approach of delivering “Logging API”

I faced a question in a .NET interview. As a client i need a LoggingAPI. How you go the approach of design and development and delivering Logging API to the client? I don't care about WPF or a ...
2
votes
1answer
257 views

Repeating Interface inheritance declarations

Take the following example: public interface ISerialRVD { RouteValueDictionary ToRVD(); } public interface IViewModel : ISerialRVD // Here? { Int32 Page { get; set; } String Action { get;...
2
votes
6answers
4k views

Class Design — Multiple Calls from One Method or One Call from Multiple Methods?

I've been working on some code recently that interfaces with a CMS we use and it's presented me with a question on class design that I think is applicable in a number of situations. Essentially, what ...
2
votes
3answers
1k views

File storage for a blog component: database or filesystem?

I'm going to develop a fairly basic re-usable blog component, with simple CRUD operations using ASP.Net. Which method of storing blog posts would be best suited to the situation in terms of ...
2
votes
2answers
405 views

What is the best approach to update a database field when a corresponding class property changes?

I have a class with several fields. public readonly byte Id; public bool Active { get; set; } public List<Group> Groups { get; set; } public ...
2
votes
2answers
1k views

Invoke model logic in one UserControl from view-model in another UserControl without violating MVVM

Here is WPF application consisting from 3 UserControls: UserControl3 is a part of UserControl2 content. I keep MVVM during developing and using Prism. I need to invoke custom class method (which is ...
2
votes
1answer
412 views

Use struct or not

I made a tiny wrapper for fluent precondition assertions in c#. Now basically in all public / contract methods i assert the values this way: Precondition .For(()=>Model) ....
2
votes
3answers
890 views

What should I name these methods? [closed]

I have two interfaces, one with and one without generic type parameters. The non-generic interface is used internally so that I can store instances of the generic interface in a collection. All would ...
2
votes
3answers
2k views

Switch Parent Children relationship in C#

Using C# and WPF I have a situation where my data is organized hierarchically. I am using a treeview to represent this : Group_01 Object_01 Material_01 Texture Material_02 Texture_02 Group_02 ...
2
votes
1answer
300 views

Is an administration facility a bounded context in its own right?

Say I have a DDD application with three bounded contexts i.e. Sales, Production and Marketing. Say I wanted to setup an administration facility. The admin facility would allow superusers' to change ...
2
votes
1answer
565 views

Class structure for Entity Framework

I'm using EF (Code first) and I'd like to isolate the properties from the methods (many of the methods reference other libraries that I don't want my database project to have to reference). As an ...
2
votes
2answers
211 views

Should I use the Primary Key field when comparing two DDD Entities using: .Equals

Say I have a class like this: public abstract class Product { public Guid id {get; set;} public string description {get; set;} } This class is populated from the database. ...
2
votes
3answers
1k views

if a c# interface contain only getter and setter definition, is it a code smell?

A project that I am working on has the following code for interface example: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Test { public ...
2
votes
2answers
787 views

Where to place configuration files sources

I am developing a C# windows service application, which have different configuration files for development, for production system, for test system, like: Dev.config Test.config Prod.config Now we ...
2
votes
2answers
2k 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 ...
1
vote
1answer
286 views

Does merely parameterizing a dependency meet the requirements for Inversion of Control?

When I find a concrete dependency inside an extension method, I have been attempting to remove the (concrete) dependency by parameterising it like so // original implementation public static List<...
1
vote
1answer
422 views

Create an entity object in the domain layer when the ID is unknown

I am trying to learn the Rules Design Pattern as described here: http://www.michael-whelan.net/rules-design-pattern/ (towards the bottom of the webpage). I have written a class like this: public ...
1
vote
2answers
2k views

share method logic along classes without inheriting from abstract class

In some languages (e.g. C#) a class can only ever have 1 base class which seems like a problem for what I'm trying to do. I will give you an example of what i'm trying to do, hopefully this will make ...
1
vote
1answer
276 views

Using Aggregation and Association

Say I have two classes: Customer and Invoice. The database tables look like this: CREATE TABLE Customer (ID int, name varchar(30), primary key (ID)) CREATE TABLE Invoice (ID int, date datetime, ...
1
vote
3answers
2k views

Return domain objects from the repository

I am more experienced with the Database First approach for Entity Framework. I am currently looking at a Code First project, which returns domain model objects from the repository. Database First ...
1
vote
2answers
2k views

embedding programming languages into other languages [duplicate]

In C/C++, there is a keyword that allows you to enter assembly language directly into a method. Example int Main() { __asm // notify the compiler that this block is assembly language. { ...
1
vote
1answer
185 views

C# - How can I ensure a member is invoked without needing to call it and rely on the { get; }

I'm using reflection as a way of implementing a factory pattern: Type type = GetProviderType(vendor); ConstructorInfo constructorInfo = type.GetConstructor(new Type[] { typeof(...
1
vote
2answers
1k views

Class structure/pattern for validating several different Excel templates?

I'm trying to validate the contents of Excel sheets that follow several different templates. For each one, there are three possible validation actions for various cells: Regex (e.g. "XYZ-123" fails ...
1
vote
4answers
3k views

Circular dependency and object creation when attempting DDD

I have a domain where an Organization has People. Organization Entity public class Organization { private readonly List<Person> _people = new List<Person>(); public Person ...
1
vote
1answer
285 views

Should I handle all nine comparisons?

I was reading this article here: http://enterprisecraftsmanship.com/2014/11/08/domain-object-base-class/. The article talks about creating a base Entity class, which handles four of the nine ways to ...
1
vote
1answer
122 views

Should I actually be using encapsulation here?

Problem Statement I am going to write a library to control a whole bunch of relays, and I am just trying to think conceptually right now. Here are my design constraints: We have an exact number of ...
1
vote
3answers
771 views

Guidance for a C# developer to become better UI developer

I am a C# developer and had developed simple websites in regular asp.net(with asp.net controls) and a wpf application. Nowadays, I am trying to learn Asp.net MVC3 and I have been exposed to HTML ...
1
vote
2answers
3k views

Nested Try Catch Error Handling with Log Files?

Best practice question for error handling in C#? In our system we will be writing out files, and with each file they will have a corresponding error file. The error file will get written every time ...
1
vote
3answers
444 views

Is EF4 mature enough with MySQL or Oracle? [closed]

Is Entity Framework 4 with MySQL or Oracle mature enough to be used on production level web application? Can it provide high level of performance, or should we stick with just plain data access with ...
1
vote
1answer
617 views

MVVM, is it better suited for web applications or GUIs?

I am currently deciding whether I should implement a new system with a web application as a front-end, or if I should instead produce an executable file using WPF. The pattern that I will use is MVVM,...
1
vote
1answer
205 views

C# - Data-Driven Design & Coupling - Mother may I?

I have used data-driven design in the past and it has worked quite well. What I dislike about it is if you need some form of a string whose value has to be updated based on other values. e.g., "...
1
vote
3answers
3k views

Most efficient method for large switch statements

Let's say you have many paths that an application can take at a certain point based on the value of a specific input (for example a simple int). Is there a certain method that is most efficient for ...
1
vote
1answer
322 views

Implementation of instance testing in Java, C++, C#

For curiosity purposes as well as understanding what they entail in a program, I'm curious as to how instance testing (instanceof/is/using dynamic_cast in c++) works. I've tried to google it (...
0
votes
2answers
93 views

Can a query handler (not repository) access a web service?

Say I have the following class, which maps to a database table: public class Person { public Guid Id {get; set; } public string Name {get; set; } public DateTime DateOfBirth {get; set; } public ...
0
votes
1answer
388 views

Factory Design Pattern Implementation with multiple interfaces and base class

I know it is lot of code. But I am trying to understand the concept of Factory pattern with interfaces and base class. I have a base class of Car that implements an interface which will be implemented ...
0
votes
2answers
3k views

How To Invoke A Method When It's Class is Accessed (Any Method) - “OnClassEnter”

I am working on a C# net micro framework project, in particular an I2C bus management/class. I have several different I2C devices each defined in separate classes which contain all of the devices' ...
0
votes
3answers
338 views

Should I pass an ID number from the feature file?

Say I have a domain object like this: public class Customer { private Guid _id; private string _name; private Address _address; public Customer (Guid id, string name, Address address)...
0
votes
1answer
23k views

What is the benefit of using getters and setters on properties in C#? [duplicate]

Possible Duplicate: When are Getters and Setters Justified Why do we use get and set method in C#? And why do we use public and private method property? For example: public class Date { ...
0
votes
1answer
831 views

C# Application GUI design dependent on configuration

I have built quite big WinForms application working in industry for a few years. It communicates with many HW devices. Application can be configured to use or not use some of these devices and GUI is ...
0
votes
3answers
2k views

suggest structure for classes that maps to json with dynamic data without using dynamic or object reference

this is a kind of data i have to de-serialize { "id": "M:11427", "title": "DAX30", "nextStartId": "S:727831", "sections": [ { "type": "HIGHLIGHTS", "...
0
votes
2answers
560 views

Should a class validate argument using external method/service with unit testing?

I have a class that runs as a service and returns html code of a website when supplied with a URL. The code: public interface IHtmlDownloader { IWebProxy Proxy { get; set; } string UserAgent ...
0
votes
1answer
120 views

Does returning an instance directly in a property create duplicate instances?

Let's say I have a class with a property that returns an array of strings. public static string[] MyStrings { get { return new string[] { "Foo", "Bar" }; } } Will this create multiple instances ...
0
votes
1answer
307 views

Should Domain Entities be dependant on factories?

Please see the code below: public IEnumerable<DenominationNumberRequired> CalculateDenominationsFor(int cost) { var target = cost; foreach (var denomination in currency....
0
votes
2answers
125 views

Testing a class that only has one field only that is an ID number

I am trying to incorporate BDD into the teams working practices to make interactions with Business Analysts more effective. I recently asked this question: Should I pass an ID number from the feature ...
-1
votes
1answer
314 views

One Acceptance Test project per layer or one Acceptance Test project per Bounded Context

This link (http://www.taimila.com/blog/ddd-and-testing-strategy/) says: "Feature tests should depend only on the application layer" i.e. presentation layer. I am trying to understand how BDD fits in ...
-1
votes
2answers
99 views

How to swap between 2 third-party providers when both implement different events?

I have 2 third-party providers, both do a similar function(this could be logging, messaging, etc), and both have events that the client must subscribe to. I want to know what design patterns or ...
-2
votes
2answers
1k views

When should local variables be used over instance variables?

This question is inspired by Mike Nakis' answer to a question I asked earlier: Should a Calculator be a value type or an entity type?. Please see the code below: public class Calculator { ...
-3
votes
3answers
150 views

Should a Calculator be a value type or an entity type?

Please see the code below: public class Calculator { private readonly int Number1; private readonly int Number2; private readonly int Answer; public Calculator(...