design

Eliminating coupling out of classes that have strong conceptual bonds with each other

I have the types Rock, Paper, and Scissors. These are components, or "hands" of the Rock, Paper, Scissors game. Given two players' hands the game must decide who wins. How do I solve the problem of storing this chain chart without coupling the various hands to each other? The goal is to allow adding a new hand to the game (Jon Ske...

Changing our BL design - which pattern(s) would be most useful?

Hi, I am in the process of refactoring our BI layers to make our code more "loosely coupled" and I was interested to hear what you guys thought might be interesting improvements to make? At present, our API is something like the following:- // Fetch a collection of objects ProductCollection prods = Product.GetProducts(); // Load an i...

Data structure for relationships

Hi All -- I am converting a VB6 to C# and I want to make my data structure that holds values and relationships more efficient. In VB I have a collection of values and another collection of relationships between those values with priorities for those relationships. I also have an algorithm that when a set of values is passed to it all re...

Why is Java's Cloneable Interface Not Generic?

Java 5 introduced generics, and they were added to many interfaces in the java.lang package. However, Cloneable did not get generics. I wonder why? Edit: In reply to the answers of @Jon and @litb, and the comment of @Earwicker, I was thinking Cloneable might be: public interface Cloneable<T> { public T clone(); } Here T clone()...

Parsing files to set data of an object - a design question

I recently had to write some code which parsed a file to set data in an object. As there were several objects and corresponding files involved here, I decided to separate the parsing code out. So I then had one class for parsing the files, CommandFileParser, and two classes per file/object type: one for the actual object itself and one ...

Why is dotnet's char.IsLower() a static method?

This seems to go against every design guideline. A static method that accepts a single argument of type T should usually just be a member method. It's so bizzare I actually had to post a StackOverflow question to understand IsUpper exists (as it didn't show up in auto-completion) Edit I understand my earlier statement needs a little e...

Namespace Design and Class Awareness

I remember reading once (I believe the book was the .NET Framework Design Guidelines) that when you are designing a framework or class library that you should take care in how you arrange the classes in your namespaces. Specifically, classes in parent namespaces should have no knowledge of classes in child namespaces. Conversely, it is p...

WPF design question involving treeview

I have a hierarchy that looks like this - Factory>machines>components>controls where ">" can be read as "contains a list of". This fits very nicely into a TreeView using HierarchicalDataTemplates. Now say I want to add checkboxes to the tree, so that the user can create "views" of the tree that require controlling. Currently my templat...

Are design patterns something you invent as you go

Are there set design patterns or does each individual sufficiently skilled software developer recognize and reduce their code to develop new patterns. Effectively creating their own "design" patterns. Edit - Thanks for the responses. In reality I'm just refactoring and/or reducing code where the problem should have first been compared...

Displaying polymorphic classes.

I have an existing app with a command-line interface that I'm adding a GUI to. One situation that often comes up is that I have a list of objects that inherit from one class, and need to be displayed in a list, but each subclass has a slightly different way of being displayed. Not wanting to have giant switch statements everywhere usin...

Best way to separate Business from Presentation Logic?

I want to create a game that will work both locally and online. My first thought was to create an interface that would have all the methods that will be needed by the GUI for the business logic and then have a network implementation and a local implementation. This works fine for request-response messages. But what about messages that ...

What should be considered when deciding between explicit vs implicit paging in a UI?

When a list becomes very large, presenting it in a UI raises a design issue. Should the user get pages of items or should the user get a list control that pages items implicitly as it is scrolled? In google search, paging of results is explicit. You get a set of results and hit a link to get the next set. On the iPhone the applicatio...

Trying to design an object model - using enums

I am trying to design an object model (for C#), and can't work out the best way to store the data. I'll try to use a simple example to illustrate this! I have an object "pet", which could be one of, "cat", "dog" etc. So I have created an "pet" class with a "petType" enum to store this. Now this is where it gets tricky. If an "pet" is a...

How many types should be implementing the Repository pattern?

I am trying to use the repository pattern in an instance of storing pictures. What I do is save the actual pics in a directory on disk but save data about the pics and what pics go with what object in a database. I was wondering if I should use 2 interfaces for the storage, like IStorePicRepo and IStorePicDataRepo or have 1 interface ...

Flexible design - customizable entity model, UI and workflow

Hi All, I want to achieve the following aspects in the software I am building: 1. Customizable entity model 2. Customizable UI 3. Customizable workflow I have thought about an approach to achieve this, I want you to review this and make suggestions: Entity objects should be plain objects and will hold just data Separate Entity model ...

Database design question

I accumulated a quite a lot of data in a raw form (csv and binary) - 4GB per day for a few months to be precise. I decided to join the civilized world and use database to access the data and I wondered what would be the correct layout; the format is quite simple: a few rows for every time tick (bid, ask, timestamp, etc.) x up to 0.5Mill...

Highly Customizable App in C# (Like Apache Ofbiz)

Hi, I have recently been exploring Apache Ofbiz and was impressed by its ability to customize most areas of the application: UI, workflow, entities. Is there any similar (not necessarily an ERP system) application developed in C#/.Net which offers a similar level of customization? I am looking for examples of applications developed i...

Graphical User Interface Specification Template

At my job we put some elements of the design for graphical user interface in both the functional specification and the technical design documents. However, this is often easy as nearly 100% of the time we are making modifications to existing software. What would one do if they wanted to produce a separate document for GUI specificati...

Instantiating objects with a Configuration class or with Parameters

I am running into a design disagreement with a co-worker and would like people's opinion on object constructor design. In brief, which object construction method would you prefer and why? public class myClass { Application m_App; public myClass(ApplicationObject app) { m_App = app; ...

How do you export from Expression Design to Silverlight XAML and retain vector relativity?

I am trying to export some prepared assets out of Expression Design 2 and into .XAML, with a final destination of Blend 2 for layout, but I cannot find a reliable way to keep the ability to resize those assets when they reach Blend. Taking a look at the exported final product, the XAML produced is wrapped in a Canvas (whether or not I se...