Sign in to follow this  
PDHB

[.net] Auto generating simple classes

Recommended Posts

Suppose I have an object representing a molecule. I want to use this object for scientific modeling, but in a variety of different ways. In one circumstance I might need a set of properties related to how this molecule will react with light. In another, with a neutron beam. In yet another, both. The possible combinations are numerous. Now suppose I don't want this object to implement all possible interfaces. I want it to implement just those interfaces it needs for a given situation. This is in part because I don't want the extra overhead of using objects that are larger than necessary, and in part because I want to make things simpler for the user. (The user interface uses reflection to allow the user to set or change certain property values, and I don't want him flooded with unnecessary properties to sort through for just those he needs to worry about.) The Facet design pattern doesn't seem appropriate. Which interfaces are exposed is controlled and limited by this pattern, but there's still the issue of dealing with objects much larger than necessary. The visitor pattern doesn't seem right either, because of the extra overhead of invoking the visitor, and it doesn't seem to really solve the problem of many possible combinations of interfaces being used. So this is my idea. Given a set of interfaces, the user or client software can specify just those interfaces needed, and the class will be created dynamically, implementing those interfaces. The core of the class will be the molecule object (a flyweight), which can also be used as a key in a database to get amy availible data on those properties implimented. My questions are: 1. Am I reinventing the wheel here? is there some design pattern or library that already does things like this? 2. Is there a better way of doing this? Thanks. Matt Brown (p.s. please don't move this to general programming. I will be implementing this in C# or managed C++, and am particularly looking for solutions involving the .NET framework.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this