Aspect-Oriented Software DesignRecall: What does OO Offer?Classic OO programWhen and How does OO fail?Survey Management ApplicationWhat Occurs at Larger Scale?An Example of Good ModularityAnother Example of Good ModularityAn Example of Poor Modularity …Another Example of Poor Modularity …What are Cross-Cutting Concerns?What is AOSD?Symptoms of Cross-Cutting ConcernsConsider Another ExampleSlide 15Slide 16Slide 17Slide 18Objective of AOSDCombining Cross Cutting ConcernsBenefits of AOSDOther Thoughts on AspectsAspect-Oriented Programming (AOP)Aspects in AOPObjective in Discussing AOPWeaving Process VariesAspectJ™AspectJ applied to a large middleware systemproblems like…the cost of tangled codecrosscutting concernsModularizing Crosscutting ConcernsAspect as a Modular UnitJoin Points and Point CutsAdvices and WeavingAspect-Oriented DefinitionsWeaving AlgorithmSecurity UML -1Aspect-Oriented Software DesignAspect-Oriented Software DesignMotivating the ProblemMotivating the ProblemWhat does OO Offer?When and How does OO Fail?Looking at the Problem Large ScaleLooking at the Problem Large ScaleAspect-Oriented Software Design (AOSD)Aspect-Oriented Software Design (AOSD)Aspect-Oriented Programming (AOP)Aspect-Oriented Programming (AOP)Security UML -2Recall: What does OO Offer?Recall: What does OO Offer?Classes are a Very Good Technique to Modularize the Classes are a Very Good Technique to Modularize the Components of the SystemComponents of the SystemAbstractionClasses and Objects Usually Represent Concepts from the Real World, Abstracting Unnecessary Details.EncapsulationClasses Encapsulate their Behavior into Manageable Units, by Hiding their Implementation to the ClientsClassificationHierarchies Provide a Good way to Organize and Classify ClassesSecurity UML -3Classic OO programClassic OO programSurvey Management exampleSurvey Management exampleConcerns are Separated into Different Classesclass Survey_List { public void Add_Survey_Header(Survey_Header sh) { } public List Survey_Title_Search(String title) { } public void Update_Survey_List() { } public void Delete_Survey_Header(Survey_Header sh) { }}class Survey_List { public void Add_Survey_Header(Survey_Header sh) { } public List Survey_Title_Search(String title) { } public void Update_Survey_List() { } public void Delete_Survey_Header(Survey_Header sh) { }}class Survey_Header { public void Create_Survey_Header() { } public void Add_Question(String q) { } public void Add_Special_Question(String sq) { }}class Survey_Header { public void Create_Survey_Header() { } public void Add_Question(String q) { } public void Add_Special_Question(String sq) { }}class Public_Survey_Results { public List Get_General_Statistics() { } public List Get_Questions() { }}class Public_Survey_Results { public List Get_General_Statistics() { } public List Get_Questions() { }}Security UML -4When and How does OO fail?When and How does OO fail?The Object-oriented Paradigm Provides the Class as The Object-oriented Paradigm Provides the Class as the Main unit to Decompose a Software Systemthe Main unit to Decompose a Software SystemA Good Designer/Programmer can Decompose Fairly A Good Designer/Programmer can Decompose Fairly well the Main Concerns of an Application into Classes well the Main Concerns of an Application into Classes and Hierarchiesand HierarchiesHowever, no Matter how Good is the Design there are However, no Matter how Good is the Design there are still Concerns that Cannot be well Modularizedstill Concerns that Cannot be well ModularizedSound Modeling for One Concern (GUI) may Lead to Poor Modeling for Another Concern (Database)This Leads to:Scattering – Code for Concern is DistributedTangling – Code for Multiple Concerns is Present in Each Abstraction (Class, Method, etc.)Security UML -5Survey Management ApplicationSurvey Management ApplicationA Visual ExampleA Visual ExampleAccess-control Code is Scattered Through Both ClassesEach Class has Tangled both Access-control Code and Domain-specific Code public void Survey_Title_Search(String title) { if (user.canSearch()){ slist.search(title); ...}public void Survey_Title_Search(String title) { if (user.canSearch()){ slist.search(title); ...}public void public void Add_Special_Question(String sq) { if (user.canAddSpecialQuestion()){ Question_List.add(sq); ...}public void public void Add_Special_Question(String sq) { if (user.canAddSpecialQuestion()){ Question_List.add(sq); ...}Security UML -6What Occurs at Larger Scale?What Occurs at Larger Scale?Consider Apache Tomcat as a Set of Abstractions that Consider Apache Tomcat as a Set of Abstractions that Represents its Broad Functionality for:Represents its Broad Functionality for: XML ParsingUML Pattern MatchingLogging of User ActivityMany Other CapabilitiesRepresented Pictorially as:Represented Pictorially as:Security UML -7An Example of Good ModularityAn Example of Good ModularityXML Parsing in org.apache.tomcatXML Parsing in org.apache.tomcatRed shows Relevant lines of codeNicely Located in one box – Well Defined© Copyright 1998-2002 Palo Alto Research Center Incorporated. All rights reserved. ApsectJ.org.Security UML -8Another Example of Good ModularityAnother Example of Good ModularityURL Pattern Matching in org.apache.tomcatURL Pattern Matching in org.apache.tomcatRed shows Relevant lines of codeNicely Located in two boxes – (using inheritance)© Copyright 1998-2002 Palo Alto Research Center Incorporated. All rights reserved. ApsectJ.org.Security UML -9An Example of Poor Modularity …An Example of Poor Modularity …… … is Logging in org.apache.tomcatis Logging in org.apache.tomcatRed Shows lines of code Handle Logging Not in just one placeNot even in a small number of placesJust a Mess…© Copyright 1998-2002 Palo Alto Research Center Incorporated. All rights reserved. ApsectJ.org.Security UML -10Another Example of Poor Modularity …Another Example of Poor Modularity …/* * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source
View Full Document