Tagged Questions
5
votes
1answer
83 views
Recommended Naming for function that tests and mutates
I am a huge proponent of self-documenting code (when at all possible). I prefer to have code be self evident by the very nature of the names of the variables, methods, etc.. For instance:
if ...
-1
votes
0answers
33 views
Checklist for coding MVVM web application [closed]
We are a small team working on a web application using MVVM design pattern using technologies like .NET, Knockout and HTML. I am trying to come up with a code review process and as a first step trying ...
1
vote
1answer
115 views
Code review for an abstract repository implementation
I have a repository abstract class that encapsulates pretty much all of the CRUD functionality:
public abstract class DataRepository<T> : IRepository<T>
where T : class
{
public ...
4
votes
1answer
152 views
How do I make this code unit-testable?
I have a functionality that imports data into a database, based on an Excel workbook and some meta data (both user-supplied). The functionality implements interface IFunctionality which essentially ...
2
votes
1answer
86 views
A complex string splitter- How do I make this working code better?
I have the below program
class Program
{
static void Main(string[] args)
{
List<Assembly> failedAssemblies = LoadAssembly();
string batchFile = ...
1
vote
2answers
135 views
How can I refactor this code in order to not repeat code?
I have this code:
private eFileStatus CheckConfigSettings()
{
mFileStatus = mXMLHelper.CheckElement(eElementName.StartLanguage.ToString(), out mContent);
if (eFileStatus.OK != ...
1
vote
0answers
42 views
Hardware resource Open/Close methods
So I'm making a program that is a serial port wedge. In other words I want it to listen to a serial port. If data comes in, wait a given amount of time, then play a sound and finally send the data ...
0
votes
2answers
138 views
Constructor with too many arguments [closed]
We have a Transaction class that's very loaded; so loaded that I originally ended up passing almost 20 argument to the ctor. After extracting a few value objects, there are still 12 arguments left, ...
0
votes
1answer
118 views
Illustrating DI and IoC concepts
This question is a follow-up to the questions here: Illustrating DI and IoC concepts : Simple code requesting review
I have taken the very good review comments got and tweaked the code. These are the ...
2
votes
2answers
155 views
Illustrating DI and IoC concepts : Simple code requesting review
I have written a little bit of code which illustrates DI(dependency injection) and IoC(Inversion of control) container. The point of this exercise is to illustrate the two methods by which you can ...
4
votes
2answers
385 views
Trying to clearly seperate my logic in my program
My problem is I need to know
is my code in my CRUD functions structured well and effectively? I plan to implement CRUD for Locations entity too. hopefully without redundant code.
you see how one ...
-1
votes
1answer
131 views
advices to clean up C# Code [closed]
I have this code but I think it is so messy and can me cleaned up a bit... But I can't because I don't know so much about C#...
The problem is that I have an if(servicio.Value == "PAS") because the ...
1
vote
1answer
226 views
Am I using too many functions in my DataAccess Class?
I am wondering if in particular the function called AssignDBStatusMessage and TryDataBaseAction are unnecessary. It seems to me that the logic is more cluttered if i do away with those functions. ...
4
votes
2answers
224 views
Progressive tax program in C#
Please review this code. It should calculate the tax precentage a person will pay in a progressive tax system. The goal is a perfect program.
Comments please.
using System;
using ...
4
votes
2answers
144 views
How do I simplify the code in C#?
Here is a code I want to simplify:
public void Method1(Context context, EventLog log = null)
{
Class myClass = ConvertToMyClass();
ApiCall1 apiCall = new ApiCall1(context);
if (log != ...
5
votes
1answer
239 views
How to simplify this c# code?
i have below function in my application i need to simplify it to improve the code quality all the suggestions are warmly welcome
void FilterValues()
{
...
3
votes
5answers
307 views
How to avoid passing variable to a method again and again
Following is a chunk of code from my class which generate PDF document. I am refactoring my code and in the process I have created short methods. But I have to pass 'table i.e PdfPTable' to my methods ...
3
votes
3answers
227 views
Write it better/neat/fast (if condition)
How to write following if condition clean/fast/readable.
Any one of the fields 'address', 'city', 'district', 'province' can be null. I want to make full address by concat all these fields. Like
...
7
votes
2answers
339 views
ViewModel constructor with many parameters
I have some ViewModels that have a lot of parameters like this one:
public class ProductsMainViewModel : NotificationObject, IActiveAware, ...
{
public ProductsMainViewModel(IProductRepository ...
4
votes
2answers
150 views
Rewriting the code without use of GOTO
This is a code automatically converted from VB 6.0 to C#.net
What is a safe and correct way to get rid of that GOTO statement:
public bool IsDirty(bool checkChildrenInd)
{
bool result = false;
...
1
vote
1answer
180 views
How can I improve upon my SharePoint Class?
To help learn the SharPoint Object Model (Primarily for SharePoint 2007) I've been working on a class library with a number of useful functions. I'm a junior developer and this is my first C# project ...
5
votes
2answers
137 views
Ideas for reducing repetition in control binding
I have seven checkboxes on a data maintenance WinForm, which indicate the days of the week that are "valid" for a particular operation to be performed. These "map" to a list of DayOfWeek enum values ...
2
votes
2answers
107 views
My DoWork event code is not built good. So many times im calling the downloadContent() can someone hlep?
I wrote this downloadContent() function.
Is there some other way to download the content faster?
private string downloadContent()
{
try
{
WebRequest request = ...
3
votes
2answers
133 views
Restucture code to wrap optional resources in a using block
I have some C# I/O code that can take one or two input files. I would like to wrap the Stream objects in a using block, but cannot find a way to succinctly express this in code.
Currently, I have ...
0
votes
2answers
61 views
Extract common code to enable/disable, show/hide controls on some condition
I have few controls on my page which I want to show/hide and/or enable/disable on some condition.
Images to help illustrate the requirements:
Following is the code to show/hide, enable/disable ...
5
votes
3answers
247 views
Multi-tiered sorting using custom IComparer
I have this custom IComparer I use to sort a list of SurveyResponse objects, but it seems really inefficient, both in terms of runtime performance, and code elegance and maintainability. I thought of ...
4
votes
4answers
388 views
Spaghetti return statement
I've just came upon this fine return statement :)
I am curious how would you rewrite this, I will post my edited version later.
public bool Changed(bool Cascading)
{
return ...
3
votes
7answers
265 views
Check assistant's password
I have two more methods the same as this except that they query a different table. Is there another way to know if the result of the query is null? Because the hasher.CompareStringToHash() method is ...
3
votes
4answers
384 views
Extremely long if-or-or statement just feel wrong
I'm sure this is wrong, but I can't think of a cleaner way to do this. I'm looping through a set of column to identify which column identifies the company name, the test is true if one of a large ...
3
votes
2answers
149 views
Could generics condense these two methods into one?
Two methods which do very similiar things, is it possible to condense these somehow? This is using the Entity Framework.
public void ExportSiteData (FLEX_INV_EXP_SITE siteData)
...