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. Design and Architecture
  4. Base Classes and Factory Pattern

Base Classes and Factory Pattern

Scheduled Pinned Locked Moved Design and Architecture
businessregexquestion
4 Posts 3 Posters 10 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.
  • B Offline
    B Offline
    Brady Kelly
    wrote on last edited by
    #1

    I use an IMessageTransport to send various B2B messages and receive replies. It has various methods related to various business functions, so e.g. I will pass a DocumentMessage to the SubmitDocument method, or a StatusRequest to the GetDocStatus method. A requirement has arisen to include, lets call it, a SenderID, with each message sent. Now, before I do any refactoring, I need a Guid SenderID param for each IMessageTransport method. Now, to remove this duplication I could delegate the insertion of the SenderID to the implementors of IMessageTransport, but I may want to allow these to also send messages from other senders. I seem to have two choices: all IMessageTransport methods must be passed an object that derives from MessageBase, which exposes a SenderID property, and populates this from config, or an IMessage interface, with the same property that is populated by a sender dedicated factory class. Which would be the better direction to look in?

    P L 2 Replies Last reply
    0
    • B Brady Kelly

      I use an IMessageTransport to send various B2B messages and receive replies. It has various methods related to various business functions, so e.g. I will pass a DocumentMessage to the SubmitDocument method, or a StatusRequest to the GetDocStatus method. A requirement has arisen to include, lets call it, a SenderID, with each message sent. Now, before I do any refactoring, I need a Guid SenderID param for each IMessageTransport method. Now, to remove this duplication I could delegate the insertion of the SenderID to the implementors of IMessageTransport, but I may want to allow these to also send messages from other senders. I seem to have two choices: all IMessageTransport methods must be passed an object that derives from MessageBase, which exposes a SenderID property, and populates this from config, or an IMessage interface, with the same property that is populated by a sender dedicated factory class. Which would be the better direction to look in?

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      I would definitely go with the Factory pattern. It gives you more flexibility later on, especially if things change further down the line.

      Deja View - the feeling that you've seen this post before.

      1 Reply Last reply
      0
      • B Brady Kelly

        I use an IMessageTransport to send various B2B messages and receive replies. It has various methods related to various business functions, so e.g. I will pass a DocumentMessage to the SubmitDocument method, or a StatusRequest to the GetDocStatus method. A requirement has arisen to include, lets call it, a SenderID, with each message sent. Now, before I do any refactoring, I need a Guid SenderID param for each IMessageTransport method. Now, to remove this duplication I could delegate the insertion of the SenderID to the implementors of IMessageTransport, but I may want to allow these to also send messages from other senders. I seem to have two choices: all IMessageTransport methods must be passed an object that derives from MessageBase, which exposes a SenderID property, and populates this from config, or an IMessage interface, with the same property that is populated by a sender dedicated factory class. Which would be the better direction to look in?

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        Brady Kelly wrote:

        I need a Guid SenderID param for each IMessageTransport method.

        You need a GUID for each method? :confused:

        led mike

        B 1 Reply Last reply
        0
        • L led mike

          Brady Kelly wrote:

          I need a Guid SenderID param for each IMessageTransport method.

          You need a GUID for each method? :confused:

          led mike

          B Offline
          B Offline
          Brady Kelly
          wrote on last edited by
          #4

          Yes, but the same one. Until a point, I have separated the sender ID from the business information, as at the interface to our other system there is always only one sender, but I prefer not to fix a single sender ID in my transport. Therefore between the transport layer getting a message to send, and sending it, it must determine a sender ID. At the moment it's passed with the message as a parameter.

          My Blog

          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