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
158 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 ...
1
vote
2answers
185 views

Testing C# Eventhandler Subscription

I want my unit tests to be able to verify that some events were subscribed or unsubscribed at specific points. Currently, I see two options. VerifiableEventHandler Each client subscribes using the ...
1
vote
1answer
165 views

Best practice for projects architecture - server side [closed]

The usual way (that I'm familiar with) to divide the server side is the n-layer architecture : DAL - data access layer, usually has the Entities and the context (and maybe include also a repository) ...
1
vote
1answer
228 views

How can I create a set of random numbers based on a total and number of objects?

For example with: Total population = 400000 Number of villages = 800 The average population is 500 How can I randomize the amount of people in each village using a specified deviation (eg +-50) so ...
0
votes
1answer
212 views

The problem of dependencies management

Let's consider the next situation: We have a module A which has a class Crt570 intended to interact with a device. We have a module B which uses Crt570 in the class called M100Communicator. We have ...
0
votes
1answer
115 views

A specific problem with architecturing a part of our application

Firstly, I'll try to describe the real world model of what we are trying to express in C# code. We have a device called M100. It's purpose is to read\write data from\into cards (plastic or ULTRALIGHT ...
0
votes
1answer
91 views

Executing user configuration settings

For an API I'm building what it does is load an XML file that is passed to it as a string, drill to the correct element, modify values, and return the modified XML. I'm doing something like this in ...
1
vote
2answers
191 views

Environment-aware Code

There are situations where the deployed environment (development, test, or production, for example) might dictate the outcome of certain actions. For example, perhaps a successful "user registration" ...
0
votes
1answer
172 views

Export to Excel - threading

I am working on an ASP.NET application. One requirement by the users is they are capable of exporting to Excel of some UIs. I have worked on them using the Infragistics library, and I have supplied ...
0
votes
3answers
238 views

Storing a C# dictionary of type <datetime,enum> [closed]

As title says it, i'm looking for a way to store many dictionaries (one per user) of type Dictionary<DateTime,enum> in a database (sql server 2012). Each dictionary has 366 items inside and it ...
0
votes
2answers
190 views

Gathering IP address and workstation information; does it belong in a state class?

I'm writing an enterprisey utility that collects exception information and writes to the Windows Event Log, sends an email, etc. This utility class will be used by all applications in the corporation: ...
1
vote
1answer
199 views

Does the recent open sourcing of MSFT's C# compiler mean it can be made cross-platform? [closed]

I really enjoy working with C# however one of its biggest drawbacks is that it is kind of split-brained between MSFT .NET and Mono. In practice its not a big deal most of the time but it is one of ...
0
votes
7answers
759 views

Is there any performance benefit in checking the item count prior to executing a foreach loop?

I saw this in code and was wondering if there is any performance benefit to checking the item count prior to looping: if (SqlParams.Count > 0) foreach (var prm in SqlParams) ...
9
votes
2answers
383 views

Compile-time IOC

Has anyone started a project to do IOC at compile time (possibly using Roslyn or Linq MethodInfo emit)? My experience with IOC containers has thus far been great, baring a few small issues Many IOC ...
0
votes
2answers
189 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' ...
1
vote
1answer
224 views

Organising data access for dependency injection

In our company we have a relatively long history of database backed applications, but have only just begun experimenting with dependency injection. I am looking for advice about how to convert our ...
0
votes
3answers
378 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
1answer
251 views

ASP.net performance code behind vs app_code

I am wondering about performance of a web site/application when there is code in the code behind files rather than when the code is moved to separate files in the App_Code folder. My understanding ...
1
vote
2answers
373 views

Testing ASP.NET .aspx and .ascx code behind files

I am wondering how to test .aspx.cs and .ascx.cs code behind. Can I use unit testing and if so how? Are there alternatives that will help test the functions in the code behind files? I don't know how ...
1
vote
1answer
174 views

How to get back into software development when you took a 10yr break? [duplicate]

I graduated 2004 CECS and the only experienced I had was at intern for 2 years. At that time I had c and c++ knowledge. I took a 10yrs break and now want to go back into it. I am interested in c#. ...
0
votes
1answer
359 views

Domain driven design and WCF services architecture

I am trying to figure out how to architecture my project in the DDD paradigm (a complete beginner in DDD) and stumbled upon a problem about the implementation of the web services... These are some ...
0
votes
2answers
74 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 ...
1
vote
0answers
115 views

How much segregation is too much in this design?

We are working on ASP.NET webforms application developed using WCSF (MVP pattern). In the application, there is a search screen that allows the user to enter some fields and display the results. We ...
-3
votes
1answer
46 views

Text field Form [closed]

I have 2 forms that have text input fields. One is written in JavaScript and the other in ASP NET. I would like to prevent a single symbol, the dollar or string "$" symbol from being entered into the ...
-1
votes
1answer
112 views

RESTful API Call Method Names, C# [closed]

I am working on some old code that works with a REST api in c#. The method names (what method to invoke on the API side) is being passed in as hard-coded strings. Would a static class be the best ...
2
votes
2answers
108 views

Segregating interfaces/concerns to a tree

When working with a single object there are a number of ways to segregate interfaces to it. Breaking it into smaller components that can be treated independently. Breaking it into simpler ...
5
votes
1answer
254 views

How to modify ELO algorithm when number of games is low to reduce outliers

I've developed the standard ELO implementation that can be found here, but the problem I'm running into is that my players will only have between 10 and 40 games in a "season". Since my first season ...
0
votes
0answers
86 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 ...
0
votes
4answers
258 views

How to handle or prevent all Admins and users being removed

I have a website that stores all users in a database. A user can log on to the website and if they have sufficient privileges can add/delete users, as well as change their privileges. How do I ensure ...
2
votes
2answers
157 views

When to use custom collections?

I see a lot of APIs that use custom collections instead of just using strongly-typed packaged generics. For instance, the API will have a Object1Collection instead of just a List<Object1> (or ...
0
votes
2answers
308 views

how are virtual methods slower in C#

I was reading the that virtual calls make the code slower than calling non-virtual call in C#. However the IL instruction for both are the same callvirt except in cases where base.somemethod() is ...
0
votes
1answer
147 views

log4net - roll my own singleton, use LogImpl, etC?

Reposting here... hopefully the better place to seek opinions on the matter. :) Writing my own log4net wrapper class using C#. I want to create a lib such that I can reference it from any ...
1
vote
0answers
80 views

Guideline for managed (C#) and native code (C++) hybrid development [closed]

Is there any guideline for a mixed managed and unmanaged system architecture? Given the same amount of time I find managed code to give better performance. The default to pass by (constant) ...
1
vote
5answers
531 views

Unit Testing a method that contains two output type parameters

I was following a book Art of Unit Testing, This book says that You must not have any logic in Your asserts as this reduces readability of test, or I may be testing too many things at a time. Suppose ...
1
vote
0answers
100 views

State Pattern Code for embedded device - Dependency Injection of Device Objects in Context and State Classes

I'm wrestling with some code and I think I've finally gotten some state pattern code working with my events. I've got a simplified system that will work like this: This is my first go with State ...
1
vote
1answer
158 views

Designing software functions which are both pausable and restartable

Consider the following situation: One hardware device, two applications (1 C# application, 1 Firmware). The C# application sends frames to the firmware and the firmware executes scripts. C# -> ...
1
vote
0answers
82 views

Converting number based data to text based story [closed]

I'm looking for a model/strategy to use for converting data in the form of numbers into a text based story. The ultimate goal would be if the resulting story feels human written and that it is pseudo ...
-1
votes
1answer
80 views

ASP.net/IIS runtime envitonment [closed]

I'm not too experienced in the regard of configuring IIS/ASP.net. A client has asked me to extend the functionality of a custom web application I didn't develop. Unfortunately, they don't have the ...
0
votes
1answer
115 views

When getting a list of files to process, should I store them to a list of string, or a list of Stream? [closed]

for a list of files, coming from a list like from a file dialog is it better to store the list as a list of strings or should I convert each file to opened Streams stored in a List? For example ...
4
votes
1answer
306 views

Should reflection be part of design?

I'm currently designing a somewhat large program that will involve the simulation of math/physics models and collection of data (I have not implemented any code yet). One of the main problems I'm ...
2
votes
6answers
333 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 ...
1
vote
1answer
110 views

What design pattern can I use to represent processing data from any stream?

I'm reading data from a stream in buffered series of bytes (say 1024 bytes at a time) and do some comparison, checking, or processing, before writing it back to the same type of stream. Currently ...
0
votes
2answers
90 views

Best practice to return a long string in a stub

I have some methods im trying to test which use a StreamReader dependency that i mock using Rhino mocks. But it is a large xmlFile. In the spirit of unit testing im trying to keep away from using a ...
0
votes
3answers
505 views

How can I explain this is an anti-pattern? [closed]

I recently started at a new job. The existing system works OK but is poorly designed and hard to maintain, and they are planning to rebuild it in MVC and I fear it will be much worse. (Not because ...
2
votes
5answers
281 views

Create Database To Fit Data vs Make Data Fit The Database

I'm newish to programming and would like to know what people have found to be the most supportable option or rather what people find more understandable. I'm the only one writing code at my firm, but ...
14
votes
5answers
889 views

Why isn't java used as a build language?

If Java is a general purpose language, and building a program is something that can be described using the Java language, why isn't this the best way to write build files and instead we use tools like ...
1
vote
1answer
103 views

Software trial: limited time or limited functionality? [closed]

I am currently developing my first serious piece of software in C#. It is a good learning experience so far. My software is basically a task scheduling tool with some advanced features and ...
6
votes
4answers
2k views

Reason for (post/pre) increment operator in Java or C#

Recently, I've stumbled across question about predicting the output of code which heavily uses post/pre increment operators on integers. I am experienced C programmer, so I felt like at home, but ...
3
votes
2answers
307 views

Implementing the Interface Segregation Principle

Does this IConvertible interface satisfy the Interface Segregation Principle (ie. the "I" in SOLID)? Here is the definition: public interface IConvertible { TypeCode GetTypeCode(); bool ...