Questions tagged [.net]

The .NET Framework is a software framework for Microsoft Windows operating systems. It includes an implementation of the Base Class Library, Common Language Runtime, and Dynamic Language Runtime. It supports many programming languages, including C#, VB.NET, F# and C++.

Filter by
Sorted by
Tagged with
49 votes
5 answers
59k 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 ...
mayur rathi's user avatar
37 votes
8 answers
6k views

Why do .Net books talk about stack vs heap memory allocation?

It seems like every .net book talks about value types vs reference types and makes it a point to (often incorrectly) state where each type is stored - the heap or the stack. Usually it's in the first ...
Greg's user avatar
  • 805
36 votes
3 answers
21k views

Why is there no generic implementation of OrderedDictionary in .net?

Why did Microsoft not provide generic implementation of OrderedDictionary? There are a few custom implementations I've seen, including: http://www.codeproject.com/KB/recipes/GenericOrderedDictionary....
nonot1's user avatar
  • 711
35 votes
8 answers
3k views

S.O.L.I.D., avoiding anemic domains, dependency injection?

Although this could be a programming language agnostic question, I'm interested in answers targeting the .NET ecosystem. This is the scenario: suppose we need to develop a simple console application ...
David Robert Jones's user avatar
34 votes
13 answers
40k views

Career advice: stay with PHP or start a new career in something else ( .Net?) [closed]

I'm planning on moving to NY in 6-12 months tops, so I'm forced to find a new job. When I'm planing to start my life in another city it's also probably a good time to think about career changes. I've ...
Christian P's user avatar
  • 1,954
33 votes
4 answers
6k 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 ...
George Mauer's user avatar
  • 2,012
32 votes
7 answers
11k views

How to treat unhandled exceptions? (Terminate the application vs. Keep it alive)

What is best practice when a unhandled exceptions occurs in a desktop application? I was thinking about to show a message to the user, so that he can contact support. I would recommend to the user to ...
Jonas Benz's user avatar
32 votes
11 answers
20k views

Declaring interface in the same file as the base class, is it a good practice?

To be interchangable and testable, normally services with logic needs to have interface, e.g. public class FooService: IFooService { ... } Design-wise, I agree with this, but one of the things that ...
Louis Rhys's user avatar
  • 6,122
27 votes
15 answers
2k views

How do I convince my team to use smaller classes/methods?

Disclaimer: I'm a newcomer (this is my third day of work), and most of my teammates are more experienced than me. When I look at our code, I see some code smells and bad engineering practices, like ...
Deltax76's user avatar
  • 1,041
27 votes
5 answers
54k views

Refactoring constructor that has too many parameters [duplicate]

I'm in my first two months as a software engineer and just wanted to get advice on if this can be improved upon. I've created a class that represents data from RFID in the form of a message: class ...
Matt's user avatar
  • 381
27 votes
8 answers
8k 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 ...
Joshua Smith's user avatar
  • 2,050
27 votes
3 answers
5k views

C# 8 non-nullable references and the Try pattern

There is a pattern in C# classes exemplified by Dictionary.TryGetValue and int.TryParse: a method that returns a boolean indicating success of an operation and an out parameter containing the actual ...
Sebastian Redl's user avatar
26 votes
7 answers
20k views

Best practices for moving large MS Access application towards .Net?

We have a really huge MS Access application developed in-house initially for our personal needs which then was turned into a commercial software and successfully sold. The software is a sort of "all-...
Alexander Galkin's user avatar
26 votes
1 answer
17k views

What is the purpose of Code analysis and when do I need to use it?

I heard about Visual Studio's Code analysis but never used one. I've read MSDN, but still don't understand the real use of Code analysis. Isn't it the same as StyleCop? Somewhere, FxCop was also ...
Arseni Mourzenko's user avatar
25 votes
6 answers
4k views

Should the usage of DI/IoC remove all occurrences of the "new" keyword?

Should the usage of Dependency Injection and an Inversion of Control container remove all occurrences of the "new" keyword from your code? In other words, should every object/dependency, no matter ...
CraigTP's user avatar
  • 1,554
24 votes
17 answers
6k views

Does Silverlight have a future? [closed]

Recently I have read some articles/blogs/comments about the development and history of WPF and Silverlight. In some forums many developers and users criticize the performance of WPF applications (for ...
Elmex's user avatar
  • 753
22 votes
2 answers
12k views

Isn't CQRS overengineering?

I still remember good old days of repositories. But repositories used to grow ugly with time. Then CQRS got mainstream. They were nice, they were a breath of fresh air. But recently I've been asking ...
SiberianGuy's user avatar
  • 4,793
20 votes
6 answers
4k views

What advantage was gained by implementing LINQ in a way that does not cache the results?

This is a known pitfall for people who are getting their feet wet using LINQ: public class Program { public static void Main() { IEnumerable<Record> originalCollection = ...
Panzercrisis's user avatar
  • 3,173
20 votes
9 answers
3k views

Constraints in a relational databases - Why not remove them completely?

Is there any reason to build constraints between tables (inside SQLserver) nowadays? If so, when? Most applications in my area are built on object principles and tables are joined on demand. Demand ...
Independent's user avatar
20 votes
8 answers
7k views

Why did Microsoft make parameters, local variables and private fields have the same name naming convention?

I asked this question quite some time ago: How do you name your private variables in C#? In one of the answers, I was pointed to Microsoft's MSDN page that shows that private variables/fields should ...
Vaccano's user avatar
  • 4,048
20 votes
3 answers
41k views

Best design for Windows forms that will share common functionality

In the past, I have used inheritance to allow the extension of Windows forms in my application. If all of my forms would have common controls, artwork, and functionality, I would create a base form ...
Jonathan Henson's user avatar
18 votes
13 answers
50k views

What are the practical uses of Windows Services? [closed]

I am new to working with Windows Services. Although I have learnt to create Windows Services in VS2010 I would like to know some practical ways in which windows services could be used? I tried ...
Karthik Sreenivasan's user avatar
17 votes
5 answers
5k views

What does Windows 8 mean for the future of .NET? [closed]

Microsoft showed off a demo of Windows 8, including a new platform that allows developers to use HTML5 and JavaScript. Is this new platform the main way to develop for Windows 8? Is Microsoft ...
Kottan's user avatar
  • 331
15 votes
5 answers
10k views

Is there a proper way to create a file format?

I'm building a proprietary file format for an application I wrote in C# .NET to store save information and perhaps down the line project assets. Is there a standard on how to do this in any way? I was ...
corylulu's user avatar
  • 271
14 votes
2 answers
3k views

How to Implement Error Handling [closed]

Even though I've programmed on a professional level for some years I still do not fully understand error handling. Although my applications work fine, the error handling isn't implemented at a ...
James Jeffery's user avatar
14 votes
2 answers
28k views

What is .NET framework backward compatibility?

We develop a windows application in .NET 4 with a database of MySQL. When we are about to deploy that application, we install the .NET 4 framework in our client, then when installing the .NET ...
John Isaiah Carmona's user avatar
14 votes
3 answers
8k views

What is an "application model"?

Currently I'm studying .NET Core and in the early docs which first introduced .NET Core we see that talk about the many different verticals. This can be seem in this picture: In all the verticals we ...
user1620696's user avatar
  • 4,867
13 votes
4 answers
3k views

How would I design an interface such that it's clear which properties may change their value, and which will remain constant?

I am having a design issue regarding .NET properties. interface IX { Guid Id { get; } bool IsInvalidated { get; } void Invalidate(); } Problem: This interface has two read-only ...
stakx's user avatar
  • 2,138
13 votes
2 answers
12k views

Dependency injection with n-tier Entity Framework solution

I am currently designing an n-tier solution which is using Entity Framework 5 (.net 4) as its data access strategy, but am concerned about how to incorporate dependency injection to make it testable / ...
Matthew's user avatar
  • 2,006
12 votes
11 answers
13k views

Examples of operator overloading, which make sense [closed]

While I learning C#, I found that, the C# supports operator overloading. I have problem with good example which: Make sense (ex. adding class named sheep and cow) Is not an example of concatenation ...
Paweł Sołtysiak's user avatar
12 votes
4 answers
14k views

Business Objects within a Data Access Layer

So I've been creating a data access layer via TDD and have approached somewhat of a concern. I'd rather not start down the wrong path, so I figured I'd ask you guys to see if my thoughts were in line ...
user avatar
11 votes
4 answers
1k views

Virtualized Development Environments in Enterprise Networks

We are attempting to implement a development environment using virtualization for a small team of 4 developers within an enterprise organization. This would allow us to set up separate development, ...
ScottBai's user avatar
  • 248
11 votes
6 answers
2k views

Which is more maintainable -- boolean assignment via if/else or boolean expression?

Which would be considered more maintainable? if (a == b) c = true; else c = false; or c = (a == b); I've tried looking in Code Complete, but can't find an answer. I think the first is more ...
Bret Walker's user avatar
11 votes
6 answers
13k 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 ...
ShamirDaj's user avatar
  • 111
10 votes
4 answers
3k views

Best practice with branching source code and application lifecycle

We are a small ISV shop and we usually ship a new version of our products every month. We use Subversion as our code repository and Visual Studio 2010 as our IDE. I am aware a lot of people are ...
Toni Frankola's user avatar
10 votes
1 answer
986 views

Injecting data processing logic into class

I want find more elegant and appreciate way to inject processors into CommandProcessorDispatcher class. Or it can be another one solution (the goal is separate each command processing logic to ...
Boo's user avatar
  • 217
9 votes
3 answers
2k views

Why do we have so many flavors of .NET? Is it a good thing? [closed]

There are many "flavors" of the .NET Framework: Full ("normal") Client profile subset Silverlight in web browsers "Silverlight" on Windows Phone Compact framework WinRT When C# code is needed on a ...
Paul Stovell's user avatar
  • 1,709
9 votes
2 answers
11k views

C# .NET MVVM software architecture and naming conventions

I am currently working on a software using C# .NET and WPF with the MVVM pattern. Though the software is almost done, I have been discussing our architecture for a long time and I would like to get ...
Rashimov Azarov's user avatar
9 votes
10 answers
14k views

Switch from C# to Java, which "gotchas" I should care?

I may have to switch to Java for new project. I have very little knowledge about Java, because I've mainly studied and used C#, and I'm afraid of the differences between these two language/platform ...
9 votes
1 answer
832 views

Naming of related classes and interfaces

I have created an ObjectParser class which parses data into strongly typed objects using an IObjectParserDataSource as the data source (the data could be an Excel file, text file, array, query string, ...
Dave New's user avatar
  • 897
8 votes
3 answers
4k views

Design Pattern - DLL per Strategy

I usually found myself designing my application in the following way: One DLL containing interfaces for a desired subsystem. For example, Company.Framework.Persistence.dll. One new DLL per each ...
Matias Cicero's user avatar
7 votes
3 answers
4k views

How to share methods and properties between custom web controls

I'm building some custom web controls in .NET using C#. The controls inherit from the standard web controls, and add additional properties and functionality (e.g. I'm creating an 'extendedTextBox' ...
Chris Halcrow's user avatar
7 votes
3 answers
9k views

When are chained assignments (i.e. a=b=c) bad form?

I'm working on a VB.Net WinForms project and found myself writing code like this: this.Fizz.Enabled = this.Buzz.Enabled = someCondition; I couldn't decide whether that was bad code or not. Are there ...
Jeff B's user avatar
  • 838
7 votes
7 answers
16k views

Which is better: many class definitions in the same file or every class definition in a separate file?

Which is better: many class definitions in same file or every class definition in separate file? Examples: 1) Many classes in same file. Say, myManyClasses.cs: namespace myPack { class myClass1(...
user avatar
7 votes
1 answer
3k views

How do we isolate dependencies for a .Net app deploy in a way which is safe for a strongly-named assemblies?

To design in such that it is easy to deploy dependencies with your app, and so that development environments are easy to set up, it is advantageous to isolate an app's dependencies from it's ...
Jordan Morris's user avatar
7 votes
3 answers
651 views

Unit Testing: Should we care about distinguishing between Mocks and Stubs?

There's been a lot of talk in various blogs, forums and on StackExchange about the distinction between Mock and Stub objects (most of them specifically referencing the Rhino Mocks framework). These ...
mjhilton's user avatar
  • 653
6 votes
5 answers
2k views

Performance: Is There a Reason to Use Processes over Threads?

This is a general question but I work in the .NET world so I'd like to know if there any specific quirks about the .NET Framework / Core platforms that I should be concerned about here. I think it's ...
Christian Findlay's user avatar
6 votes
4 answers
4k views

How are blocking calls implemented?

This may be a very simple question. I'm curious how blocking calls are implemented. Specifically, how do they block? Is this just thread.sleep?
ConditionRacer's user avatar
6 votes
3 answers
3k views

How do I support per-method-call instantiation without referencing the IoC container outside the composition root?

I read with interest this article which states: A DI Container should only be referenced from the Composition Root. All other modules should have no reference to the container. This means that all ...
John Wu's user avatar
  • 26.5k
6 votes
8 answers
4k views

What do you consider to be the essential design patterns? And do you use them? [closed]

It seems to me that programmers have an increasingly uphill task of staying up-to-date. In my efforts to improve my programming ability, I am in search of the essential design patterns that are ...
Stuart Blackler's user avatar