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

5
votes
3answers
152 views

Where do I place my example implementations in my framework?

I've created a pretty simple templating framework and have default implementations for some of my interfaces used for passing around information. I store these in MyFramework.Default namespace ...
27
votes
5answers
3k views

Pass ID or Object?

When providing a business logic method to get a domain entity, should the parameter accept an object or an ID? For example, should we do this: public Foo GetItem(int id) {} or this: public Foo ...
28
votes
15answers
2k views

Is it wise to be going back and forth between two programming languages? [closed]

I have been writing quite a lot of PHP for nearly two years. Now I am doing .NET (mainly c#) development. However, sometimes I go back and do some php. My main question is, is it wise for me to ...
8
votes
4answers
4k views

Return interface or class

Suppose I have a method public List<User> GetBatchOfUsers(IEnumerable<int> userIDs) { List<User> users = new List<User>(); // some database stuff return users; } ...
-2
votes
2answers
2k views

A good way of creating XML files at run time

Please stare at this structure for a second :) I should create such a thing all at run time. What are the values that we pass in at run time? the string values you see after "#" are passed in so ...
34
votes
6answers
5k views

How do you encode Algebraic Data Types in a C#- or Java-like language?

There are some problems which are easily solved by Algebraic Data Types, for example a List type can be very succinctly expressed as: data ConsList a = Empty | ConsCell a (ConsList a) consmap f ...
25
votes
10answers
10k views

Why the question “give five things you hate about C#” is so difficult to answer during an interview? [closed]

In podcast 73, Joel Spolsky and Jeff Atwood discuss, among other subjects, "five things everyone should hate about their favorite programming language": If you’re happy with your current tool ...
0
votes
4answers
3k views

Application connecting to database server

I'm working on an application which requires user credentials and so on. So a database is required on the backend. What is the best practice to connect to a database without hardcoding your password ...
92
votes
11answers
27k views

What backs up the claim that C++ can be faster than a JVM or CLR with JIT? [closed]

A reoccurring theme on SE I've noticed in many questions is the ongoing argument that C++ is faster and/or more efficient than higher level languages like Java. The counter-argument is that modern JVM ...
-2
votes
2answers
708 views

How do I tell the cases when it's worth to use LINQ?

Many things in LINQ can be accomplished without the library. But for some scenarios, LINQ is most appropriate. Examples are: SELECT - ...
3
votes
3answers
2k views

Writing Unit Tests for a Class That Starts External EXE

I wrote a C# class that is used to start a list of EXEs (not one of mine - third party EXEs I have to run) and keep them running (will check occasionally to make sure it is still running, and start ...
11
votes
0answers
241 views

Return magic value, throw exception or return false on failure? [duplicate]

Possible Duplicate: Return magic value, throw exception or return false on failure? We've all seen these: a string format error, end of stream, item not found. While coding a class library ...
13
votes
3answers
2k views

Can someone explain to me C#'s coding convention?

I recently started working with Unity3D and primarily scripting with C#. As, I normally program in Java, the differences aren't too great but I still referred to a crash course just to make sure I am ...
39
votes
8answers
15k views

Return magic value, throw exception or return false on failure?

I sometimes end up having to write a method or property for a class library for which it is not exceptional to have no real answer, but a failure. Something cannot be determined, is not available, not ...
8
votes
4answers
3k views

Are fluent interfaces more flexible than attributes and why?

In a EF 4.1 Code First tutorial the following code is given: public class Department { public int DepartmentId { get; set; } [Required] public string Name { get; set; } public virtual ...
0
votes
3answers
276 views

Dynamic choice of compilers?

An application has the following logic: client => created *.cpp => sent to the server => cl.exe + *.cpp = *.exe client => created *.cs => sent to the server => csc.exe + *.cs = *.exe client => ...
0
votes
1answer
12k 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 { ...
6
votes
2answers
1k views

.Net Language Interoperability Gotchas [closed]

I hope this is the appropriate forum to ask this question. A group of colleagues and I just starting learning C# a few weeks ago and we are planning on having a discussion about language ...
3
votes
2answers
549 views

What is a good design strategy for retaining history of user activities and files like Visual Studio projects?

OK so I'm not so sure that "project" is the right term, but for my purposes, I define "project" as similar to what Visual Studio uses, or Microsoft word - files that the user can open and work on and ...
4
votes
4answers
630 views

Do large test methods indicate a code smell?

I have a particular method called TranslateValues() (Cyclomatic-Complexity of 5) which I would like to test. The test requires a substantial number of mock objects which take up most of the method; ...
7
votes
2answers
3k views

Storing and maintaining serialized objects in C#

What are the best practices to store and maintain serialized objects in C#? Any strategies or patterns that apply? What I have come to believe so far is this: Prefer Json over XML, both for space ...
4
votes
6answers
1k views

What pitfalls are inherent in using partial classes?

Over at this question in the comments I mentioned that I heard that partial classes are best avoided if possible. What if any is the reason for this sentiment? Or If this is an invalid sentiment, how ...
0
votes
3answers
216 views

How to port this architecture to .net?

My team is currently locked into using a tool we dislike that takes the form of a Eclipse plugin and a .jar; the plugin gives us a button to quickly run a single file's code (via invoking the main ...
15
votes
8answers
2k views

Is it common to use partial classes to achieve 'modularity'?

I recently encountered a situation in our codebase where a different team created a 'god class' containing around 800 methods, split across 135 files as a partial class. I asked the other team about ...
3
votes
2answers
675 views

Add a second developer to the team

In my company, I'm the only developer, but we plan on expanding the team by hiring a second programmer. I know there are a lot of implications to that (especially around source control). I've Googled ...
3
votes
2answers
559 views

How do you follow the single responsibility principle in classes responsible for behaviour?

I have many classes in my application responsible for behaviour- views, controllers, models, network- often the state of one class or system depends on another and I'm finding that classes that are ...
1
vote
1answer
1k views

Clients with multiple proxy and multithreading callbacks

I created a sessionful web service using WCF, and in particular I used the NetTcpBinding binding. In addition to methods to initiate and terminate a session, other methods allow the client to send to ...
3
votes
2answers
2k views

Refactor class (extract methods) in a main / helper classes

Simply spoken, one of my c# classes got too big and I'm currently splitting this class in several subclasses by clustering semantically related methods (actually actions, which do side effects). So, ...
2
votes
1answer
687 views

Were method cascades ever considered for C#?

Smalltalk supports a syntax feature called "message cascades". Cascades are being adopted by the Dart Programming language. As far as I know, C# doesn't support this. Were they ever considered during ...
0
votes
1answer
671 views

WCF service and security

Been building a WP7 app and now I need it to communicate to a WCF service I made to make changes to an SQL database. I am a little concerned about security as the user name and password for accessing ...
1
vote
2answers
126 views

OSS - GPL v3 plugins in non-copyleft codebase.

I've been working on software to modify a game's resource files, and I'm planning on releasing it in open source. I'm perfectly fine with releasing my code under gpl v3. However, I'm afraid that ...
1
vote
1answer
612 views

Abstraction Layer over ORM Generated Entities

I am learning LINQ to SQL (and planning to learn Entity Framework). Initially I used a abstraction layer to convert LINQ to SQL entities into a domain objects. Later I discovered the “Inheritance ...
16
votes
7answers
2k views

What is the correct order to read these books? [closed]

I'm a junior C# developer, I learned at home and now I got my first job :) I want to buy these books. But what is the correct order to read these books? Code Complete: A Practical Handbook of ...
4
votes
2answers
621 views

Storing IEnumerable as instance variable - is it a code smell to expect it to change?

I have something that works like a fixed size list - it's actually called FixedSizeStack<T> in my program. I will use it to represent the X last occured events. This event list will then be ...
5
votes
3answers
3k views

How to make Unit Tests to make sure stored procedure is deleting row from the database?

I'm new to unit testing and I need some help with the following. I have created a small project to help me learn how to make Unit Tests. The functionality for one of the forms in my application ...
2
votes
2answers
2k views

Is this method of writing Unit Tests correct?

I have created a small C# project to help me learn how to write good unit tests. I know that one important rule of unit testing is to test the smallest 'unit' of code possible so that if it fails you ...
18
votes
6answers
21k views

Advantages and disadvantages to using XAML/C# or HTML5/JavaScipt for Metro apps? [closed]

I was just wondering if there are any major advantages or disadvantages to using either XAML/C# or HTML5/JavaScript for Metro Apps.
46
votes
8answers
5k views

Why a static main method in Java and C#, rather than a constructor?

I’m Looking for a definitive answer from a primary or secondary source for why (notably) Java and C# decided to have a static method as their entry point, rather than representing an application ...
31
votes
4answers
4k views

Why does F# have an interactive mode but not C#?

F# comes out of the box with an interactive REPL. C# has nothing of the sort and is in fact kinda difficult to play around without setting up a full project (though LINQpad works and its also possible ...
0
votes
3answers
612 views

What are the pre-requisites for writing .NET web services?

I am very new to web development. I have been a C,C++ programmer for 5 years and I'm starting to get into the web development, writing web services, etc. I understand that basic concepts of web ...
2
votes
4answers
684 views

Do I lose anything by coding in c# and using free online vb.net code convertors? [closed]

The company I work for uses vb.net since there are many programmers who moved up from vb6 to vb.net. Basically more vb.net resources in the company for support/maintenance vs c#. I am a c# coder and ...
5
votes
2answers
2k views

Should I expose IObservable<T> on my interfaces?

My colleague and I have dispute. We are writing a .NET application that processes massive amounts of data. It receives data elements, groups subsets of them into blocks according to some criterion and ...
-2
votes
1answer
262 views

Single Responsibility Principle: Responsibility unknown [closed]

I store sessions in a SessionManager. The session manager has a dependency to ISessionPersister. SessionManager private readonly ISessionPersister sessionPersister; public ...
3
votes
4answers
8k views

Practical size limits of a DataTable in c#

I have to query a large data-set (~500 MB) using a sqlDataReader but I have to save the data in three different formats. Instead of querying the database 3 times I'm thinking about saving the data to ...
7
votes
1answer
8k views

Future of WPF and free controls ? [closed]

I am willing to work on a personal project that I would like to release publicly. I am working with Silverlight and have experience with XAML, as it is my full-time job. It is enjoyably for me to ...
3
votes
1answer
324 views

Is the structure used for these web pages a design pattern?

I want to know if the structure for an ASP.NET website I'm working on uses a design pattern for it's web pages. If it is a design pattern, what is it called? The web pages have the following ...
4
votes
1answer
1k views

Designing a Content-Based ETL Process with .NET and SFDC

As my firm makes the transition to using SFDC as our main operational system, we've spun together a couple of SFDC portals where we can post customer-specific documents to be viewed at will. As such, ...
2
votes
1answer
3k views

Best way to reuse common functions between ASPX pages ?

I have a bunch of functions that are used across multiple ASPX files. I want to condense these down to one file to be used for all the ASPX files. I have a few ideas but I want to know what the ...
3
votes
2answers
2k views

Should this code/logic be included in Business Objects class or a separate class?

I have created a small application which has a three tier architecture and I have business object classes to represent entities such as User, Orders, UserType etc. In these classes I have methods that ...
7
votes
3answers
10k views

Best Architecture for ASP.NET WebForms Application

I have written an ASP.NET WebForms portal for a client. The project has kind of evolved rather than being properly planned and structured from the beginning. Consequently, all the code is mashed ...