1
vote
1answer
147 views

Are the over-usage of delegates a bad thing?

Good day. I have been told that a good practice for writing methods is to make the method only responsible for doing one thing. It made sense to me now that I look back upon it in retrospect. There ...
1
vote
3answers
245 views

Trying to come up with a mapping convention for C# objects

so this is C# but it could apply to any OO language where different sets of objects exist across different layers of an application. We have been trying to come up with a convention within the team ...
0
votes
2answers
105 views

How to deal with a new version of visual studio's directory?

When upgrading Visual Studio to a newer version, a new directory is created e.g. "Visual Studio 2013". I understand that that makes sense as we want to differentiate between code targeting different ...
6
votes
2answers
194 views

Is it good practice declare a function inline?

I'm writing a method and depending on a config field I need to change where I get my data from. What this results in me having to write code that looks like this: List<string> result = new ...
2
votes
1answer
124 views

Is serialization better done in instance methods or static methods

Say I have a class workStockItem, that I wish to serialize. Which is the better style? using a static method or using a non-static method (maybe even implemented as a property as seen below) ...
1
vote
2answers
92 views

Scalable Job Handler

We have a job table that triggers a notification when a new job gets inserted. Clients that can handle such jobs may subscribe to those notifications. When a client receives a notification, he can ...
1
vote
0answers
117 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
2answers
408 views

Asterisks in Multi-line comments

Using Visual Studio 2012 with C#, when I write multi-line comments, VS automatically begins each line with an asterisk, like this: /* * * */ I was just curious if this was the case in ...
3
votes
1answer
86 views

Development console commands registration

I have a DevelopmentConsole class. I am making functionality to register console commands for the subsystems. I don't want the console to know about them but also I don't want them to contain a debug ...
2
votes
6answers
820 views

Stacking keywords on top of each other - poor style?

I have always wondered about this, especially in C/Java style languages. For example, consider the first 3 lines of this C# code: lock (serviceLock) using (var client = new ServiceClient()) try { ...
1
vote
3answers
2k views

Best Practices To Create Error Codes Pattern For an Enterprise Project in C# [closed]

I'm working on an enterprise project which will be deployed in many SMBs and Enterprises. The support for this project would be struggling and so I want to create a coding pattern for errors (Like ...
4
votes
4answers
954 views

Exceptions vs ErrorCodes when working with devices

Out team is at the cusp of a new project. One of the components at the boundary of the system is the component which interacts with a printer through an external COM component (referenced as a usual ...
6
votes
5answers
430 views

Why would a developer create a public class that has all static properties?

A previous developer has a couple public classes that do not inherit from any other classes but are filled with static properties. Is this another way of creating a struct or enum? Is this an older or ...
3
votes
3answers
123 views

Is it bad practice to have FooObject and FooObjectSummary?

I have a service where users can upload/download/replace/delete files. These files have about a dozen attributes that are saved to a SQL Database. Periodicaly throughout their session they will have ...
57
votes
11answers
6k views

Is it a bad practice to modify code strictly for testing purposes

I have a debate with a programmer colleague about whether it is a good or bad practice to modify a working piece of code only to make it testable (via unit tests for example). My opinion is that it ...
-1
votes
1answer
4k views

Object reference not set to an instance of an object [closed]

I'm making a simple Contact Manager as a practice project based on a XML file everything is working just fine except for two problems Every time I click on the white blank space on ListBox, I get ...
8
votes
4answers
5k views

Is it a good practice to create a ClassCollection of another Class?

Lets says I have a Carclass: public class Car { public string Engine { get; set; } public string Seat { get; set; } public string Tires { get; set; } } Lets say we're making a system ...
7
votes
3answers
3k views

How to encapsulate 'global' variables in C#? /best practice

In C# what is the best practice for encapsulating variables I need to use in multiple methods? Is it OK to simply declare them at the top of my class above the two methods? Also if I am using app ...
15
votes
4answers
1k views

Is the “Gets or sets ..” necessary in XML documentation of properties?

I am looking for a recommendation of a best practice for XML comments in C#. When you create a property, it seems like that the expected XML documentation has the following form: /// <summary> ...
0
votes
1answer
373 views

Is C# namespace should be Project-Name?

I am working with multiple websites (freelancer) and a good amount of them I write using C# MVC4. I created a very good boilerplace project that I plan to use on every next starting mvc4 application ...
1
vote
3answers
420 views

C# dynamics and Expando object [closed]

Under which application development scenarios C# dynamics and ExpandoObject can be used or when to consider using c# dynamics and ExpandoObject
4
votes
3answers
365 views

Renaming long named method in C# [closed]

I'm working on a project where exist one method with title string ValidateNewPasswordExpireCurrentPasswordAndCreateNewPassword(...) I'm sure the method name must be changed. But can't found good ...
6
votes
3answers
1k views

Child to Parent linking - bad idea?

I have a situation where my parent knows about it's child (duh) but I want the child to be able to reference the parent. The reason for this is that I want the child to have the ability to designate ...
13
votes
2answers
1k views

What is the best approach for inline code comments?

We are doing some refactoring to a 20 years old legacy codebase, and I'm having a discussion with my colleague about the comments format in the code (plsql, java). There is no a default format for ...
11
votes
13answers
2k views

Dealing with curly brace soup

I've programmed in both C# and VB.NET for years, but primarily in VB. I'm making a career shift toward C# and, overall, I like C# better. One issue I'm having, though, is curly brace soup. In VB, ...
6
votes
3answers
1k views

Exception Handling Frequency/Log Detail

I am working on a fairly complex .NET application that interacts with another application. Many single-line statements are possible culprits for throwing an Exception and there is often nothing I can ...
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 ...
7
votes
5answers
453 views

For what reasons should I keep “using” section clean in C#?

Once when I was refactoring my code, I went up the IDE to the using section of my C# class, and cleaned unused namespaces and duplicate namespaces, and sorted them all. My pair (pair programming) ...
6
votes
2answers
290 views

Is there a certain number of lines of code to be followed /maintain?

I am developing a software system (Patient Administration System) and I have noticed it already had 451 lines of code(in one namespace). Is this bad? Or does the number of lines of code not matter ...
27
votes
8answers
8k views

Private variable vs property?

When setting a value to a variable inside of a class most of the time we are presented with two options: private string myValue; public string MyValue { get { return myValue; } set { myValue = ...
19
votes
3answers
11k views

Which is a better practice - helper methods as instance or static?

This question is subjective but I was just curious how most programmers approach this. The sample below is in pseudo-C# but this should apply to Java, C++, and other OOP languages as well. Anyway, ...
15
votes
5answers
3k views

When and why you should use void (instead of i.e. bool/int)

I occasionally run into methods where a developer chose to return something which isn't critical to the function. I mean, when looking at the code, it apparently works just as nice as a void and after ...
3
votes
1answer
149 views

Should I forward the a call to .Equals onto .Equals<T>?

So, I've got you bog standard c# object, overriding Equalsand implementing IEquatable public override int GetHashCode() { return _name.GetHashCode(); } public override bool ...
19
votes
12answers
2k views

How to teach Exception Handling for New Programmers?

How do you go about teaching Exception Handling to Programmers. All other things are taught easily - Data Structures, ASP.NET, WinForms, WPF, WCF - you name it, everything can be taught easily. With ...
6
votes
11answers
917 views

C#/.Net/Programming talk [closed]

Lately we have decided in our company to have a monthly 30-60 minutes talk on a subject that relates to C#/.Net programming or anything else that will make us better in our work. We are currently ...