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

2
votes
1answer
102 views

Should I use BackgroundWorker in Pipeline pattern?

I am planning the implementation of a Pipeline pattern as seen in this MSDN article. This is a WPF application for which I need to monitor progress of each stage of the pipeline in order to display it ...
9
votes
3answers
317 views

How to share a code base among 10+ projects and minimize pain?

I have a number of applications that share the same data in the same database. To try and minimize redundancy of code the Data Access Layer is a shared project. This prevents each project from needing ...
3
votes
2answers
170 views

Most efficient strategy for search large text areas for multiple values

I have a requirement for a service that does the following. Take a block of text and identify the server names in it (by name or ip address). So given: Lorem ipsum dolor sit amet, consectetur ...
1
vote
3answers
331 views

Do I have to fork a server program as an “C” child process in order for correct interprocess communication to take place?

I would like to implement interprocess communication between an Ubuntu Linux 15.10 mono 4.1.2 C# recorder client and Ubuntu Linux 15.10 mono 4.1.2 C# video server using a C++ mutex class and C++ ...
1
vote
1answer
136 views

What's the benefit of generics in an in interface e.g. IEnumerable<HttpPostedFileBase>

I've come across a method that requires a parameter that implements IEnumerable and is of a certain type like this: public myMethod (IEnumerable<HttpPostedFileBase> myParameter) { ...
0
votes
1answer
99 views

Calculating variable distances

I'm attempting to write an algorithm that calculates the distance between vertebrae. The text parser already works perfectly in picking out vertebral references (cervical 6, c-6, c6, c six, cervical ...
0
votes
1answer
93 views

Passing a Serial Port Instance

Background I am thinking about designing a (GoF/behavioral) command-pattern interface. I may decide to call this thing ICommand. I am thinking that I would have some sort of a queue containing a ...
7
votes
5answers
211 views

Open Closed principle in design patterns

I am bit confused about how Open Closed principle can be applied in real life. Requirement in any business changes over the time. According to Open-Closed principle you should extend the class instead ...
0
votes
0answers
28 views

How to find existing UserControl and Window at Runtime

We have a LOB Application where I want my users to be able to create themselves a Menu (Left-handed main menu like a webpage). The "poweruser" creates menu, add some security and then the final users ...
6
votes
1answer
187 views

Relaxed architecture DAL or anemic BLL?

Particularly for the sake of unit testing, I'm trying to implement an application with a layered architecture. I'm coding in C# and using ASP.NET Web API for the service layer. I'm aiming at a 3-layer ...
3
votes
2answers
197 views

How do I deal with unneeded inherited members?

Consider the following UML diagram: In a nutshell: ChildClass1 and ChildClass2 use all of the members of ParentClass. ChildClass3only uses Member1 and Member2 and the value of Member5 is a ...
2
votes
0answers
124 views

REST API Versioning in C# WebApi

I haven't really found a decent/future-proof way to version methods in my WebAPI. This is what I typically do now, but it can get confusing and hard to trace if it gets a bit large (I'll end up [...
2
votes
1answer
80 views

Possible DRY with Pausing Mechanism

Background I am currently working on the architecture for a future software design. The design is one long running task (hours-long) with thousands of sequential calls to various libraries. I ...
2
votes
0answers
55 views

Dictionary-Sorting in bigger projects

My concern is how to handle ResourceDictionarys in a WPF (MVVM)-Project. I usually only create small Projects, so it doesn't matter that much, but since I created a Project-Template to handle some of ...
1
vote
3answers
137 views

Use case for async/await?

Background Most of the applications that I write are hour long sequential tests for electronic equipment. The equipment under test has a specification that is a state-machine that looks like... Get ...
3
votes
2answers
121 views

Proper design for models

I have a class called ReplaceRule this is used by 2 classes DocumentRuleViewModel and SectionRuleViewModel as a List<ReplaceRule> in both Question 1: In my database implementation I have 2 ...
4
votes
3answers
398 views

What problems might arise if I didn't make a method static when I could?

I have a stateless method that takes an input, and based on that input returns an output. This method has no state so in theory it could be made static. But let's say I don't do this. What problems ...
2
votes
1answer
67 views

Merging dynamically created data with an HTML template

I have a C# application where I'd like to present information that is accumulated in memory from an embedded system in the form of an HTML page in a near real-time manner. As a proof of concept I've ...
-1
votes
1answer
122 views

Code structure of third party framework [closed]

Is an API always returning 200 OK, an issue?
2
votes
3answers
259 views

Why does C# not allow scope-local using Directive?

One thing I do not get with C#'s using Directive is why I can only "use" a namespace at file level, and not within any arbitrary block scope. (using namespace x; of C++ does allow this and certainly ...
0
votes
0answers
83 views

What to use in case of waiting for something that is complete: delegates, events and/or thread

I try to give a concrete example. Create a semaphore for a crossroads. I have two semaphores. I have possibility to set a duration of semaphore 2 minutes, 5 minutes, 10m inutes etc. When one ...
2
votes
5answers
245 views

Constructor overloading or allow null?

Which is the preferred design to use, one constructor that allows null, or two constructors where one throws an ArgumentNullException on null? Two constructors with exception throwing public class ...
0
votes
3answers
175 views

Using nested private class to hold data from csv file

I have a class that only has one method. This method has to read csv file, do some work concerning internal logic (check if item already exists, do some transformations, etc.) and finally write all ...
0
votes
0answers
30 views

Syncing file data and form data uploaded at separate times

I have a web application where users can upload office documents. In addition to uploading files users also specify extra information about them that's not contained in the files themselves but is ...
0
votes
1answer
59 views

Sequence of Integration Test in Build Process

We are developing a Web API (ASP.net, C#) project and use Bamboo CI for our continuous Integration. We run the Unit test before the deployment task so that deployment does not happen if test fails. We ...
0
votes
0answers
36 views

Tracking a program-wide state of tasks being done and making it testable

I have a program which does some processing which can be asynchronously requested (WCF). There should be only one computation per identifier (always supplied upon request). So if at some point work is ...
4
votes
1answer
117 views

Overflow Exception Checking Problem

Background I have to call a method that needs to return a signed integer (see code block below) after converting from an unsigned integer. The reason for this is that I have to do bit-wise math that ...
2
votes
1answer
71 views

Does murmur3 hash have memory?

This implementation of Murmur hash yields different results when called twice in a row: Murmur3 m3 = new Murmur3(); var la = m3.ComputeHash(new byte[] { 1, 2 }); var lb = m3.ComputeHash(new byte[] { ...
5
votes
3answers
393 views

Is it ok to have a class that only has boolean properties?

Scenario We have a class Vehicle, this class contains some properties to define the object such as a CarBrand, TransmissionType, Color, etc.. A car (vehicle) also has options, these days a lot of ...
1
vote
2answers
98 views

Catching exceptions from child process

I am looking for any info. (I know some C++ with win32 and C#) The Idea: The idea is to help a program with missing files load. In the end I wanted to see if I could have my program launch a simple ...
-3
votes
1answer
180 views

C# Share Datatable in Multi-threading

I am beginner in Multi-threading in C# & confuse in current task. My task is to read datatable and display datatable in C# console application using multi threading. I have three threads and one ...
0
votes
1answer
375 views

Strange C# method call syntax

Can you explain this method call syntax to me? this.mainParticleSystem.Simulate(time, withChildren: false, restart: true); Particularly I don't understand what withChildren: false parameters syntax ...
0
votes
3answers
152 views

What is the best way to update boolean variable in this particular scenario? [closed]

I have the following class and a method named ValidateEverything(), where IsEverythingValid becomes true only when a or b or both of them are true. I was wondering about what would be the best way to ...
2
votes
0answers
80 views

Creating a generic Cache solution for function calls using SOLID principles in C#

I would like to have a caching solution for a variety of function calls. All of the function calls fit the following signature public ResponseType ProcessRequest(RequestType request); About half ...
4
votes
1answer
116 views

Using delegates as named lambdas

Suppose we have a domain in which we can generalise some operation by passing in a function, like the Select \ map functions. Now suppose that the function we pass in has some domain specific name, ...
-2
votes
1answer
50 views

logging for an web application deployed on multiple nodes

My production setup involves four servers running behind load balancer. I have same set of web applications deployed on all four servers. The log files generated on one server are completely isolated ...
7
votes
2answers
418 views

When and why to use Nested Classes?

Using Object Oriented Programming we have the power to create a class inside a class (a nested class), but I have never created a nested class in my 4 years of coding experience. What are nested ...
99
votes
16answers
15k views

Should I add redundant code now just in case it may be needed in the future?

Rightly or wrongly, I'm currently of the belief that I should always try to make my code as robust as possible, even if this means adding in redundant code / checks that I know won't be of any use ...
1
vote
1answer
80 views

Split class into two or leave as one

I have the following class: internal class LeaveRequest : ServiceBase { private const string InvalidRequestMessage = "Specified Request does not exist"; private const string ...
0
votes
1answer
53 views

Retrieve variable from Console.ReadLine()

I am making a tic-tac-toe game in C#. I have a string variable for each square. I want to make it so the user inputs the square name i.e. (topMiddle). Then I declare the input playerInput. I want to ...
3
votes
3answers
208 views

Optimal way to use null conditional operators in boolean expressions

You are writing a boolean expression that might look like this: team.Category == "A Team" && team?.Manager?.IsVietnamVet public class Manager { public bool IsVietnamVet { get; set; } } ...
5
votes
1answer
111 views

Partially parallel producer-consumer pattern with internal state

I need to implement a producer-consumer pattern for reading, processing and saving electrical values. I have to implement this in C# .NET 4.6.1. I try to describe this in great detail, so that there ...
2
votes
1answer
138 views

Developing a calculator using the command pattern

In an attempt to solidify my understanding of the command pattern, I decided to write a calculator application that utilised it. After making some progress, I realised that my choice of application ...
4
votes
1answer
169 views

Am I using the factory method design pattern correctly, or which creational pattern should I use?

I've been studying creational design patterns for the past week or so because I have a common use case that keeps coming up, and I can't figure out which pattern fits the bill. Here is a simplified ...
-1
votes
3answers
216 views

Is there any technical reason to be concerned with casting speed?

So, I'm working on a project that takes a very complex entity from a third party framework and converts it into the native object that defines that entity. This entity has several one-to-many ...
0
votes
0answers
40 views

Where to store DataSets in this project?

I'm currently running a structure like this in my C# project: .Classes (This is where I store my classes) .UI (WinForms) .Helpers (Utility classes and extensions) .Reports( .rdlc reports) Now I'm ...
0
votes
0answers
63 views

Centralized management of app.config parts for self-hosted .NET services

What will be the best way to handle these scenarios, if they are not one-time, but regular: Self-hosted services on quite a bunch of machines are needed to be reconfigured to a different database in ...
4
votes
2answers
176 views

Can StringBuilder be used to effectively store and manage multiple variables of data?

Using C# I want to create one or more text files to store all the data pertaining to a particular 'Thing' on the same line. I am presently leaning towards StringBuilder as per the following. sb....
2
votes
4answers
125 views

Are names like OrderCreation and UserRegistration suitable names for business logic / domain classes

We have moved to a more SRP model and found coming up with class names challenging. Previously we had a Order class that looked something like this: public class Order { public void Create() {...
3
votes
8answers
726 views

Why can't we just use variables instead of constants?

I can't see the point of constants. For example I can use the famous example of PI: PI = float(3.14) Here I get the job done without a constant. Who cares if the value never changes during the ...