CS4YY – Aspect Oriented Programming Language Final Exam Total Marks: 100 Part 1: Questions (1) to (5) Are Multiple Choice and Short Questions

CS4YY – Aspect Oriented Programming Language Final Exam Total Marks: 100 Part 1: Questions (1) to (5) Are Multiple Choice and Short Questions

CS4YY – Aspect Oriented Programming Language Final Exam Total Marks: 100 Part 1: Questions (1) to (5) are multiple choice and short questions. Each is worth 2 points. (1) Is it possible to implement cross cutting concerns in Object-oriented programming? Mention one of the most important issues that must be taken care of to implement the cross cutting concern in AOP. Answer: (2) Which of the following statements is false? AspectJ allows capturing join points corresponding to: A. method call and execution join points. B. read and write access to data member of a class. C. execution of exception handler block. D. for and while loops. (3) Which of the statements about pointcut is false? A. Pointcut is an AspectJ construct to capture join points. B. Pointcuts can be declared inside aspects, classes, and interfaces. C. Pointcuts can be declared inside methods. D. Pointcuts can have an access specifier. CS4YY – Final Exam – Page 1 (4) AspectJ's dynamic crosscutting does not provide the following kind of advice A. Concurrent B. Before C. After C. Around (5) Briefly differentiate between Call and Execution Designators Answer: CS4YY – Final Exam – Page 2 Part 2: Questions (6) to (9) are short essay questions. Each is worth 7 points. (6) Explain differences between AOP Weaving Types in terms of Compile-time, Link-time, Load-time and Run-time. Answer: (7) What are Softening Exceptions? Explain? Answer: CS4YY – Final Exam – Page 3 (8) Explain Joint Point Model in terms of Pointcuts and advice. Answer: CS4YY – Final Exam – Page 4 (9) Why is System.out.println() not a good way to display output to the user for multiple programs? Explain it and also provide a remedy for this problem? Answer: CS4YY – Final Exam – Page 5 Part 3: Questions (10) to (13) are long essay questions. Each is worth 10 points. (10) Explain AOP in detail, problems relating from OOPS and how AOP overcomes the drawbacks of OOPS? Answer: (11) What are the different types of Extended Runtime Error Handling? Explain briefly. Answer: CS4YY – Final Exam – Page 6 (12) Explain Design Patterns as Aspects. Answer: CS4YY – Final Exam – Page 7 (13) Explain Reusable Persistence Protocol Aspect Answer: CS4YY – Final Exam – Page 8 Part 4: Question (14) consists of two parts (a) and (b). This question is of 22 points . (14) (a) Explain 'After advice' in detail? Answer: CS4YY – Final Exam – Page 9 (14) (b) Give the Jikes virtual machine architecture and explain the architecture of Steamloom model? Answer: CS4YY – Final Exam – Page 10 CS4YY – Aspect Oriented Programming Language Final Exam - Solutions Part 1: Questions (1) to (5) are multiple choice and short questions. Each is worth 2 points. (1) Is it possible to implement cross cutting concerns in Object-oriented programming? Mention one of the most important issues that must be taken care of to implement the cross cutting concern in AOP. Answer: In object oriented programming, cross cutting concerns cannot be implemented whereas these can be implemented easily in aspect-oriented programming. Issue to be taken care of: In aspect-oriented programming, if there is a logic mistake in implementing these cross-cutting concerns then the whole system will fail. In case of object-oriented this scenario of entire system failure will not occur. (2) Which of the following statements is false? AspectJ allows capturing join points corresponding to: A. method call and execution join points. B. read and write access to data member of a class. C. execution of exception handler block. D. for and while loops. Answer: D (3) Which of the statements about pointcut is false? A. Pointcut is an AspectJ construct to capture join points. B. Pointcuts can be declared inside aspects, classes, and interfaces. C. Pointcuts can be declared inside methods. D. Pointcuts can have an access specifier. Answer: C CS4YY – Final Exam – Page 11 (4) AspectJ's dynamic crosscutting does not provide the following kind of advice A. Concurrent B. Before C. After C. Around Answer: A (5) Briefly differentiate between Call and Execution Designators Answer: In terms of this() and target(): Part 2: Questions (6) to (9) are short essay questions. Each is worth 7 points. (6) Explain differences between AOP Weaving Types in terms of Compile-time, Link-time, Load-time and Run-time. CS4YY – Final Exam – Page 12 Answer: The differences between AOP Weaving Types in terms of Compile-time, Link-time and Load-time and Run-time are explained as below: • Compile-time: The source code from the primary Compiler and aspect languages is weaved before being put through the phases of the compiler where byte code is produced. For example AspectJ 1.0 uses this form of weaving. • Link-time: The weaving occurs after the primary Linker and aspect language code has been compiled into byte code. For example AspectJ 1.1 uses this form of weaving. • Load-time: The weaving occurs when classes (Classloader) under Java are loaded by the Classloader. Ultimately, the weaving is at the byte-code level. • Run-time: The virtual machine is responsible for Virtual machine detecting join points and loading and execution aspects. (7) What are Softening Exceptions? Explain? Answer: AspectJ allows users to bypass Java’s exception checking system by softening exceptions. As experienced Java developers are aware, Java ensures that all subclasses of Exception (except those that subclass Runtime Exception) are either declared in signatures or caught and handled. Sometimes this feature reminds programmers to handle exceptional conditions. Often, however, exceptional conditions indicate flaws in program design or infrequently encountered combinations of state and input. Intermediary callers may not have any better idea of how to deal with the condition than did the original thrower. As such, a lot of error handling that we’ve seen in practice amounts to logging the exception or rethrowing an unchecked exception in the place of the original checked exception. In recognition of this state of affairs, AspectJ’s designers incorporated the ability to selectively silence exceptions and rethrow them as unchecked exceptions using the 'declare soft' form. (8) Explain Joint Point Model in terms of Pointcuts and advice. The advice-related component of an aspect-oriented language defines a join point model (JPM). A Joint Point Model defines three things: • When the advice can run . These are called join points because they are points in a running program where additional behavior can be usefully joined. A join point needs to be addressable and understandable by an ordinary programmer CS4YY – Final Exam – Page 13 to be useful. It should also be stable across inconsequential program changes in order for an aspect to be stable across such changes. Many AOP implementations support method executions and field references as join points. • A way to specify (or quantify) join points, called pointcuts . Pointcuts determine whether a given join point matches. Most useful pointcut languages use a syntax like the base language (e.g., Java signatures are used for AspectJ) and allow reuse through naming and combination. • A means of specifying code to run at a join point. In AspectJ, this is called advice, and can run before, after, and around join points. Some implementations also support things like defining a method in an aspect on another class. (9) Why is System.out.println() not a good way to display output to the user for multiple programs? Explain it and also provide a remedy for this problem? Answer: For simple Programs System.out.println() is a great way to display output to the user because the user gets to know where the output came from. However for multiple programs it is not a good approach to use because user would not be able to identify that from which class/method the output came from. Remedy: CS4YY – Final Exam – Page 14 To remedy this problem JDK 1.4 introduced logging classes. This solution introduces complexity. For example Public class printtest { Public printtest() { System.out.println(“ In Constructor”); } Pubic coid test1() { System.out.println(“In test 1”); } Public void test2() { System.out.println() { System.out.println(“ In test2”); } Public static void main (string[] args){ System.out.println(“In main”); Print test t=new printtest(); t.test1(); t.test2(); } } Inorder to add a little context to the printlns; lets find out the name of the class that made the call to system.out.println(). Advice Code used: Before(object caller):log calls(caller){ System.out.println(getclassname(caller) + ”:”); } Here this advice says before log calls issue an additional print statement stating the class name of the caller. Before specifies the type of advice that we are using and it means that the advice will execute before the joint point it effects. Part 3: Questions (10) to (13) are long essay questions. Each is worth 10 points. (10) Explain AOP in detail, problems relating from OOPS and how AOP overcomes the drawbacks of OOPS? Answer: Aspect-oriented programming is a paradigm that supports two fundamental goals: Allow for the separation of concerns as appropriate for a host language and provide a mechanism for the description of concerns that crosscut other components. AOP is designed to support the separation of the example concerns and to allow both a Logger and a Product class; it also handles the crosscutting that occurs when logging is required in the components supporting another concern. CS4YY – Final Exam – Page 15 Problems Resulting from OOPS OOP allows for the encapsulation of data and methods specific to the goal of a specific object. In other words, an object should be a self-contained unit with no understanding of its environment, and its environment should be aware of nothing about the object other than what the object reveals. A class is the cookie cutter for objects in a system, and it implements a concern for the system.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    23 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us