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

15
votes
1answer
448 views

What is the proper way to suggest features to be added to the C# language?

What is the proper way to suggest features to be added to the C# language? For example, I would like to have an operator similar to ?? but for selecting the min or max values. I'd like a <? b to ...
0
votes
0answers
105 views

Is this approach scalable?

I am working to rewrite a legacy application (C++) to C# ASP.NET MVC with EF6 but plan to upgrade to ASP.NET Core1 and EF Core 1. The database schema is really arcane in that it has a single schema ...
5
votes
1answer
317 views

Does unused code affects the assembly after startup (Memory for example)?

Disclaimer: I come from a PHP background. In PHP, I could have thousands files, which are never loaded, if not needed, due to the autoloader feature (If some code is needed, it would be loaded) How ...
0
votes
0answers
47 views

can a parallel queue empty itself?

Is there a way to accomplish this pseudo-code in C# in .NET4.5? parallelQueue.attemptDequeueFirstItem(item) success -> ( doAsyncTask(item).Success(UpdateDatabase) ) ...
0
votes
1answer
94 views

Neat way on passing interface parameter to a constructor

Having lots of Interface that needs to pass in a constructor looks messy, is there any neat way of doing it? Code snippet: public class Foo { private readonly IRepository1 _repository1; ...
2
votes
2answers
128 views

Differences between Given When Then (GWT) and Arrange Act Assert (AAA)?

In TDD there is Arrange Act Assert (AAA) syntax: [Test] public void Test_ReturnItemForRefund_ReturnsStockOfBlackSweatersAsTwo_WhenOneInStockAndOneIsReturned() { //Arrange ShopStock shopStock ...
-2
votes
1answer
103 views

Why are interfaces necessary in MVP design pattern?

I am trying to understands MVP using Winforms. I found this example. Why do UserModel and UserView need to implement the IUserModel and IUserView interfaces ?
3
votes
3answers
2k views

Separation of retrieving data and business objects between DAL and BLL Layers

I did some research before posting this question. Among other questions or post, one of those is provided below. I could not get a clear mind how to determine.. Business Objects within a Data Access ...
0
votes
0answers
112 views

Are assemblies packed into another sort of file(e.g Portable Executable) before JIT starts converting CIL into native code?

I've read that assembly is the smallest unit of functionality and that CIL code is stored in assembly along with assembly metadata.If this is true, here's my question: Are assemblies packed into ...
10
votes
1answer
7k views

How can I improve my application's memory use? [closed]

I am writing a C# application, and can see the memory usage increasing as the running time of the application increases. Are there any tools or techniques I could monitor my application's memory ...
14
votes
3answers
4k views

Should I use .ToString() when concatenating string and integer variables in C#?

int a = 1; int b = 2; int sum = a + b; string expression = "Expression: " + a + " + " + b + " = " + sum; Console.WriteLine(expression); //displays Expression 1 + 2 = 3 Should I use: string ...
56
votes
11answers
6k views

Does this class design violate the single responsibility principle?

Today I had an argument with someone. I was explaining the benefits of having a rich domain model as opposed to an anemic domain model. And I demoed my point with a simple class looking like that: ...
2
votes
0answers
49 views

Log with Application Insights only (NLog vs AI) in Asp MVC

I was going through several blog posts and stackoverflow and programmers and I am still a bit confused. You can install NLog (or some other logging lib) and start logging quite fast and then you can ...
12
votes
2answers
4k views

How does C++ handle multiple inheritance with a shared common ancestor?

I'm not a C++ guy, but I'm forced to think about this. Why is multiple inheritance possible in C++, but not in C#? (I know of the diamond problem, but that's not what I'm asking here). How does C++ ...
1
vote
2answers
155 views

For what reasons Java and C# initialize static data on demand?

I am reading "The Go Programming Language" right now and I have read package initialization chapter which tells (or I read it wrong) that Go uses eagerly initialization. So in time we saw say C++ ...
1
vote
0answers
95 views

Option<T> functional type implementation and scenarios

Have you ever being implementing Option<T> functional type? It is discussed here: https://app.pluralsight.com/library/courses/tactical-design-patterns-dot-net-control-flow/table-of-contents ...
1
vote
2answers
74 views

Where to inject dependency required by all implementors of an interface?

I have an interface whose job is to communicate with repository (that implements some interface). It doesn't seem to make sense to implement this interface without receiving a repository,so I'd like ...
7
votes
2answers
130 views

Should `Vector<float>.Equals` be reflexive or should it follow IEEE 754 semantics?

When comparing floating point values for equality, there are two different approaches: NaN not being equal to itself, which matches the IEEE 754 specification. NaN being equal to itself, which ...
2
votes
4answers
211 views

Handling Multiple Collections in C#

I'm currently trying to learn C# and want to enhance my understanding of Object Oriented Programming (OOP). I'm hoping to accomplish this by experimenting with a small program that keeps track of my ...
3
votes
2answers
778 views

How do you apply Single Responsibility principle to a repository

I am trying to apply "SOLID" whenever I can and try to use common sense and avoid a pattern when I see that a pattern is creating more problems than it's trying to solve. I don't want to apply a ...
23
votes
4answers
3k views

How many days is it normal for a new hire programmer to take to get up to speed? [duplicate]

I have just landed a role as a C#/Asp.Net developer at a large software house. I have previously worked at a much smaller software house for about two years but it was a varied/mixed role there, and ...
3
votes
3answers
365 views

Generics vs common interface?

I don't remember when I wrote generic class last time. Every time I think I need it after some thinking I make a conclusion I don't. The second answer to this question made me to ask for ...
0
votes
1answer
93 views

Can I enforce the overriding of GetHashCode() and Equals() methods for users of a generic container class?

I have a container class similar to the one below (with much of the logic omitted): class Container<T> { Dictionary<T, TWrapped> contains = new Dictionary<T, TWrapper>(); ...
0
votes
2answers
457 views

Do reactive extensions and ETL go together?

I don't fully understand reactive extensions, but my inital reading caused me think about the ETL code I have. Right now its basically a workflow to to perform various operations in a certain ...
22
votes
7answers
2k views

Specify optional parameter names even though not required?

Consider the following method: public List<Guid> ReturnEmployeeIds(bool includeManagement = false) { } And the following call: var ids = ReturnEmployeeIds(true); For a developer new to ...
1
vote
1answer
190 views

Can sequence alignment algorithms be used for search implementation?

Hi I want to implement a search on a website which includes imperfect search results. Meaning, if the search term is misspelled or slightly different from a 100% match, the function should still ...
7
votes
2answers
39k views

Generating a class dynamically from types that are fetched at runtime

Is it possible to do the following in C# (or in any other language)? I am fetching data from a database. At run time I can compute the number of columns and data types of the columns fetched. Next I ...
0
votes
1answer
96 views

Best way to get push notifications to server from ms sql database

I partially found solution to my question but I'm not really satisfied with the result. My application consists of ASP.NET MVC + MS SQL Server. The case is as follows: External app saves data ...
42
votes
7answers
10k views

Single Responsibility Principle - How Can I Avoid Code Fragmentation?

I'm working on a team where the team leader is a virulent advocate of SOLID development principles. However, he lacks a lot of experience in getting complex software out of the door. We have a ...
2
votes
2answers
177 views

Where is the class itself stored at runtime to be used as a reference

In C# or Java we find that the objects are stored on heap and their reference vars are stored on stack. But at run time where is the class definition stored to be used as a template for creating ...
5
votes
2answers
266 views

How does breaking up a big method into smaller methods improve unit testability when the methods are all private?

I'm presently reading Building Maintainable Software by Joost Visser and some of the maintenance guidelines they recommend include: A) each unit/method should be short (less than 15 lines per method) ...
0
votes
2answers
188 views

Create the fields in class level then instantiate inside methods or create and instantiated inside methods

I'm a newbie in software development. Just wondering which code is better and why should I continue which pattern I should follow. First Snippet: Class TestClass { private Object1 field = null; ...
1
vote
3answers
285 views

How can I sell DRY? [closed]

Where I work we have around 10 VS projects in a solution which are identical in functionality (with some different different rules in a few methods) and share many exact methods. They share the same ...
4
votes
4answers
175 views

Best practice for getting last record inserted in DB

Me and a couple of colleagues are having a discussion regarding the following case: In an OrderStatus table we're keeping track of all the statuses an order goes through in time, including ...
12
votes
5answers
10k views

Programming practice - Is there a site that has a daily “write a method to do X” type challange? [duplicate]

Possible Duplicate: Programming Puzzles Looking for ways to help me improve my C# coding skills. I thought it would be handy if there was a site that asked you to write a new method every ...
1
vote
1answer
228 views

How to scale a C# server application

I'm writing a pretty simple TCP server/client application for the first time. It is a personal project for education, but I really like my applications to be extendable and to scale in case the code ...
0
votes
1answer
54 views

Create/destroy multiple threads for animations/light effects

I'm developing a program for the Razer Deathadder and Firefly, I am going to create new light effects for the Firefly. I'm doing this in C# with the Colore library. Now these light effects will be ...
2
votes
2answers
641 views

Any OOP design pattern that is somewhat representative of all of the SOLID OOP design principles at play?

I'm trying to teach an object oriented design principles course (on SOLID) at a training institute. I also want to teach the students a few OOP design patterns such as factory, singleton and one ...
3
votes
3answers
229 views

Single Responsibility - is this class doing too much?

I'm redesigning one of my programs which performs certain actions on processes of interest (known as "Monitored Processes" in my program). Some actions I always need to do on those processes are: ...
2
votes
1answer
106 views

Pattern for interface between sequence executing object(s) and sequence configuration objects

My motivating case is hardware test automation. We have several different testers (benches of lab equipment that connect to the "device under test" (DUT)), and we write test configuration files which ...
0
votes
0answers
57 views

How to prevent parallel calls to model?

While there is some command running which calls methods on some model, how to prevent concurrent calls for critical places in that model? If multiple requests comes in then they should maintain their ...
1
vote
1answer
47 views

Structuring projects in a solution for interfaces

I had this idea that I would achieve some good automation and separation of concerns as follows: Define an interface, IDataProvider, in a class in a DataMuncher project that needs to both consume ...
91
votes
8answers
71k views

How do you organize your projects? [closed]

Do you have any particular style of organizing projects? For example, currently I'm creating a project for a couple of schools here in Bolivia, this is how I organized it: TutoMentor (Solution) ...
1
vote
1answer
179 views

What is wrong with this substring-matching algorithm? [closed]

At a recent interview I was asked to write an algorithm which: Given a string text, and string subtext, finds the starting character positions of each subtext found within the text. "hey hi how are ...
1
vote
1answer
149 views

Modular Filter Architecture for WPF

I am creating a little stock-management tool for private use. I have different views, which need similar but different filters. As an example i have a "current stock" list where i can filter for ...
2
votes
1answer
126 views

Algorithm to get all paths in a tree

I have a tree that has n-levels. For example here I have four levels: Each node has two children (except for the last one), however everyone except for the first and last node of each row has two ...
1
vote
1answer
100 views

Azure BLOB grained access

I have a standalone WPF desktop application which gathers data from Digital-to-Analog converter boards, computes, analyzes this data and then it creates binary files (proprietary format) with the ...
2
votes
2answers
362 views

How/when to “build” a Singleton that stores configuration data

I am a junior developer (think "intern-level" experience) working at a small shop more or less alone on a project that consumes data from a database, processes it, and inserts the results into another ...
1
vote
3answers
168 views

The best practice for passing formatted string to methods

Though it might be trivial for someone, I find it a little inconvenient when someone formats the string while passing it as a parameter to a method. For e.g. AddMessage( string.Format("{0} (" + ...
0
votes
1answer
73 views

How to automate common tasks in development and production between my computer and our servers? [closed]

I'm working as a web developer. Our server is in MVC ASP.NET (C#) and SQL Server. We also work with wordpress for content, and SVN for integration of code between front end developers and back-end ...