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. Cross cutting code

Cross cutting code

Scheduled Pinned Locked Moved C#
comtoolsquestion
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
    Nathan Gloyn
    wrote on last edited by
    #1

    I'm currently in the process of refactoring a web app to make it more testable and have posted here about it. I've managed to move forward a lot but now I'm in the situation where I perform the dependency injection on the constructor or via setting properties and the number of items needed is increasing e.g. Membership, state management, meta data provider etc. Although I could look at using static classes within the assembly I need to provide the implementation to be used from outside the assembly e.g. web app creates instance of class providing the relative dependancies and I am also concerned about the testability of static classes. Any suggestions about approaches I could take or patterns I could follow would be greatly appreciated.

    J 1 Reply Last reply
    0
    • N Nathan Gloyn

      I'm currently in the process of refactoring a web app to make it more testable and have posted here about it. I've managed to move forward a lot but now I'm in the situation where I perform the dependency injection on the constructor or via setting properties and the number of items needed is increasing e.g. Membership, state management, meta data provider etc. Although I could look at using static classes within the assembly I need to provide the implementation to be used from outside the assembly e.g. web app creates instance of class providing the relative dependancies and I am also concerned about the testability of static classes. Any suggestions about approaches I could take or patterns I could follow would be greatly appreciated.

      J Offline
      J Offline
      Jon Rista
      wrote on last edited by
      #2

      Some cross-cutting concerns can be aggregated into "context", which is usually globally accessible. Think of HttpContext...you can access it anywhere via HttpContext.Current. Think of context from a grammatical perspective...certain words or phrases only have meaning when they are taking "in context". Same general idea with programming. A piece of code really only works when you factor in the appropriate context(s). Not everything needs to be injected, some things should be globally accessible via one or more contexts. This might help lighten your DI load so that you are only injecting direct dependencies of each class, while keeping global dependencies properly centralized.

      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