The difference between intrusive and non-invasive

Source: Internet
Author: User

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:

  1. Public class Loginaction extends action{
  2. Public Actionforward Execute (actionmapping mapping,actionform form,httpservletrequest request,httpservletresponse Response) throws actionexception{
  3. LoginForm loginform = (loginform) Form;
  4. if ( "Scott". Equals (Loginform.getusername () && "Tiger". Equals (Loginform.getpassword)))
  5. { return Mapping.findforward ( "Success");}
  6. else {
  7. Return Mapping.findforward ( "failure");}
  8. }
  9. }


The design of webwork is non-invasive:

    1. Public class Loginaction implements action{
    2. Private final static String Loginfail = "Loginfail";
    3. Private final static String SUCCESS = "SUCCESS";
    4. Private String Passward;
    5. Private String username;
    6. Public String GetPassword () {
    7. return password;
    8. }
    9. Public void SetPassword (String password) {
    10. this. Password = password;
    11. }
    12. Public String GetUserName () {
    13. return username;
    14. }
    15. Public void Setusername (String username) {
    16. this. Username= username;
    17. }
    18. Public String Execute () throws exception{
    19. if ( "Yeeku". Equalsignorecase (GetUserName ()) && "password". Equals (GetPassword)) {
    20. Actioncontext ctx= Actioncontext.getcontext ();
    21. Map session = Ctx.getsession ();
    22. Session.put ("username", GetUserName ());
    23. return SUCCESS;
    24. }
    25. else return loginfail;
    26. }
    27. }

The difference between intrusive and non-invasive

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.