Introduction to Aspect-Oriented Programming
|
|
- Austin Brown
- 5 years ago
- Views:
Transcription
1 Introduction to Aspect-Oriented Programming Martin Giese Chalmers University of Technology Göteborg, Sweden AOP Course 2003 p.1/33
2 AspectJ Idioms and Patterns AOP Course 2003 p.2/33
3 Sources These idioms and pattern candidates were taken from the AspectJ in Action book by Laddad A paper by Hanenberg, Unland and Schmidmeier, named AspectJ Idioms for Aspect-Oriented Software Construction. AOP Course 2003 p.3/33
4 Avoid Infinite Recursion Problem: Pointcut matches some code in the advice Stack overflow public aspect Tracing { before() : call(* *.*(..)) { System.out.println("Caling: " + thisjoinpointstaticpart); pointcut too general. Use call(* *.*(..)) &&!within(tracing) AOP Course 2003 p.4/33
5 Nullifying Advice Problem: How to temporarily switch off advice during development, for experimentation and debugging? Advice declaration: before() : operation() {... Nullify advice: before() : operation() && if(false) {... Why not put if(false){... around the advice body? AOP Course 2003 p.5/33
6 Nullifying Advice (cont.) Compare: around() : operation() { if(false) {... proceed();... and around() : operation() && if(false) {... proceed();... AOP Course 2003 p.6/33
7 Empty Pointcuts Problem: Extending an abstract advice requires you to define a pointcut, but there are no mathing join points in your system. Example: public abstract aspect RemoteCallHandler { protected abstract pointcut synchronouscalls(); protected abstract pointcut asynchronouscalls();... In your system, no calls can be asynchronous. AOP Course 2003 p.7/33
8 Empty Pointcuts (cont.) Solution: not an idiom, but a language feature. Leave away colon and pointcut: public aspect MyRemoteCallHandler { protected pointcut synchronouscalls() : call(...); protected pointcut asynchronouscalls(); The alternative if(false) does not work with parameters: pointcut anop(int x) : if(false); formal unbound in pointcut AOP Course 2003 p.8/33
9 Marker Interface Problem: You want to apply advice based on some property that cannot be derived from the signature and name alone. Selecting particular methods: very difficult. Sometimes, it is sufficient to select certain classes for a pointcut. use Marker Interface Empty interface that is implemented by classes where advice should apply. Maybe other aspect (Marker Sticker) to attach marker to classes. Liberty in specifying which classes should be included. AOP Course 2003 p.9/33
10 Marker Interface (cont.) public interface TraceConstructors { public aspect ConstructorTracing { pointcut constrexec(): execution(*.new(..)) && target(traceconstructors);... public aspect MarkerSticker { declare parents: TargetClass implements TraceConstructor; AOP Course 2003 p.10/33
11 The Participant Pattern Problem: Pointcuts contain long lists of entities from all over the system, which should receive advice. The pointcuts actually specify all classes/methods/fields with a certain property. Solution: Reverse the roles make classes aware of the aspect, and have them declare the relevant properties. Use aspect with abstract pointcut. Classes can participate by inheriting from the aspect. Usually use inner aspect. AOP Course 2003 p.11/33
12 Participant Example public abstract aspect AbstractTracing { // invite participants public abstract pointcut logpoints();... public class MyQuadraticSATSolver { public boolean issatisfiable(clauseset c) { // participate in tracing public static aspect TraceMe extends AbstractTracing { public pointcut logpoints() : call(* MyQuadraticSATSolver.*(..)); AOP Course 2003 p.12/33
13 Template Advice Problem: You have different advice bodies, doing mainly the same thing, with just a few details changing. Solution: inspired by the Gang-of-Four Template Method pattern. use an abstract aspect put variation points into abstract methods implement a template advice, which uses these abstract methods. Note: advice itself cannot be overwritten in a sub-aspect template itself cannot be refined. AOP Course 2003 p.13/33
14 Template Advice Example public abstract aspect MultilingualTracing { // primitive operations public abstract String enteringstring(); public abstract String exitingstring(); public abstract pointcut logpoints(); // temlate advice before() : logpoints() { System.err.println(enteringString() + " " + thisjoinpoint); public abstract aspect FrenchTracing { public String enteringstring() { return "entrant"; public String exitingstring() { return "sortant de"; AOP Course 2003 p.14/33
15 Worker Object Creation Problem: around advice only allows you to choose whether you execute the original code at a join point or not. Your application needs to execute the code later or elsewhere or concurrently, etc. Standard non-aspectj solution: Wrap the action in a worker object implementing the Runnable interface. The run() method performs the action in question. Use the worker object to register the delayed action, start a thread, etc. AOP Course 2003 p.15/33
16 Worker Object Example Example: In a GUI program, a worker thread periodically wants to update a table to monitor progress.... tablemodel.addrow(newdata);... But Swing s thread safety rule prohibits modifying the model from anywhere but the AWT event handling thread. use one of the methods: java.awt.eventqueue.invokelater(runnable r) java.awt.eventqueue.invokeandwait(runnable r) AOP Course 2003 p.16/33
17 Worker Object Example (cont.) class TableRowAdder impelements Runnable { DefaultTableModel _model; Vector _data; AddTableRow( DefaultTableModel m, Vector d ) { _model = m; _data = d; public void run() { _model.addrow(_data); Call: EventQueue.invokeLater(new TableRowAdder(tableModel,newData)); AOP Course 2003 p.17/33
18 Worker Object Example (cont.) With anonymous class: EventQueue.invokeLater(new Runnable() { public void run() { tablemode.addrow(newdata); ); Idea: use around advice to create a worker object. AOP Course 2003 p.18/33
19 Worker Object Aspect around() : guicalls() { Runnable worker = new Runnable() { public void run() { proceed(); ; EventQueue.invokeLater(worker); Use proceed to capture normal operation; use it in a worker object. AOP Course 2003 p.19/33
20 Worker Object Aspect (cont.) Second example: asynchronous execution: around() : makeasynccalls() { Runnable worker = new Runnable() { public void run() { proceed(); ; new Thread(worker).start(); AOP Course 2003 p.20/33
21 Getting the Return Value What if we care about the return value? First create variant of Runnable which can store a return value: public abstract class RunnableWithReturn implements Runnable { protected Object _returnvalue; public Object getreturnvalue() { return _returnvalue; Use around advice to create a worker object that extends this class. AOP Course 2003 p.21/33
22 Worker Object Aspect with Return Value Object around() : guicallswithvalue() { Runnable worker = new RunnableWithReturn() { public void run() { proceed(); ; EventQueue.invokeAndWait(worker); return worker.getreturnvalue(); Note that return type Object for around advice includes primitive types! AOP Course 2003 p.22/33
23 Wormhole Problem: Somewhere deep in the call graph, you find out that you need some context information that was present much further up. Traditional solution: Add a context parameter to all the intermediate mehtods, that is not needed but only passed along. Idea: use a pointcut to capture the information when it is available, and advice to re-introduce it when it is needed. AOP Course 2003 p.23/33
24 Wormhole Nomenclature Nomenclature: caller space : where the context information is available. callee space : where the context information is needed. Example: Add logging statements for binomial coefficients, which include arguments of top-level call. caller space: top level call to binomcoeff callee space: logging statement that needs top level arguments. AOP Course 2003 p.24/33
25 How to Drill a Wormhole public aspect WormholeAspect { pointcut callerspace(<caller context>) : <caller pointcut>; pointcut calleespace(<callee context>) : <callee pointcut>; pointcut wormhole(<caller context>,<callee context>) : cflow(callerspace(<caller context>)) && calleespace(<callee context>) ; around(<caller context>,<callee context>) : wormhole(<caller context>,<callee context>) {... AOP Course 2003 p.25/33
26 Binomial Coeff. Tracing with Context public aspect WormholeAspect { pointcut topcall(int n0,int m0) : bccall(n0,m0) &&!cflowbelow(bccall(int,int)); pointcut bccall(int n,int m) : call(* BC.bc(..)) && args(n,m); pointcut wormhole(int n0,int m0,int n,int m) : cflow(topcall(n0,m0)) && bccall(n,m) ; around(int n0,int m0,int n,int m) : wormhole(int n0,int m0,int n,int m) { System.out.println("Calling bc( "+ n + "," + m + ")" "for bc( "+ n0 + "," + m0 + ")" ); AOP Course 2003 p.26/33
27 Exception Introduction Problem: Advice throws concern specific exceptions that should not be handled in the advised code. Solution from yesterday s lecture: use declare soft always the same SoftException wrapper, prevents concern specific exception handling. Idea: mimic exception softening but with concern specific RuntimeException AOP Course 2003 p.27/33
28 Advice with Exception Introduction public abstract aspect ConcernAspect { abstract pointcut operations(); before() : operations() { try { concernlogic(); catch (ConcernCheckedException ex) { throw new ConcernRuntimeException(ex); void concernlogic() throws ConcernCheckedException {... AOP Course 2003 p.28/33
29 Advice with Exception Introduction (cont.) public class ConcernRuntimeException extends RuntimeException { public ConcernRuntimeException(Throwable cause) { super(cause); Note: Since Java 1.4, exceptions have a constructor taking another Throwable describing the cause of this exception. Dedicated RuntimeException for each concern. AOP Course 2003 p.29/33
30 Handling Business Exceptions Call exceptions concerning the original code and not the advice business exceptions. Sometimes advice needs to catch all exception to do its work, aspect-specific and business-specific. Problem: a generic, reusable aspect might catch too much. How do we regenerate the appropriate business exceptions, which the original code can and expects to handle? AOP Course 2003 p.30/33
31 Catching All Exceptions public abstract aspect ConcernAspect { abstract pointcut operations(); Object around() : operations() { try { return proceed(); catch (Throwable ex) {... do concern s stuff... throw new ConcernRuntimeException(ex); What about exceptions that are thrown in proceed(), are not taken care of by this aspect, and should be handled by the code around the join point? AOP Course 2003 p.31/33
32 Preserving Business Exceptions public aspect PreserveBusinessException { declare precedence: PreserveBusinessException, ConcreteConcernAspect; after() throwing(concernruntimeexception ex) throws BusinessException : call(* *.*(..) throws BusinessException) { Throwable cause = ex.getcause(); if (cause instanceof BusinessException) { throw (BusinessException)cause; throw ex; // still a RuntimeException -> unchecked Detect where business exception may occur, unwrap them there AOP Course 2003 p.32/33
33 Conclusion You should now know about: some pointcut idioms marker interfaces the participant idiom template advice worker object creation the wormhole pattern exception introduction Tomorrow, you will hear about pros and cons and alternatives. AOP Course 2003 p.33/33
Le L c e t c ur u e e 5 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Exception Handling
Course Name: Advanced Java Lecture 5 Topics to be covered Exception Handling Exception HandlingHandlingIntroduction An exception is an abnormal condition that arises in a code sequence at run time A Java
More informationIntroduction to Aspect-Oriented Programming
Introduction to Aspect-Oriented Programming Martin Giese Chalmers University of Technology Göteborg, Sweden AOP Course 2003 p.1/44 AspectJ Quick Tour AOP Course 2003 p.2/44 Reminder: Join Points A join
More informationSo, What is an Aspect?
Introduction to AspectJ Aspect-oriented paradigm AspectJ constructs Types of Join Points Primitive Lexical designators Type designators Control flow Types of Advice Before After Around Receptions Join
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationIdioms for Building Software Frameworks in AspectJ
Idioms for Building Software Frameworks in AspectJ Stefan Hanenberg 1 and Arno Schmidmeier 2 1 Institute for Computer Science University of Essen, 45117 Essen, Germany shanenbe@cs.uni-essen.de 2 AspectSoft,
More informationExceptions. Gunnar Gotshalks EX 1
Exceptions EX 1 Exceptions Are surprising events that occur during the execution of a program» Not surprising that exceptions may occur > so we can prepare for them in a general way» Surprising in that
More informationB2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA
B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE
More informationCS 3 Introduction to Software Engineering. 3: Exceptions
CS 3 Introduction to Software Engineering 3: Exceptions Questions? 2 Objectives Last Time: Procedural Abstraction This Time: Procedural Abstraction II Focus on Exceptions. Starting Next Time: Data Abstraction
More informationCS159. Nathan Sprague
CS159 Nathan Sprague What s wrong with the following code? 1 /* ************************************************** 2 * Return the mean, or -1 if the array has length 0. 3 ***************************************************
More informationSCALA AND ASPECTJ. Approaching Modularizing of Crosscutting. Ramnivas Laddad. Concerns. ramnivas
SCALA AND ASPECTJ Approaching Modularizing of Crosscutting Concerns Ramnivas Laddad ramnivas ramnivas!com @ramnivas Copyright Ramnivas Laddad. All rights reserved. @ramnivas Spring framework committer
More informationCourse 6 7 November Adrian Iftene
Course 6 7 November 2016 Adrian Iftene adiftene@info.uaic.ro 1 Recapitulation course 5 BPMN AOP AOP Cross cutting concerns pointcuts advice AspectJ Examples In C#: NKalore 2 BPMN Elements Examples AOP
More informationDOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS
Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationMerge Sort Quicksort 9 Abstract Windowing Toolkit & Swing Abstract Windowing Toolkit (AWT) vs. Swing AWT GUI Components Layout Managers Swing GUI
COURSE TITLE :Introduction to Programming 2 COURSE PREREQUISITE :Introduction to Programming 1 COURSE DURATION :16 weeks (3 hours/week) COURSE METHODOLOGY:Combination of lecture and laboratory exercises
More informationG51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions
G51PGP Programming Paradigms Lecture 009 Concurrency, exceptions 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals = new Animal[6]; animals[0]
More informationMobile MOUSe JAVA2 FOR PROGRAMMERS ONLINE COURSE OUTLINE
Mobile MOUSe JAVA2 FOR PROGRAMMERS ONLINE COURSE OUTLINE COURSE TITLE JAVA2 FOR PROGRAMMERS COURSE DURATION 14 Hour(s) of Interactive Training COURSE OVERVIEW With the Java2 for Programmers course, anyone
More informationMurach s Beginning Java with Eclipse
Murach s Beginning Java with Eclipse Introduction xv Section 1 Get started right Chapter 1 An introduction to Java programming 3 Chapter 2 How to start writing Java code 33 Chapter 3 How to use classes
More informationLecture 20. Java Exceptional Event Handling. Dr. Martin O Connor CA166
Lecture 20 Java Exceptional Event Handling Dr. Martin O Connor CA166 www.computing.dcu.ie/~moconnor Topics What is an Exception? Exception Handler Catch or Specify Requirement Three Kinds of Exceptions
More informationAOP 101: Intro to Aspect Oriented Programming. Ernest Hill
AOP 101: Intro to Aspect Oriented Programming ernesthill@earthlink.net AOP 101-1 AOP 101: Aspect Oriented Programming Goal of Software History of Programming Methodology Remaining Problem AOP to the Rescue
More informationCS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance?
CS6501 - Internet programming Unit- I Part - A 1 Define Java. Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed to have the "look
More informationCompaq Interview Questions And Answers
Part A: Q1. What are the difference between java and C++? Java adopts byte code whereas C++ does not C++ supports destructor whereas java does not support. Multiple inheritance possible in C++ but not
More information2.6 Error, exception and event handling
2.6 Error, exception and event handling There are conditions that have to be fulfilled by a program that sometimes are not fulfilled, which causes a so-called program error. When an error occurs usually
More informationA Quick Tour p. 1 Getting Started p. 1 Variables p. 3 Comments in Code p. 6 Named Constants p. 6 Unicode Characters p. 8 Flow of Control p.
A Quick Tour p. 1 Getting Started p. 1 Variables p. 3 Comments in Code p. 6 Named Constants p. 6 Unicode Characters p. 8 Flow of Control p. 9 Classes and Objects p. 11 Creating Objects p. 12 Static or
More informationAssoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Marenglen Biba Exception handling Exception an indication of a problem that occurs during a program s execution. The name exception implies that the problem occurs infrequently. With exception
More informationTo Think About. MyClass.mogrify(new int[] { 1, 2, 4, 6 }));
A student adds a JUnit test: To Think About @Test public void mogrifytest() { assertequals("mogrify fails", new int[] { 2, 4, 8, 12 }, MyClass.mogrify(new int[] { 1, 2, 4, 6 })); } The test always seems
More informationJava Programming. Price $ (inc GST)
1800 ULEARN (853 276) www.ddls.com.au Java Programming Length 5 days Price $4235.00 (inc GST) Overview Intensive and hands-on, the course emphasizes becoming productive quickly as a Java application developer.
More informationCS159. Nathan Sprague
CS159 Nathan Sprague What s wrong with the following code? 1 /* ************************************************** 2 * Return the maximum, or Integer. MIN_VALUE 3 * if the array has length 0. 4 ***************************************************
More informationCSE 331 Software Design & Implementation
CSE 331 Software Design & Implementation Hal Perkins Spring 2017 Exceptions and Assertions 1 Outline General concepts about dealing with errors and failures Assertions: what, why, how For things you believe
More informationWritten by John Bell for CS 342, Spring 2018
Advanced OO Concepts Written by John Bell for CS 342, Spring 2018 Based on chapter 3 of The Object-Oriented Thought Process by Matt Weisfeld, with additional material from other sources. Constructors Constructors
More informationSynchronization SPL/2010 SPL/20 1
Synchronization 1 Overview synchronization mechanisms in modern RTEs concurrency issues places where synchronization is needed structural ways (design patterns) for exclusive access 2 Overview synchronization
More informationCSCI 261 Computer Science II
CSCI 261 Computer Science II Department of Mathematics and Computer Science Lecture 2 Exception Handling New Topic: Exceptions in Java You should now be familiar with: Advanced object-oriented design -
More informationCMPSCI 187: Programming With Data Structures. Lecture #20: Concurrency and a Case Study David Mix Barrington 24 October 2012
CMPSCI 187: Programming With Data Structures Lecture #20: Concurrency and a Case Study David Mix Barrington 24 October 2012 Concurrency and a Case Study Concurrency and Threads Example: Counter, Increase,
More informationJava Inheritance. Written by John Bell for CS 342, Spring Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources.
Java Inheritance Written by John Bell for CS 342, Spring 2018 Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources. Review Which of the following is true? A. Java classes may either
More informationQuiz on Tuesday April 13. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 4. Java facts and questions. Things to try in Java
CS 361 Concurrent programming Drexel University Fall 2004 Lecture 4 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce
More informationTypes, Values and Variables (Chapter 4, JLS)
Lecture Notes CS 141 Winter 2005 Craig A. Rich Types, Values and Variables (Chapter 4, JLS) Primitive Types Values Representation boolean {false, true} 1-bit (possibly padded to 1 byte) Numeric Types Integral
More informationF1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept
F1 A Java program Ch 1 in PPIJ Introduction to the course The computer and its workings The algorithm concept The structure of a Java program Classes and methods Variables Program statements Comments Naming
More informationSri Vidya College of Engineering & Technology Question Bank
1. What is exception? UNIT III EXCEPTION HANDLING AND I/O Part A Question Bank An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program s instructions.
More informationObject Oriented Programming
Object Oriented Programming Java lecture (10.2) Exception Handling 1 Outline Throw Throws Finally 2 Throw we have only been catching exceptions that are thrown by the Java run-time system. However, it
More informationA Third Look At Java. Chapter Seventeen Modern Programming Languages, 2nd ed. 1
A Third Look At Java Chapter Seventeen Modern Programming Languages, 2nd ed. 1 A Little Demo public class Test { public static void main(string[] args) { int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]);
More informationCore Java Interview Questions and Answers.
Core Java Interview Questions and Answers. Q: What is the difference between an Interface and an Abstract class? A: An abstract class can have instance methods that implement a default behavior. An Interface
More informationAgenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java
CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors Agenda
More informationASSERTIONS AND LOGGING
SUMMARY Exception handling, ASSERTIONS AND LOGGING PROGRAMMAZIONE CONCORRENTE E DISTR. Università degli Studi di Padova Dipartimento di Matematica Corso di Laurea in Informatica, A.A. 2015 2016 rcardin@math.unipd.it
More information"Charting the Course... Java Programming Language. Course Summary
Course Summary Description This course emphasizes becoming productive quickly as a Java application developer. This course quickly covers the Java language syntax and then moves into the object-oriented
More informationIndex. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107
A abbreviations 17 abstract class 105 abstract data types 105 abstract method 105 abstract types 105 abstraction 92, 105 access level 37 package 114 private 115 protected 115 public 115 accessors 24, 105
More informationCasting -Allows a narrowing assignment by asking the Java compiler to "trust us"
Primitives Integral types: int, short, long, char, byte Floating point types: double, float Boolean types: boolean -passed by value (copied when returned or passed as actual parameters) Arithmetic Operators:
More informationAround Weaving in abc
Around Weaving in abc Objectives Avoid heap allocations Inlining not as the general strategy to avoid code duplication Keep code in original classes to avoid visibility problems The starting point Around
More informationIndex COPYRIGHTED MATERIAL
Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes
More informationJava. Error, Exception, and Event Handling. Error, exception and event handling. Error and exception handling in Java
Computer Science Error, Exception, and Event Handling Java 02/23/2010 CPSC 449 228 Unless otherwise noted, all artwork and illustrations by either Rob Kremer or Jörg Denzinger (course instructors) Error,
More informationMathematics/Science Department Kirkwood Community College. Course Syllabus. Computer Science CSC142 1/10
Mathematics/Science Department Kirkwood Community College Course Syllabus Computer Science CSC142 Bob Driggs Dean Cate Sheller Instructor 1/10 Computer Science (CSC142) Course Description Introduces computer
More informationObject oriented programming. Instructor: Masoud Asghari Web page: Ch: 7
Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 7 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Essential
More informationApplication Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started
Application Development in JAVA Duration Lecture: Specialization x Hours Core Java (J2SE) & Advance Java (J2EE) Detailed Module Part I: Core Java (J2SE) Getting Started What is Java all about? Features
More informationCore JAVA Training Syllabus FEE: RS. 8000/-
About JAVA Java is a high-level programming language, developed by James Gosling at Sun Microsystems as a core component of the Java platform. Java follows the "write once, run anywhere" concept, as it
More informationAssertions and Exceptions Lecture 11 Fall 2005
Assertions and Exceptions 6.170 Lecture 11 Fall 2005 10.1. Introduction In this lecture, we ll look at Java s exception mechanism. As always, we ll focus more on design issues than the details of the language,
More informationCS121/IS223. Object Reference Variables. Dr Olly Gotel
CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors CS121/IS223
More informationProgram Correctness and Efficiency. Chapter 2
Program Correctness and Efficiency Chapter 2 Chapter Objectives To understand the differences between the three categories of program errors To understand the effect of an uncaught exception and why you
More informationTwo Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.
Class #07: Java Primitives Software Design I (CS 120): M. Allen, 13 Sep. 2018 Two Types of Types So far, we have mainly been dealing with objects, like DrawingGizmo, Window, Triangle, that are: 1. Specified
More informationEECS168 Exam 3 Review
EECS168 Exam 3 Review Exam 3 Time: 2pm-2:50pm Monday Nov 5 Closed book, closed notes. Calculators or other electronic devices are not permitted or required. If you are unable to attend an exam for any
More informationJava Threads. Written by John Bell for CS 342, Spring 2018
Java Threads Written by John Bell for CS 342, Spring 2018 Based on chapter 9 of Learning Java, Fourth Edition by Niemeyer and Leuck, and other sources. Processes A process is an instance of a running program.
More informationIntroduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview
Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple
More informationThis page intentionally left blank
This page intentionally left blank Absolute Java, Global Edition Table of Contents Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents Chapter 1 Getting Started 1.1 INTRODUCTION
More informationMultiple Inheritance, Abstract Classes, Interfaces
Multiple Inheritance, Abstract Classes, Interfaces Written by John Bell for CS 342, Spring 2018 Based on chapter 8 of The Object-Oriented Thought Process by Matt Weisfeld, and other sources. Frameworks
More informationResearch on the Novel and Efficient Mechanism of Exception Handling Techniques for Java. Xiaoqing Lv 1 1 huihua College Of Hebei Normal University,
International Conference on Informatization in Education, Management and Business (IEMB 2015) Research on the Novel and Efficient Mechanism of Exception Handling Techniques for Java Xiaoqing Lv 1 1 huihua
More informationMotivation. Ability is what you're capable of doing. Motivation determines what you do. Attitude determines how well you do it.
Aspects in AspectJ Motivation Aspect Oriented Programming: a brief introduction to terminology Installation Experimentation AspectJ some details AspectJ things you should know about but we dont have time
More informationJAVA GUI PROGRAMMING REVISION TOUR III
1. In java, methods reside in. (a) Function (b) Library (c) Classes (d) Object JAVA GUI PROGRAMMING REVISION TOUR III 2. The number and type of arguments of a method are known as. (a) Parameter list (b)
More informationCS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1
P a g e 1 CS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1 Q1 Describe some Characteristics/Advantages of Java Language? (P#12, 13, 14) 1. Java
More informationTypecasts and Dynamic Dispatch. Dynamic dispatch
Typecasts and Dynamic Dispatch Abstract Data Type (ADT) Abstraction Program Robustness Exceptions D0010E Lecture 8 Template Design Pattern Review: I/O Typecasts change the type of expressions as interpreted
More informationFunctions in C C Programming and Software Tools
Functions in C C Programming and Software Tools N.C. State Department of Computer Science Functions in C Functions are also called subroutines or procedures One part of a program calls (or invokes the
More informationStandard. Number of Correlations
Computer Science 2016 This assessment contains 80 items, but only 80 are used at one time. Programming and Software Development Number of Correlations Standard Type Standard 2 Duty 1) CONTENT STANDARD
More informationObjects and Iterators
Objects and Iterators Can We Have Data Structures With Generic Types? What s in a Bag? All our implementations of collections so far allowed for one data type for the entire collection To accommodate a
More informationPatterns and an Antiidiom for Aspect Oriented Programming (AOP)
Patterns and an Antiidiom for Aspect Oriented Programming (AOP) Arno Schmidmeier AspectSoft Lohweg 9, 91217 Hersbruck, Germany Arno@aspectsoft.de Abstract. There are many different options when using AOP
More informationCS61B Lecture #12. Today: Various odds and ends in support of abstraction.
CS61B Lecture #12 Today: Various odds and ends in support of abstraction. Readings: At this point, we have looked at Chapters 1 9 of Head First Java. Today s lecture is about Chapters 9 and 11. For Friday,
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationCS455: Introduction to Distributed Systems [Spring 2019] Dept. Of Computer Science, Colorado State University
CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] The House of Heap and Stacks Stacks clean up after themselves But over deep recursions they fret The cheerful heap has nary a care Harboring memory
More information15CS45 : OBJECT ORIENTED CONCEPTS
15CS45 : OBJECT ORIENTED CONCEPTS QUESTION BANK: What do you know about Java? What are the supported platforms by Java Programming Language? List any five features of Java? Why is Java Architectural Neutral?
More informationComp 249 Programming Methodology Chapter 9 Exception Handling
Comp 249 Programming Methodology Chapter 9 Exception Handling Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia University, Montreal, Canada These slides has been extracted,
More informationUnit III Rupali Sherekar 2017
Unit III Exceptions An exception is an abnormal condition that arises in a code sequence at run time. In other words, an exception is a run-time error. In computer languages that do not support exception
More informationJava Strings Java, winter semester
Java Strings 1 String instances of java.lang.string compiler works with them almost with primitive types String constants = instances of the String class immutable!!! for changes clases StringBuffer, StringBuilder
More informationUMBC CMSC 331 Final Exam
UMBC CMSC 331 Final Exam Name: UMBC Username: You have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points for answers that are needlessly wordy
More informationThe Sun s Java Certification and its Possible Role in the Joint Teaching Material
The Sun s Java Certification and its Possible Role in the Joint Teaching Material Nataša Ibrajter Faculty of Science Department of Mathematics and Informatics Novi Sad 1 Contents Kinds of Sun Certified
More information6.Introducing Classes 9. Exceptions
6.Introducing Classes 9. Exceptions Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 Learning
More informationCS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)
CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers
More informationSERG. Formalizing typical crosscutting concerns. Delft University of Technology Software Engineering Research Group Technical Report Series
Delft University of Technology Software Engineering Research Group Technical Report Series Formalizing typical crosscutting concerns Marius Marin Report TUD-SERG-2006-010 SERG TUD-SERG-2006-010 Published,
More informationInterview Questions of C++
Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.
More informationCS11 Java. Fall Lecture 4
CS11 Java Fall 2014-2015 Lecture 4 Java File Objects! Java represents files with java.io.file class " Can represent either absolute or relative paths! Absolute paths start at the root directory of the
More informationControl Abstraction. Hwansoo Han
Control Abstraction Hwansoo Han Review of Static Allocation Static allocation strategies Code Global variables Own variables (live within an encapsulation - static in C) Explicit constants (including strings,
More informationInheritance. SOTE notebook. November 06, n Unidirectional association. Inheritance ("extends") Use relationship
Inheritance 1..n Unidirectional association Inheritance ("extends") Use relationship Implementation ("implements") What is inherited public, protected methods public, proteced attributes What is not inherited
More informationLecture 10 Assertions & Exceptions
CSE 331 Software Design and Implementation OUTLINE Lecture 10 Assertions & Exceptions Zach Tatlock / Winter 2016 Exceptions: what, how in Java How to throw, catch, and declare exceptions Failure happens!
More informationAspect-Oriented Programming
Aspect-Oriented Programming Based on the Example of AspectJ Prof. Harald Gall University of Zurich, Switzerland software evolution & architecture lab AOP is kind of a complicated one for me ( ) the idea
More informationInformation systems modeling. Tomasz Kubik
Information systems modeling Tomasz Kubik Aspect-oriented programming, AOP Systems are composed of several components, each responsible for a specific piece of functionality. But often these components
More informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More informationLogicAJ The Power of Uniformly Generic Aspects
LogicAJ The Power of Uniformly Generic Aspects Tobias Rho Günter Kniesel ROOTS group Computer Science Department III University of Bonn Germany {rho, gk@cs.uni-bonn.de Adressed Problem: Context dependent
More informationEngineering Robust Server Software
Engineering Robust Server Software Exceptions Exceptions Handling problems: exceptions C++ Java temp-and-swap RAII Smart Pointers finally specifications finalizers (and why they are not what you need for
More informationCMSC 331 Second Midterm Exam
1 20/ 2 80/ 331 First Midterm Exam 11 November 2003 3 20/ 4 40/ 5 10/ CMSC 331 Second Midterm Exam 6 15/ 7 15/ Name: Student ID#: 200/ You will have seventy-five (75) minutes to complete this closed book
More informationException Handling Introduction. Error-Prevention Tip 13.1 OBJECTIVES
1 2 13 Exception Handling It is common sense to take a method and try it. If it fails, admit it frankly and try another. But above all, try something. Franklin Delano Roosevelt O throw away the worser
More informationExceptions (part 2) An exception is an object that describes an unusual or erroneous situation. Quick Review of Last Lecture.
(part 2) December 3, 2007 Quick Review of Last Lecture ComS 207: Programming I (in Java) Iowa State University, FALL 2007 Instructor: Alexander Stoytchev An exception is an object that describes an unusual
More informationCOMP1008 Exceptions. Runtime Error
Runtime Error COMP1008 Exceptions Unexpected error that terminates a program. Undesirable Not detectable by compiler. Caused by: Errors in the program logic. Unexpected failure of services E.g., file server
More informationAspect-Oriented Programming with C++ and AspectC++
Aspect-Oriented Programming with C++ and AspectC++ AOSD 2007 Tutorial University of Erlangen-Nuremberg Computer Science 4 Presenters Daniel Lohmann dl@aspectc.org University of Erlangen-Nuremberg, Germany
More informationRecreation. MyClass.mogrify(new int[] { 1, 2, 4, 6 }));
A student adds a JUnit test: Recreation @Test public void mogrifytest() { assertequals("mogrify fails", new int[] { 2, 4, 8, 12 }, MyClass.mogrify(new int[] { 1, 2, 4, 6 })); } The test always seems to
More informationC# Syllabus. MS.NET Framework Introduction
C# Syllabus MS.NET Framework Introduction The.NET Framework - an Overview Framework Components Framework Versions Types of Applications which can be developed using MS.NET MS.NET Base Class Library MS.NET
More informationJava Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p.
Preface p. xix Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p. 5 Java Applets and Applications p. 5
More information