Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. design problem with static classes

design problem with static classes

Scheduled Pinned Locked Moved C#
questiondesignbusinesshelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NikoTanghe
    wrote on last edited by
    #1

    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. >>

    S 1 Reply Last reply
    0
    • N NikoTanghe

      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. >>

      S Offline
      S Offline
      Simon P Stevens
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups