Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Modularizing RESTful Web Service Management with Aspect Oriented Programming

Modularizing RESTful Web Service Management with Aspect Oriented Programming

Related Books

Free with a 30 day trial from Scribd

See all
  • Be the first to comment

Modularizing RESTful Web Service Management with Aspect Oriented Programming

  1. 1. MODULARIZING RESTFUL WEB SERVICE MANAGEMENT WITH ASPECT ORIENTED PROGRAMMING
  2. 2. Authors Widhian Bramantya Dana S. Kusumo Bayu Munajat School of Computing Informatics Engineering Telkom University widhian.bramantya@gmail.com School of Computing Informatics Engineering Telkom University danakusumo@telkomuniversity.ac.id School of Computing Informatics Engineering Telkom University bayu1887@gmail.com
  3. 3. 1 2 3 4 Introduction Outline Proposed Construction RESTful Web Service How RESTful Web Service Works Crosscutting Concern in RESTful Web Service Aspect Oriented Programming Reusability Metric Crosscutting Concern Identification UML, ERD, API Design Conversion RESTful Web Service Development Result and Analysis Conclusion
  4. 4. INTRODUCTION
  5. 5. Introduction RESTful Web Service Show all admin GET /admin Insert new admin POST /admin Show detail admin 1 GET /admin/1 Update admin 1 PUT /admin/1 Delete admin 1 DELETE /admin/1 <resource href="/admin"> <link href="{related link}" rel="{related rel}"> <resource href="/admin/1" rel="admin"> <id_admin>1</admin> <name>bob</name> </resource> <resource href="/admin/2" rel="admin"> <id_admin>2</admin> <name>alice</name> </resource> </resource> API DB request response
  6. 6. Introduction How RESTful Web Service Works Browser / Other .htaccess REST API Get Request Process API Method I () Database Method I () Method I () request response
  7. 7. function processApi(){ $auth = $cache = $log = NULL; $func = str_replace("/","" , $_REQUEST['request']); $parameter = str_replace("/","", $_REQUEST['attribute']); $cache = new Cache(); $log = new Log(); $auth = new Auth(); $auth->auth_start($parameter); $log->log_start($parameter); $cache->cache_start($parameter); $result = $this->$func($parameter); $cache->cache_end($result); $log->log_end($result); } Introduction Crosscutting Concern in RESTful Web Service Call Main Method Cache Concern Log Concern Authentication Concern class
  8. 8. Introduction Aspect Oriented Programming Authentication First Logging First Caching Call Main Method Last Caching Last Logging API Class API Class API Class Aspect Authentication Aspect Logging Aspect Caching class Authentication First Logging First Caching Call Main Method Last Caching Last Logging class Authentication First Logging First Caching Call Main Method Last Caching Last Logging class advice advice advice
  9. 9. Introduction Reusability Metrics Reusability Understandability Flexibility Separation of Concerns Size Coupling Cohesion CDO, CDC, CDLOC VS, LOC, NOA, WOC CBC, DIT LCOO Qualities Factors Internal Attributes Metrices
  10. 10. Introduction Reusability Metrics No Metrics Definition 1 Concern Diffusion over Components (CDC) Counts the number of primary components whose main purpose is to contribute to the implementation of a concern 2 Concern Diffusion over Operations (CDO) Counts the number of primary operations whose main purpose is to contribute to the implementation of a concern 3 Concern Diffusion over LOC (CDLOC) Counts the number of transition points for each concern through the lines of codes (concern switch) 7 Vocabulary Size (VS) Counts the number of system component, i.e. classes or aspects. 8 Lines of Code (LOC) Counts the number of lines of codes.
  11. 11. Introduction Reusability Metrics No Metrics Definition 9 Number of Attributes (NOA) Counts the internal vocabulary of each component, i.e. the number of attributes of each class or aspect 10 Weighted Operations per Component (WOC) Measures the complexity of component in terms of its operations. 4 Coupling Between Components (CBC) A component (class or aspect) as a tally number of other components to which it is coupled. 5 Depth of Inheritance Tree (DIT) Counts the maximum length of a node to a root of the tree 6 Lack of Cohesion in Operations (LCOO) Counts the lack of cohesion of a component. (inherited class or aspect).
  12. 12. PROPOSED CONSTRUCTION
  13. 13. Proposed Construction 1 2 3 Crosscutting Concern Identification UML, ERD, and API Design Conversion RESTful Web Service Development
  14. 14. Proposed Construction Crosscutting Concern Identification Identify & Describe Non- Functional Concerns Specify Functional Requirements Identify & Specify Crosscutting Concern Compose Crosscutting Concerns into the UML Models Crosscutting Concern <Name> Description <Executive description> Priority <Priority can be Max, Med, and Min> List of requirements <Requirements that describe the concern> List of models <UML models influenced by the concern>
  15. 15. Proposed Construction UML, ERD, and API Design Conversion UML ERD API Design {root}/ {resource 1}/ {…}/ {resource n}/ {id resource 1}/ {sub resource 1}/ {…}/ {sub resource n}/ {id sub resource 1}/
  16. 16. Proposed Construction RESTful Web Service Development OOPGet Request Authentication First Logging First Caching Process API Last Caching Last Logging Method I Method II Method III Class Crosscutting Concern
  17. 17. Proposed Construction RESTful Web Service Development OOP + AOP Get Request Process API Method I Method II Method III Class Aspect Authentication Aspect Logging Aspect Caching
  18. 18. Proposed Construction RESTful Web Service Development <?php class User { function processApi(){ ... } } $api = new User(); $api->processApi(); ?>
  19. 19. Proposed Construction RESTful Web Service Development <?php class User { function processApi() { $func = str_replace("/","",$_REQUEST['request']); $parameter = str_replace("/","", $_REQUEST['attribute']); $log = new Log($this); $log->$func($parameter); } } ?> <?php class Log extend AOP { function __construct($object){ AOP::__construct($object); } } ?> <?php class AOP { $_inner = NULL; function __construct($object){ $this->_inner = $object; } } ?>
  20. 20. Proposed Construction RESTful Web Service Development <?php class Log extend AOP { function __construct($object){ ... $this->inject_before_call(".*", "before_advice"); $this->inject_after_call(".*", "after_advice"); } function before_advice(){. . .} function after_advice(){. . .} } ?> <?php class AOP { $_before = array(); $_after = array(); function inject_before_call(){ $this->_before[] = array("/".$pattern."/", $method_name); } function inject_after_call() {..} } ?>
  21. 21. Proposed Construction RESTful Web Service Development <?php class Log extend AOP { function __construct() { ... $this->inject_before_call(".*", "before_advice"); $this->inject_after_call(".*", "after_advice"); } function before_advice(...) {...} function after_advice(...) {...} } ?> <?php class AOP { $_before = array(); $_after = array(); function inject_before_call() {...} function inject_after_call() { $this->_after[] = array("/".$pattern."/", $method_name); } } ?>
  22. 22. Proposed Construction RESTful Web Service Development <?php class User { function processApi() { $func = str_replace("/","", $_REQUEST['request']); $parameter = str_replace("/","", $_REQUEST['attribute']); $log = new Log(); $log->$func($parameter); } } ?> <?php class Log extend AOP { ??? } ?> <?php class AOP { ??? } ?>
  23. 23. Proposed Construction RESTful Web Service Development <?php class User { function processApi() { $func = str_replace("/","", $_REQUEST['request']); $parameter = str_replace("/","", $_REQUEST['attribute']); $log = new Log(); $log->$func($parameter); } } ?> <?php class AOP { function __call($method_name,$params) { ... } } ?>
  24. 24. Proposed Construction RESTful Web Service Development <?php class User { function __call($method_name,$params) { foreach($this->_before as $lookup) { list($pattern,$before_method_name) = $lookup; if(preg_match($pattern,$method_name)) { call_user_func_array(array( $this,$before_method_name),array( $method_name,$params)); } } ... // function to call $api->$func() ... // function to call after_advice() } } ?> <?php class Log extend AOP{ function before_advice($method_name,$params) { // some code to save log start } } ?>
  25. 25. Proposed Construction RESTful Web Service Development <?php class User { function __call($method_name,$params) { ... // function to call before_advice() $result = call_user_func_array(array($this->_inner, $method_name),array($params); ... // function to call after_advice() } } ?> <?php class User{ function methodName($params) { // main API code } } ?>
  26. 26. Proposed Construction RESTful Web Service Development <?php class User { function __call($method_name,$params) { ... // function to call before_advice() ... // function to call $api->$func() foreach($this->_before as $lookup) { list($pattern,$before_method_name) = $lookup; if(preg_match($pattern,$method_name)) { call_user_func_array(array($this, $before_method_name),array($method_name, $params,$result)); } } } } ?> <?php class Log extend AOP { function after_advice($method_name,$params,$result) { // some code to save log start } } ?>
  27. 27. RESULT & ANALYSIS
  28. 28. Result and Analysis PHP E-commerce Authentication Caching Logging Language Case Study Aspects 82 APIs APIs
  29. 29. Result and Analysis Separation of Concerns (SoC) The Best: OOP 45 47 0 50 Concern Diffusion over Components (CDC) CONCERNS METRIC Concern Diffusion over Component (CDC) OOP OOP + AOP 195 64 0 200 400 Concern Diffusion over Operations (CDO) CONCERNS METRIC Concern Diffusion over Operation (CDO) OOP OOP + AOP 453 266 0 500 Concern Diffusion over Operations (CDO) CONCERNS METRIC Concern Diffusion over LoC (CDLoC) OOP OOP + AOP The Best: OOP + AOP The Best: OOP + AOP
  30. 30. Result and Analysis Size 44 44 0 20 40 60 Vocabulary Size CLASSES METRIC Vocabulary Size (VS) OOP OOP + AOP 36979 36531 0 20000 40000 Lines of Code LINES METRIC Line of Code (LoC) OOP OOP + AOP 158 163 0 100 200 Number of Attributes ATTRIBUTES METRIC Number of Attributes (NoA) OOP OOP + AOP 410 452 0 500 Weighted Operation per ComponentCOMPLEXITY METRIC Weighted Operations per Component (WoC) OOP OOP + AOP The Best: - The Best: OOP The Best: OOP + AOP The Best: OOP
  31. 31. Result and Analysis Coupling The Best: OOP 198 201 0 200 400 Coupling Between Components (CBC) COUPLING METRIC Coupling Between Component (CBC) OOP OOP + AOP 39 39 0 50 Depth of Inheritance Tree (DIT) DEPTH METRIC Depth of Inheritance Tree (DIT) OOP OOP + AOP The Best: -
  32. 32. Result and Analysis Cohesion The Best: OOP + AOP 181 155 0 100 200 Lack of Cohesion in Operations (LCOO) LACK METRIC Lack of Cohesion in Operations (LCOO) OOP OOP + AOP
  33. 33. Result and Analysis Summary Separation of Concerns (SoC) OOP+AOP Size OOP Coupling OOP Cohesion OOP+AOP The Best
  34. 34. CONCLUSION
  35. 35. Conclusion The code of API class with OOP+AOP is still easier to be understood because of separation between the functional requirement and aspects.1 The code of API class with OOP+AOP is more flexible than OOP if there is a significant change in codes caused by grouping concerns.2 These finding have shown an evidence that REST-OOP+AOP is indicated more reusable than REST-OOP.3
  36. 36. Thank You

    Be the first to comment

    Login to see the comments

  • dskusumo

    May. 2, 2021

Modularizing RESTful Web Service Management with Aspect Oriented Programming

Views

Total views

1,432

On Slideshare

0

From embeds

0

Number of embeds

36

Actions

Downloads

26

Shares

0

Comments

0

Likes

1

×