c# - How to abstract a static classes -


i have static class. can modify , make extends interface\abstract class.

it contains

  • lots of readonly , consts members.
  • staic methods.

in order make code testable, want to

  1. separate dto , manager.
  2. abstract each of them. how classes static?

in opinion there 2 things static classes for:

  1. providing global functions/algorithms (that should not depend on state - a.k.a pure functions)
  2. hold global data

if model methods in there pure can test right away. global data (your constants , read-only members) on other hand don't need testet should produced said methods.

so if static methods use global data class refactor them include data parameters method, overload simple wrappers feeding global data , test new - pure - functions. take care include things database-data or system-times (datetime.now) , similar side-effect data methods well.

if parameterlist gets big refactor method class some/most of parameters encapsulated new classes fields - remember s solid (single responsibility) - clutter "mystaticglobals"-class/singelton if test parts in seperation.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -