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

learn more… | top users | synonyms

1
vote
1answer
91 views

Correct approach for creating api contract

I need help regarding below: I am trying to design an API. For creating contracts below are the two approaches: Approach 1: public class MyController { public void MyAction1(Dictionary<string, ...
2
votes
2answers
73 views

WCF service with methods to fetch data

I'm planning on building a WCF service that will fetch data entities from a Sql Server database. And I'm currently struggling with best practices issues. The thing is that there's a few different ...
2
votes
2answers
164 views

Client-Side JavaScript Business Logic in .Net Solution Stack

Fellow developers on other teams I interface with seemingly question my judgement calls as they pertain to the placement of coded business logic in a .Net MVC/Knockout web application currently under ...
0
votes
2answers
122 views

Constructor Injection vs. IocFactory

Today at work a collegue and I had a discussion about the following: Basically we have a rule engine which works in the following way: RuleExecutor Gets all rules to execute in the constructor ...
1
vote
3answers
213 views

Is a private property the same as a public field?

Will a private property same as a public field? Here is the sample code I wrote to understand this: using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...
4
votes
1answer
81 views

Where to create a file in WPF/MVVM

I'm building a WPF/MVVM application that takes input from the user and generates an output document which it saves in a temporary folder and opens for display in the native application (e.g. MS Word). ...
2
votes
1answer
113 views

Managing Massive Updates with Resource Access

I have a number of data servers that are pushing data to a main server as in this kind of architecture: These data points (points for short) are updated randomly from each server. On the server, ...
1
vote
2answers
299 views

ASP.NET user control best practices, programmatically or markup?

I've just started an internship with a company whose main product is an ASP.NET web forms. My related experience so far has been with Java and front end web development. My current task is to make ...
8
votes
3answers
510 views

Cleanest way to write logically procedural software in an OO language

I'm an electrical engineer and I don't know what the hell I'm doing. Please save the future maintainers of my code. Recently I've been working on a number of smaller programs (in C#) whose ...
3
votes
1answer
390 views

Can I write a cross-platform application (Mac and Windows) using C#?

I see lots of old information on this question, and lots of articles flying around the Interwebs, but I can't tell quite where things are at. Basically, I want to write C# code that I can then ...
0
votes
0answers
57 views

Whats the best way to implement DataMapper design pater and lazy loading (ghost object)

I'm doing a small project and I wanted to keep it simple to mantain. It is a renting management software. To keep it clean I decided to implement the data mapper patern, to keep the domain objects in ...
1
vote
0answers
87 views

Injecting locking policy into a class

I have a class that does some operations on data, and I want to have different locking schemes (no-lock, simple-lock, and read reader-writer lock) in different situations. Think this main class like ...
0
votes
1answer
161 views

Is there a way to do bitwise operation with more than two state

I know how make bit operation. I'm wondering if you need more than 2 states is there a way to do it using bit instead of array and % operators. Because those are really slow. So in case the array ...
1
vote
1answer
127 views

Strategies to manage a modular C# framework

Currently I'm building a large framework whose purpose is to run several algorithms in sequence. Many of these algorithms have interdependencies in data structure - the output of one algo is the ...
1
vote
1answer
93 views

Mixing reactive programming with non-reactive return requirements

Variable context from an initial non-reactive caller The whole application cannot be reactive i.e. this method needs to return a result here public string GetTextOfInterest() { var ...
1
vote
1answer
54 views

What is a good alternative to the TestDataBuilder pattern?

The TestDataBuilder pattern is used in unit testing to create collaborators. Its advantages versus using constructors: Changes to constructors are localized. Test code becomes clearer, because you ...
1
vote
0answers
63 views

Correct Class Design for EAV Model

I need to design a class model to represent an EAV Model. I based my classes on this presentation ...
0
votes
0answers
84 views

How to build Data Access Layer independent of Schema Changes

We would like to know is there any pattern in Data access layer which works perfectly with change in schema in C#.NET. I Would like to build Data access layer which is schema agnostic
3
votes
1answer
240 views

specification regarding a text file

I have a specification I need to follow (for a little project) and I want to ask if they my way of thinking on how to tackle this spec is correct. It's regarding C#. Specification: consume a TEXT ...
1
vote
0answers
74 views

How do I handle authentication in an ASP.NET webapp with offline-capable client code?

I hesitated before writing this question, as it sounds like I'm after an opinion without trying anything yet. That's not the case, I just don't want to go down the wrong route with architecture - it ...
0
votes
3answers
241 views

How can I reinforce that security questions answers should not be the same and how to encrypt?

When my users are creating an account they need to fill and set several security questions pertaining to their account. I am wondering, how can I make sure that the answer the user enters for each ...
1
vote
2answers
167 views

A Factory could be replaced by a key on the web.config? How would be the trade-offs of each approach?

The Problem We had a Environment class which would choose whether or not to use a webservice (it was set by a web reference) for our authentication methods by reading the host environment and if it ...
0
votes
0answers
83 views

Is it possible to have multiple threads using Background Workers for different controls within one GUI

In my current project i have a CPU intensive 3D chart that needs to be updated in real time. I have been using background workers for the project and using those, i do all the processing in the ...
2
votes
2answers
132 views

Abstract Property In Base Class To Force Programmer To Define It

I'm coding with a state pattern for an embedded device. I have a base/abstract class called State and then each discrete(concrete) state class implements the abstract State Class. In the State Class ...
2
votes
2answers
131 views

Lazy loaded property signatures in business objects

Let's say I am designing business objects around a poorly optimized database that have no ability to change. I have a Person object with a ShippingAddress property. The ShippingAddress is very ...
2
votes
1answer
184 views

C# Dependency Injection with Adapter Pattern

In the following code sample, I have a client that works through a controller. In my specific case the controller establishes a session to an address on a GPIB bus. An instance of this is then ...
2
votes
1answer
262 views

Should I write complex Linq queries?

I often find complex Linq queries that span over 10-15 lines in our code base. I find such queries hard to understand and impossible to debug. I've tried to split the query to smaller parts, but it's ...
2
votes
1answer
161 views

How to deal with dependency when you have separate projects?

I know there is all this talk about having only one composition root that set all your dependencies and that you should always prefer constructor injection to other types, but sometimes it just ...
1
vote
2answers
143 views

How C# protected access modifier when applied to a member variable works

I have 2 classes, Base and child class. Base class has a protected int variable. My understanding is that any protected member of a class can only be accessed in a child class, It cannot be accessed ...
0
votes
0answers
25 views

Dealing with stale data / currency issues when lazy loading related entities

Imagine I have two associated domain entities with a one-to-many relationship. Here is an example with Customer and Order classes: public class Customer { public int ID { get; internal set; } ...
3
votes
3answers
672 views

If possible, would it be a bad practice to use Nullable for non value types?

Update After writing this question I found out that Nullable<T> has a type constraint of struct on T so you cannot actually use Nullable for reference types. However, some good answers ...
0
votes
1answer
44 views

Provide part of context to class using interface

Currently I have class Context which I inject in some places in my code, like: protected override object GenerateSomething (object input, Context ctx) Depending on Context, Generate method gives ...
0
votes
3answers
175 views

Best algorithm to determine whether two arrays can be the same in a circular queue

I'm trying to figure out an efficient way to determine whether two distinct arrays of the same size can be shifted to form the same circular queue. For example: Array1 = ['A','B','C','D'] Array2 = ...
0
votes
0answers
37 views

ASP MVC Performance Analysis in Azure

I have a web application based on asp net boilerplate using EF6. The site is in it's finishing phase and I'm trying to tweak the performance to the best of my abilities. I was able to reduce the ...
1
vote
2answers
134 views

Non-printable characters and editors

Today I was presented with a very nasty problem and I do not quite know where to ask this but hope here is ok. So I have the following string: "\0" (at least that's how it looks in visual studio). If ...
2
votes
2answers
81 views

How to handle an aggregated list of the fields of multiple objects?

I have some objects each hold a list of variables, and a list which holds all variables of these objects, for example class A { List<Var> varList; } class B { List<A> aList; ...
2
votes
1answer
196 views

Events in WCF Service Architecture (Server Side)

Problem: Now, I have some events that will take place when the client submits a request to the server. These events will arise on the server and they will be subscribed by the services themselves ...
9
votes
1answer
304 views

Why it is not possible to overload compound assignment operator in C#?

The title is be misleading, so please read entire question :-). By "compound assignment operator" I have in mind a construct like this op=, for example +=. Pure assignment operator (=) does not ...
1
vote
1answer
96 views

Emulate 12bit uint in c#

I recently had to do a codility test. The question itself was reasonably easy. take a string of numbers and +, * loop through it, if the character is a number, add it to a stack, if its an operation ...
2
votes
1answer
67 views

How to handle overlapping classes

I'm putting together a program to try and recreate a board game. My goal was to keep the rules and actually actions of the game separate from its presentation, so I am creating a library that contains ...
0
votes
0answers
72 views

How to verify a method is only called once, with specific arguments (using RhinoMocks)

I'm just starting to use RhinoMocks. Now I'm wondering what test cases I should write. I want to assert that a method is only being called once, with specific arguments. Lets start with my ...
5
votes
1answer
132 views

Good way to program an orchestration / processflow

I'm programming a process in which clients will be separated in 3 different groups, and for every group a different action will be performed. My question concerns the process of deciding which client ...
0
votes
0answers
90 views

How do I model this Shipping Routes scenario?

Trying to begin coding this solution. I have a scenario as follows below: A shipping operator has a network of routes to various ports, the routes are specified explicitly below Buenos ...
3
votes
1answer
157 views

Where to store configurable, global settings

As an example, let us say that I have an application with multiple users and multiple administrators. I want the administrators to be able to configure sitewide session timeouts. The code would ...
1
vote
2answers
207 views

DLL or web service for common functions?

We have a variety of basic functions (date utilities, email sending, internal math calculations, etc) that are currently in an old VB.NET project. We're going to move towards C# and I'm wondering if ...
4
votes
2answers
202 views

C# obtain derived class from base

I am trying to build a dashboard that allows a variety of widgets to be displayed on the home screen. They are structured as follows: public abstract class Widget {} public abstract class ...
2
votes
1answer
134 views

Call method in a disposable object at the beginning of a “using” statement

When we use the lock statement, it is essentially doing a Monitor.Enter at the beginning of the locking block and a Monitor.Exit at the end of the block. This process is automatically handled by the ...
0
votes
0answers
66 views

Class design for an app that reads data from Active Directory

I am hoping someone can help me regarding design and architecture for an application. The application is basically a service written in C#. The purpose of this service is mainly to read data from ...
1
vote
3answers
198 views

Using prefix/postfix increment operator for simple incremental array access rather than actual index numbers

I cannot decide which method is better with consideration of both readability and fault-tolerance. Method #1: Object[] objects = getArrayOfKnownLength(); int i = -1; someMethod(objects[++i], ...
2
votes
2answers
199 views

How to iterate between these elements

I have an array of elements: int[] elem = new int[] {A, B, C}; I need to calculate the sum of ALL the combinations of those elements, where only some of the elements can be optionally selected. I ...