Non-intrusive design
A client's code might contain framework functionality and the client's own functionality.
Intrusive design, is the designer to "push" the framework function to the client, rather than intrusive design, it is the designer of the client's function "take" into the framework.
Intrusive design sometimes manifests itself as the client needs to inherit the classes in the framework, whereas the non-intrusive design manifests itself as the interface provided by the client implementation framework.
The biggest flaw with intrusive design is that when you decide to refactor your code, you find that the code you've written before can only be thrown away. Instead of intrusive design, the previously written code is still valuable.
The design of the struts1 is intrusive:
- Public class Loginaction extends action{
- Public Actionforward Execute (actionmapping mapping,actionform form,httpservletrequest request,httpservletresponse Response) throws actionexception{
- LoginForm loginform = (loginform) Form;
- if ( "Scott". Equals (Loginform.getusername () && "Tiger". Equals (Loginform.getpassword)))
- { return Mapping.findforward ( "Success");}
- else {
- Return Mapping.findforward ( "failure");}
- }
- }
The design of webwork is non-invasive:
- Public class Loginaction implements action{
- Private final static String Loginfail = "Loginfail";
- Private final static String SUCCESS = "SUCCESS";
- Private String Passward;
- Private String username;
- Public String GetPassword () {
- return password;
- }
- Public void SetPassword (String password) {
- this. Password = password;
- }
- Public String GetUserName () {
- return username;
- }
- Public void Setusername (String username) {
- this. Username= username;
- }
- Public String Execute () throws exception{
- if ( "Yeeku". Equalsignorecase (GetUserName ()) && "password". Equals (GetPassword)) {
- Actioncontext ctx= Actioncontext.getcontext ();
- Map session = Ctx.getsession ();
- Session.put ("username", GetUserName ());
- return SUCCESS;
- }
- else return loginfail;
- }
- }
The difference between intrusive and non-invasive