473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Up and Down Casting clases and interfaces

I am contemplating a rather complex inplementation that calls for a factory
class that can instantiate a large number of specific business objects, each
of which share a set of common base business rules (e.g., Update, Delete,
etc.) as well as a set of object specific methods. Of couse, all of the
interfaces shall be defined in a common assembly for the client and server
components. Since all of these are remoted, presume that the interfaces are:

IBusinessFactory

IDataManager
ICustomerManager : IDataManager
ISalesOrderManager : IDataManager

Do I need to declare a specific factory method for each individual business
object, or (presuming all objects have exactly one primary key identifier)
could I use a single method to retrieve a specific business object and then
cast it appropriately?

Method 1:

ICustomerManager remoteCustomer =
IBusinessFactory.GetCustomer(customerID);
ISalesOrderManager remoteSalesOrder =
IBusinessFactory.GetSalesOrder(salesOrderID);

Method 2:

ICustomerManager remoteCustomer =
(ICustomerManager)IBusinessFactory.GetBusinessObje ct("Customer",
customerID);
ISalesOrderManager remoteSalesOrder =
(ISalesOrderManager)IBusinessFactory.GetBusinessOb ject("SalesOrder",
salesOrderID);

While I have to define the individual interfaces, this eliminates a large
amount of custom coding in the factory, and the server version of the
factory could event derive the database table name that acts as backing
store for the data object from the first parameter (which would not have to
be a string parameter -- it could be an enum or a typeof() value).

Are there any pitfalls or problems with this? I have not actually tried
coding this yet as some other things are pressing, and I realized that even
if the code permitted it there may be a more effective approach in C#/,Net.

-ken
Nov 16 '05 #1
0 1131

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: yufufi | last post by:
lets say we have a 'shape' class which doesn't implement IComparable interface.. compiler doesn't give you error for the lines below.. shape b= new shape(); IComparable h; h=(IComparable)b;...
18
by: Marco | last post by:
I need to get a iterator from any generic collection. public class .... GetIterator(Object collection) { ..... }
61
by: Ken Allen | last post by:
I am relatively new to .Net, but have been using VB and C/C++ for years. One of the drawbacks with VB6 and earlier was the difficulty in casting a 'record' to a different 'shape' so one could...
9
by: Kris | last post by:
Hi. I have a asp class A with a public function AA() ----------------A.aspx.cs------------------------ public partial class A : System.Web.UI.Page { protected void Page_Load(object sender,...
1
by: pitdog | last post by:
This may not be the group to post this in. However I will try... I am interested in how the .NET runtime actually handles casting. For instance... This will work if you assume ChildProduct is...
3
by: Bob S | last post by:
A class in assembly A implements a COM interface as follows : internal interface IMyInterface { int MyMethod(); } class MyClass : IMyInterface
5
by: mijobee | last post by:
Hello Everyone, I just wanted to check that I'm using dynamic_cast correctly. I have a hierarchy of objects using pure virtual classes and virtual inheritance to implement interfaces. I ran...
7
by: Ajeet | last post by:
hi I am having some difficulty in casting using generics. These are the classes. public interface IProvider<PROF> where PROF : IProviderProfile { //Some properties/methods }
5
by: Ronald Raygun | last post by:
If I have the following class heirarchy: class A{ protected $m_type; function type(){return $this->m_type;} } class B extends A{} class C extends B{}
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.