Tuesday 15 April 2014

c# - Best method for centralised common code across MVC web application? -



c# - Best method for centralised common code across MVC web application? -

i rewriting classic asp web app using asp.net mvc 5.

there lots of mutual code held in include files need replicate in new application.

i have done lots of research , believe static methods way go.

i plan utilize static methods utilities utilize local info or input parameters (other objects)

i plan utilize instance methods utilities need instantiate other objects etc.

my question is:

with iis set inproc, static methods self-contained or inadvertently cross referenced other users?

this app installed on single server, there no web farms or collections of servers etc.

i’ve seen extension methods mentioned microsoft suggest using these sparingly. ultimately, there improve way replace mutual code in include files other static methods?

thanks reading.

putting aside architecture debate (in classic asp kludge of info access in utility procedures mutual place - don't think you'd want replicate mvc, much improve design nice layers , abstract info handling away model).

to reply main question, yes static methods self contained long don't access global variables. ie

public static string somestring = "xyz"; public static void dosomething() { somestring = "something else"; }

would suck, , blow apart in multi user environment.

and reply final question, see first paragraph. best way develop model (data access all) domain model, info access layer astraction within that. @ to the lowest degree refactor info access methods form of dataaccess layer, encapsulate behind set of interfaces - , if don't have time/resources rewrite info access in improve way now, @ to the lowest degree have drawn line in sand programme against. way you'll stop old kludge making it's way lovely new code.

c# asp.net asp.net-mvc

No comments:

Post a Comment