question about decoupling mvc 
Author Message
 question about decoupling mvc

this question is about how to better decouple a 3 layer architecture based
on iterfaced implementations.
imagine these classes:

class Model {
    public String Name;
    private IImplementation implementation;
    public Model(IImplementation implementation){
        this.implementation = implementation;
    }
    public void Save() {
        implementation.Save(this);
    }

Quote:
}

public interface IImplementation {
    void Save(object obj);

Quote:
}

public class ImpFilesys : IImplementation {
    public void Save(object obj) {
        // implementation code goes here
    }

Quote:
}

public class ImpDataBase : IImplementation { ... }

public class Client {
    public Client() {
        Model m = new Model;
        m.Name = "Don Camillo";
        m.Implementation = new ImpFilesys(); // yuck!
        m.Save(m);
    }

Quote:
}

using this design i could sucessfully decouple the model from it's
implementation. but at the cost to couple implementation to the client,
which i also do not want. how can i achieve that the model only knows model
stuff, while the implementation knows only imp-stuff and same for the
client? how can i make them truly interchangeable without having to change
the code each time?

thanks
jan

(ps sorry for the repeat)



Mon, 28 Mar 2005 19:42:24 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. MVC question - 2 Models and 1 View?

2. decoupling

3. .NET and MVC

4. MVC 6.0 cannot handle template class with template copy constructor

5. MVC -- What is it??

6. Can I write a Mac OS compatable app in MVC++6.0

7. MVC model

8. MVC++6 "Detected memory leaks."

9. Will Doc/View be replaced with MVC?

10. Q: info on/examples of MVC

11. MVC implementation in Doc/View App

12. Interrupts & hardware programing under MVC

 

 
Powered by phpBB® Forum Software