0
votes
0answers
26 views

Creating New Wrapper Objects and Extension Classes and Keeping it Organized

Here's my situation: I'm programming an embedded device with a very simple, but customizable LED array display. It's 10 RGB LEDs linearly setup. The LEDs will be used to display many different ...
0
votes
3answers
193 views

How to design an IDisposable that unconditionally needs to be disposed?

Consider a class that implements IDisposable, and that has members in such a way that it will never become eligible for garbage collection when it is not disposed. And as it will not be garbage ...
0
votes
2answers
109 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: ...
0
votes
2answers
153 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' ...
2
votes
2answers
240 views

Should I expose a “computed” value as a property or a method?

I have a C# class that represents a content type in a web content management system. We have a field that allows a web content editor to enter an HTML template for how the object is displayed. It ...
0
votes
2answers
149 views

Thoughts and Best Practices on Static Classes and Members [closed]

I am very curious as to thoughts and industry best practices regarding static members, or entire static classes. Are there any downsides to this, or does it participate in any anti-patterns? I see ...
0
votes
2answers
141 views

Data structures VS Classes and what happens if they merge? [closed]

Alright so I've learned this: Classes have public methods that perform operations on the class's data and they hide away their implementations. Data structures on the other hand, completely expose ...
0
votes
1answer
97 views

How can I layout this class to make it easier to use for API developers?

I have an application that allows the user to place a string of text into a PDF document. I have three different ways that they can do this: Use a Form Field. Then they have four properties to ...
1
vote
1answer
337 views

A class with only methods

What's the name for a class that has only methods? There are no fields/properties. Just two methods with the ability to parse some file in two ways. I have named the class Parser, but it just doesn't ...
2
votes
1answer
240 views

C# dynamically linking different libraries and/or external classes

tl;dr Is it possible to include an external library (and create instances of objects represented within that library) based on some condition? This must be done at compile-time, so separate builds? ...
1
vote
3answers
413 views

C# vector class - Interpolation design decision

Currently I'm working on a vector class in C# and now I'm coming to the point, where I've to figure out, how i want to implement the functions for interpolation between two vectors. At first I came up ...
0
votes
2answers
645 views

How to handle lookup data in a C# ASP.Net MVC4 application?

I am writing an MVC4 application to track documents we have on file for our clients. I'm using code first, and have created models for my objects (Company, Document, etc...). I am now faced with the ...
0
votes
3answers
1k views

What is good practice when inheriting static classes isn't possible/allowed

I am developing a project in C# and due to a design decision it is not possible to have a static class inherit another static class. But I have, in my opinion, a case where this would make sense. I ...
0
votes
1answer
112 views

Refactoring classes with ref to themselves

How can I refactor this code? class Node { public Node Parent { get; set; } } class AVLNode { public AVLNode Parent { get; set; } } I tried to use inheritance, but then I have to use type ...
2
votes
2answers
302 views

Same constructor signature with different semantics?

Occasionally, I'm confronted with the problem that I have to provide some constructors in order to initialize objects with different sets of data. These sets can be mathematically transformed into ...
5
votes
4answers
3k 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 ...
0
votes
1answer
330 views

How can my code structure be improved? [closed]

I am looking for advice on the neatest way to structure my code. class Password { private string cipher; Password(string cipher) { this.cipher = cipher; } public string ...
0
votes
1answer
709 views

A sample Memento pattern: Is it correct?

Following this query on memento pattern, I have tried to put my understanding to test. Memento pattern stands for three things: Saving state of the "memento" object for its successful ...
2
votes
6answers
1k views

Class Design — Multiple Calls from One Method or One Call from Multiple Methods?

I've been working on some code recently that interfaces with a CMS we use and it's presented me with a question on class design that I think is applicable in a number of situations. Essentially, what ...
8
votes
3answers
1k views

Base classes as factories?

I was writing some code over the weekend and I found myself wanting to write a factory as a static method in a base class. My question is simply to know if this is a c# idomatic approach? My sense ...
1
vote
1answer
2k views

Encapsulating a class within another class to hide its exposed properties and details

I have essentially a data model class that represents an XML data structure that we use to model our system. The model class is in a shared project that is used by a number of different solutions in ...
6
votes
6answers
643 views

Organizing Class Members in Regards to Access Modifier

If we look at typical implementation of a Class, we usually see the private members defined at the beginning and public( mostly functions and Accessors) defined towards the bottom. Now, is this a ...
5
votes
7answers
2k views

Where should I put my utility methods?

I am very new to Visual Studio and C# and am wondering how best to create a repository of sorts for utility methods. For instance, we need a method that returns the current fiscal year and other ...
0
votes
2answers
135 views

Is hooking Data access method on wrong object detrimental for a developer

In a simple application I am creating there are Admin and users where admin can create users. Right now I am creating Classes that encapsulate database CRUD calls with methods. For example: ...
11
votes
3answers
3k views

Abstract Base Class with Interfaces as Behaviors?

I need to design a class hierarchy for my C# project. Basically, class' functionalities are similar to WinForms classes so let's take WinForms toolkit as an example. (However, I can't use WinForms or ...
6
votes
4answers
3k views

Use Dependency Injection For Data Objects?

I'm just learning about dependency injection, and am stuck on something. Dependency Injection recommends sending dependent classes through the constructor, but I'm wondering if this is necessary for ...
12
votes
4answers
2k views

Is It “Wrong”/Bad Design To Put A Thread/Background Worker In A Class?

I have a class that will read from Excel (C# and .Net 4) and in that class I have a background worker that will load the data from Excel while the UI can remain responsive. My question is as follows: ...