danfromisrael (4) [Avatar] Offline
(I posted my original question in stackoverflow, trying it here as well)

In my logic classes i have ajax calls to web services, i store stuff in cookies, get info from the uri query string and display messages to the user.

What would be a best practice to decouple my logic class from those dependencies?

My environment: I'm developing with SharpKit ( C# to javascript compiler ) so i'm writing in c# and eventually my code compiles into pure javascript and runs only on the browser (no server side code).

At the begining i was thinking of wrapping them as a 2 repositories: 1 for ajax calls and the others for browser all interaction(cookies, urls, messages, etc..)

right now it looks something like that (without DI):

public class CustomersScreenController

public CustomersScreenController(Services services, CookieHelper cookieHelper, UriHelper uriHelper)
{ ... }


Does it make sense i'd put all browser's stuff in one repo? On the other hand, Cookies and Query Strings seems to me like another data source...

What do you think ?

Stackoverflow question:

danfromisrael (4) [Avatar] Offline
Re: Whats the best way to decouple my logic class from dependencies in web ?
another question:

How would you layer this kinda app ?

ajax calls seems to be the Data Layer
controllers are the Logic Layer
and BrowserStuff (cookies, url, messages) the UI Layer?

Currently it works with MVC like this:
Controller makes the ajax calls and fills the Model with data,
Model is one way databinded to the View that has all the display objects(text boxes, grids, etc..)
View takes care of view logic like rendering, hovering, clicks etc.. and fires events into the controller.

eventually i'd love to test the controllers so i want to start using DI
mark.seemann (383) [Avatar] Offline
Re: Whats the best way to decouple my logic class from dependencies in web ?

Thank you for writing. I left some comments on your SO post.


Mark Seemann