design problem with static classes
-
I have a design problem here. in the BIL there are some classes that represent business entities each of this class is static. and they all have mostly the same (static) members : - some info methods like give the pk for that entity - perform some actions on it: search for that specific business entity. - and so on I want to enforce that some methods are implemented on each static class. how can I do it ? note that interfaces don't work here since it is a static class maybe the design is wrong here, better alternatives ?
<< Nearly all men can stand adversity, but if you want to test a man's character, give him power. >>
-
I have a design problem here. in the BIL there are some classes that represent business entities each of this class is static. and they all have mostly the same (static) members : - some info methods like give the pk for that entity - perform some actions on it: search for that specific business entity. - and so on I want to enforce that some methods are implemented on each static class. how can I do it ? note that interfaces don't work here since it is a static class maybe the design is wrong here, better alternatives ?
<< Nearly all men can stand adversity, but if you want to test a man's character, give him power. >>
No, unfortunately, static classes must derive from Object and nothing else, and neither interfaces or abstract classes can be static anyway. It's hard to comment on your design without seeing the whole thing, but I would suggest that yes, to have static classes representing business entities is a bit of a strange design. Again, it's hard to suggest alternatives without seeing everything you are trying to do, but a pretty standard way is to have a bunch of business objects that define your business entities, these can then be created 1 for each entity and store all the values, and can possibly inherit from a base entity object.
Simon