Aspect-oriented programming (AOP) allows programmers to modularize crosscutting concerns. Logging is a common example of a crosscutting concern that can be implemented using AOP. In AspectJ, an AOP extension to Java, aspects are used to encapsulate crosscutting concerns. Advice such as before and after advice can be used to add behavior at certain join points, such as method calls and executions. This avoids tangling code for crosscutting concerns throughout multiple classes.
Compiler optimizations based on call-graph flatteningCAFxX
Presentation for my thesis dissertation on compiler optimizations based on call-graph flattening.
Thesis: http://cafxx.strayorange.com/app/cv/addendum/thesis/ferraris_compiler_optimizations_call_graph_flattening.pdf
Code repository: https://github.com/CAFxX/cgf
Compiler optimizations based on call-graph flatteningCAFxX
Presentation for my thesis dissertation on compiler optimizations based on call-graph flattening.
Thesis: http://cafxx.strayorange.com/app/cv/addendum/thesis/ferraris_compiler_optimizations_call_graph_flattening.pdf
Code repository: https://github.com/CAFxX/cgf
OpenFOAM for beginners: Hands-on trainingJibran Haider
NOTE: A NEW VERSION OF THIS PRESENTATION IS AVAILABLE ON MY RESEARCH GATE ACCOUNT
(https://www.researchgate.net/publication/327594760_OpenFOAM_course_for_beginners_Hands-on_training)
OpenFOAM is an open source Computational Fluid Dynamics software package based on C++ programming language within the context of cell centred Finite Volume Method. It is developed primarily by OpenCFD Ltd and distributed by OpenCFD Ltd and the OpenFOAM Foundation.
Disclaimer:
This offering is not approved or endorsed by OpenCFD Limited, producer and distributor of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks. "
Intro to Functional Reactive Programming In ScalaDiego Alonso
An overview and introduction to the Functional Reactive Programming paradigm, including Arrowised FRP, and a small peek at a simplified implementation of AFRP in Scala based on Monadic Stream Functions.
Given at Scala eXchange on 13th of December 2018.
Full tutorial to start with OpenFOAM: run tutorials, adapt tutorials, single phase flow, immiscible two-phase flow, grid complex geometries, program equations.
Approaches and techniques for statically finding a multitude of issues in source code have been developed in the past. A core property of these approaches is that they are usually targeted towards finding only a very specific kind of issue and that the effort to develop such an analysis is significant. This strictly limits the number of kinds of issues that can be detected.
In this paper, we discuss a generic approach based on the detection of infeasible paths in code that can discover a wide range of code smells ranging from useless code that hinders comprehension to real bugs. Code issues are identified by calculating the difference between the control-flow graph that contains all technically possible edges and the corresponding graph recorded while performing a more precise analysis using abstract interpretation.
We have evaluated the approach using the Java Development Kit as well as the Qualitas Corpus (a curated collection of over 100 Java Applications) and were able to find thousands of issues across a wide range of categories.
(chapter 3) A Concise and Practical Introduction to Programming Algorithms in...Frank Nielsen
These are the slides accompanying the textbook:
A Concise and Practical Introduction to Programming Algorithms in Java
by Frank Nielsen
Published by Springer-Verlag (2009), Undergraduate textbook in computer science (UTiCS series)
ISBN: 978-1-84882-338-9
http://www.lix.polytechnique.fr/~nielsen/JavaProgramming/
http://link.springer.com/book/10.1007%2F978-1-84882-339-6
EclipseCon Eu 2015 - Breathe life into your Designer!melbats
You have your shiny new DSL up and running thanks to the Eclipse Modeling Technologies and you built a powerful tooling with graphical modelers, textual syntaxes or dedicated editors to support it. But how can you see what is going on when a model is executed ? Don't you need to simulate your design in some way ? Wouldn't you want to see your editors being animated directly within your modeling environment based on execution traces or simulator results?
The GEMOC Research Project designed a methodology to bring animation and execution analysis to DSLs. The companion technologies required to put this in action are small dedicated components (all open-source) at a "proof of concept" maturity level extending proven components : Sirius, Eclipse Debug, Xtend making such features within the reach of Eclipse based tooling. The general intent regarding those OSS technologies is to leverage them within different contexts and contribute them to Eclipse once proven strong enough. The method covers a large spectrum of use cases from DSLs with a straightforward execution semantic to a combination of different DSLs with concurrent execution semantic. Any tool provider can leverage both the technologies and the method to provide an executable DSL and animated graphical modelers to its users enabling simulation and debugging at an early phase of the design.
This talk presents the approach, the technologies and demonstrate it through an example: providing Eclipse Debug integration and diagram animation capabilities for Arduino Designer (EPL) : setting breakpoints, stepping forward or backward in the execution, inspecting the variables states... We will walk you through the steps required to develop such features, the choices to make and the trade-offs involved. Expects live demos with simulated blinking leds and a virtual cat robot !
Introduction to Aspect Oriented Programming (DDD South West 4.0)Yan Cui
Introduction to AOP talk at DDD SouthWest 4.0, including examples of AOP using dynamic proxies, functional programming, dynamic language and PostSharp.
OpenFOAM for beginners: Hands-on trainingJibran Haider
NOTE: A NEW VERSION OF THIS PRESENTATION IS AVAILABLE ON MY RESEARCH GATE ACCOUNT
(https://www.researchgate.net/publication/327594760_OpenFOAM_course_for_beginners_Hands-on_training)
OpenFOAM is an open source Computational Fluid Dynamics software package based on C++ programming language within the context of cell centred Finite Volume Method. It is developed primarily by OpenCFD Ltd and distributed by OpenCFD Ltd and the OpenFOAM Foundation.
Disclaimer:
This offering is not approved or endorsed by OpenCFD Limited, producer and distributor of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks. "
Intro to Functional Reactive Programming In ScalaDiego Alonso
An overview and introduction to the Functional Reactive Programming paradigm, including Arrowised FRP, and a small peek at a simplified implementation of AFRP in Scala based on Monadic Stream Functions.
Given at Scala eXchange on 13th of December 2018.
Full tutorial to start with OpenFOAM: run tutorials, adapt tutorials, single phase flow, immiscible two-phase flow, grid complex geometries, program equations.
Approaches and techniques for statically finding a multitude of issues in source code have been developed in the past. A core property of these approaches is that they are usually targeted towards finding only a very specific kind of issue and that the effort to develop such an analysis is significant. This strictly limits the number of kinds of issues that can be detected.
In this paper, we discuss a generic approach based on the detection of infeasible paths in code that can discover a wide range of code smells ranging from useless code that hinders comprehension to real bugs. Code issues are identified by calculating the difference between the control-flow graph that contains all technically possible edges and the corresponding graph recorded while performing a more precise analysis using abstract interpretation.
We have evaluated the approach using the Java Development Kit as well as the Qualitas Corpus (a curated collection of over 100 Java Applications) and were able to find thousands of issues across a wide range of categories.
(chapter 3) A Concise and Practical Introduction to Programming Algorithms in...Frank Nielsen
These are the slides accompanying the textbook:
A Concise and Practical Introduction to Programming Algorithms in Java
by Frank Nielsen
Published by Springer-Verlag (2009), Undergraduate textbook in computer science (UTiCS series)
ISBN: 978-1-84882-338-9
http://www.lix.polytechnique.fr/~nielsen/JavaProgramming/
http://link.springer.com/book/10.1007%2F978-1-84882-339-6
EclipseCon Eu 2015 - Breathe life into your Designer!melbats
You have your shiny new DSL up and running thanks to the Eclipse Modeling Technologies and you built a powerful tooling with graphical modelers, textual syntaxes or dedicated editors to support it. But how can you see what is going on when a model is executed ? Don't you need to simulate your design in some way ? Wouldn't you want to see your editors being animated directly within your modeling environment based on execution traces or simulator results?
The GEMOC Research Project designed a methodology to bring animation and execution analysis to DSLs. The companion technologies required to put this in action are small dedicated components (all open-source) at a "proof of concept" maturity level extending proven components : Sirius, Eclipse Debug, Xtend making such features within the reach of Eclipse based tooling. The general intent regarding those OSS technologies is to leverage them within different contexts and contribute them to Eclipse once proven strong enough. The method covers a large spectrum of use cases from DSLs with a straightforward execution semantic to a combination of different DSLs with concurrent execution semantic. Any tool provider can leverage both the technologies and the method to provide an executable DSL and animated graphical modelers to its users enabling simulation and debugging at an early phase of the design.
This talk presents the approach, the technologies and demonstrate it through an example: providing Eclipse Debug integration and diagram animation capabilities for Arduino Designer (EPL) : setting breakpoints, stepping forward or backward in the execution, inspecting the variables states... We will walk you through the steps required to develop such features, the choices to make and the trade-offs involved. Expects live demos with simulated blinking leds and a virtual cat robot !
Introduction to Aspect Oriented Programming (DDD South West 4.0)Yan Cui
Introduction to AOP talk at DDD SouthWest 4.0, including examples of AOP using dynamic proxies, functional programming, dynamic language and PostSharp.
[Note that this talk is not available outside some very specific settings but this deck is here for you as a basic resource to form a basis for your own analysis based on my reasonably objective extensive professional experience using both technology sets in the real world]
Java EE 7 has been one of the most significant overhauls of the platform. Just some of the changes include retiring EJB 2 entity beans and JAX-RPC, greater alignment with CDI, WebSocket/HTML 5 support, a standard API for JSON processing, the next version of JAX-RS, an overhaul of JMS, long-awaited concurrency utilities, batch processing in Java EE and much, much more. In order to make educated choices for adoption, one should understand how the widely-used Spring Framework aligns with Java EE.
This session will compare and contrast the Spring Framework with Java EE 7. We will focus on key areas that include the component development model, dependency injection, persistence, UI, REST, messaging, security and testing. Beyond API/features, the analysis will take a holistic view in covering concerns such as ease-of-use, manageability, ecosystem and vendor-neutrality.
ScalaDays 2013 Keynote Speech by Martin OderskyTypesafe
Scala gives you awesome expressive power, but how to make best use of it? In my talk I will discuss the question what makes good Scala style. We will start with syntax and continue with how to name things, how to mix objects and functions, where (and where not) to use mutable state, and when to use which design pattern. As most questions of style, the discussion will be quite subjective, and some of it might be controversial. I am looking forward to discuss these topics with the conference attendees.
Whats New in Visual Studio 2012 for C++ DevelopersRainer Stropek
For a Microsoft event we have been hired to do a full-day workshop about news in Visual Studio 2012 for C++ developers. My colleague Philipp Aumayr conducted the workshop. Here are the slides for his talk. More details including sample code can be found in our developer blog at http://www.software-architects.com
Presentation given on 10th of January 2019 for Krków Scala Meetup Group.
We discussed how far are we from imperative programming when using the IO monad.
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)Ovidiu Farauanu
Discussing Design Patterns and OOP popularity,
Multithreading and OOP,
Functional Design for Multithreaded programming
and how Multithreading does not mean always concurency but multicore paralelism.
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Raffi Khatchadourian
Java 8 is one of the largest upgrades to the popular language and framework in over a decade. In this talk, I will first overview several new, key features of Java 8 that can help make programs easier to read, write, and maintain, especially in regards to collections. These features include Lambda Expressions, the Stream API, and enhanced interfaces, many of which help bridge the gap between functional and imperative programming paradigms and allow for succinct concurrency implementations. Next, I will discuss several open issues related to automatically migrating (refactoring) legacy Java software to use such features correctly, efficiently, and as completely as possible. Solving these problems will help developers to maximally understand and adopt these new features thus improving their software.
Object-Oriented Programming has well established design principles, such as SOLID. For many developers architecture and functional programming are at odds with each other: they don’t know how their existing tricks of the trade convert into functional design. This problem becomes worse as hybrid languages such as Scala, Java 8 and Ruby become common. I will talk about how functional programming helps you implement the SOLID principles, and how a functional mindset can actually help you achieve the holy grail of OO, encapsulation.
Composing an App with Free Monads (using Cats)Hermann Hueck
In this talk I will explain what Free Monads are and how to use them (using the Cats implementation).
After having shown the basics I build a small app by composing several
Free Monads to a small program.
I discuss the pros and cons of this technique.
Finally I will demonstrate how to avoid some boilerplate with the FreeK library.
Twins: Object Oriented Programming and Functional ProgrammingRichardWarburton
Object-Oriented Programming has well established design principles, such as SOLID. For many developers architecture and functional programming are at odds with each other: they don’t know how their existing tricks of the trade convert into functional design. This problem becomes worse as hybrid languages such as Java 8 or Scala become common. We’ll talk about how functional programming helps you implement the SOLID principles, and how a functional mindset can actually help you achieve cleaner and simpler OO design.
Need to make a horizontal change across 100+ microservices? No worries, Sheph...Aori Nevo, PhD
In this talk, you’ll be introduced to an innovative,
powerful, flexible, and easy-to-use tool developed by the
folks at NerdWallet that simplifies some of the complexities
associated with making horizontal changes in service
oriented systems via automation.
Similar to Aspect-oriented programming with AspectJ (as part of the the PTT lecture) (20)
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
Aspect-oriented programming with AspectJ (as part of the the PTT lecture)
1. Aspect-oriented
Programming
Prof. Dr. Ralf Lämmel
Universität Koblenz-Landau
Software Languages Team
https://github.com/101companies/101repo/tree/master/languages/AspectJ/aspectJSamples
Non-101samples available here:
http://101companies.org/wiki/
Contribution:aspectJ
See special
copyright message
at the end of the
slide deck.
2. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Elevator pitch
Suppose you need to implement some tracing (aka logging)
functionality in your app. Chances are that code needs to be
scattered allover the app; see below. Can we do better than this.
Yes, use AOP!
See copyright notice
elsewhere in this deck.
3. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
class Point {
void set(int x, int y) {
TraceSupport.traceEntry("Point.set");
this.x = x; this.y = y;
TraceSupport.traceExit("Point.set");
}
}
class TraceSupport {
static int TRACELEVEL = 0;
static protected PrintStream stream = null;
static protected int callDepth = -1;
static void init(PrintStream _s) {stream=_s;}
static void traceEntry(String str) {
if (TRACELEVEL == 0) return;
callDepth++;
printEntering(str);
}
static void traceExit(String str) {
if (TRACELEVEL == 0) return;
callDepth--;
printExiting(str);
}
}
TraceSupport
Many classes (objects)
interact with the trace
facility.
Tracing without AOP
See copyright notice
elsewhere in this deck.
4. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Logging is a crosscutting concern.
These concerns don’t fit into traditional modules.
Other examples:
• Error handling
• Synchronization
• Security
• Power management
• Memory management
• Performance optimizations
Costs of tangled code:
• Difficult to understand
• Difficult to change
• Increases with size of system
• Increases maintenance costs
• Very difficult to get rid of, if at all
See copyright notice
elsewhere in this deck.
5. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Aspect-Oriented Programming
• Crosscutting concerns
– … are inherent to complex systems.
– … serve important purposes.
– … have a natural structure.
– … can be captured in new kinds of modules.
– … require designated language and tool support.
An aspect is a well-modularized crosscutting concern.
See copyright notice
elsewhere in this deck.
6. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Tracing with AOP
414
aspect PointTracing {
pointcut trace():
within(com.bigboxco.boxes.*) &&
execution(* *(..));
before(): trace() {
TraceSupport.traceEntry(tjp);
}
after(): trace() {
TraceSupport.traceExit(tjp);
}
}
class Point {
void set(int x, int y) {
this.x = x; this.y = y;
}
}
The classes (objects) do not to
contain code that anticipates the
interaction with the trace facility.
An aspect in the
AspectJ language
– which is a Java
extension
See copyright notice
elsewhere in this deck.
7. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Aspects – benefits in design and coding
• Objects no longer responsible for using the trace facility.
• Trace aspect encapsulates that tracing responsibility.
• Changing the tracing concern affects one module.
• Removing tracing from the design is trivial.
See copyright notice
elsewhere in this deck.
8. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
AspectJ – an implementation of AOP
• Well-integrated extension to Java
• A general-purpose AOP language
• Compiles to JVM-compatible .class files
• Semantics relies on load-time weaving
• IDE support for Eclipse et al.: AJDT
• Freely available implementation
• Invented in the 90-ties at XEROX Parc
• Now maintained and used by IBM
• Other major AOP implementations for Java:
– JBoss
– AspectWerkz
See copyright notice
elsewhere in this deck.
9. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Logistics
Recommended working environment for AspectJ
Recent Eclipse
AJDT (includes AspectJ compiler)
Use Eclipse UPDATE to install AJDT.
Eclipse/AspectJ tips:
Make sure weaving is enabled.
Make use of IDE hints to study weaving.
11. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Scenario
• Report when “main” method is called.
• Report when execution is completed.
“Hello World” of AspectJ
DEMO
See package helloworld
12. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Scenario
• Refuse negative withdrawal.
• Refuse negative deposits.
• Refuse negative balance.
A safer account class
420
DEMO
See package accounts
14. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
operations that move elements
factory methods
Display
*
2Point
getX()
getY()
setX(int)
setY(int)
moveBy(int, int)
Line
getP1()
getP2()
setP1(Point)
setP2(Point)
moveBy(int, int)
Figure
makePoint(..)
makeLine(..)
FigureElement
moveBy(int, int)
A simple figure editor
See copyright notice
elsewhere in this deck.
15. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
A simple figure editor
class Line implements FigureElement{
private Point p1, p2;
Point getP1() { return p1; }
Point getP2() { return p2; }
void setP1(Point p1) { this.p1 = p1; }
void setP2(Point p2) { this.p2 = p2; }
void moveBy(int dx, int dy) { ... }
}
class Point implements FigureElement {
private int x = 0, y = 0;
int getX() { return x; }
int getY() { return y; }
void setX(int x) { this.x = x; }
void setY(int y) { this.y = y; }
void moveBy(int dx, int dy) { ... }
}
See copyright notice
elsewhere in this deck.
16. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
A crosscutting concern: figure updating
• Figures are collections of figure elements.
• The latter move frequently.
• Displays show figures.
• Displays need to be updated when moves happen.
See copyright notice
elsewhere in this deck.
17. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Join points along the execution of method call
(Move a line, and in turns its points)
a Line
a Point
returning or throwing
dispatch
dispatch
a method call
returning or throwing
a method execution
returning or throwing
a method execution
myObject.moveBy(2, 2)
myObject.p1.moveBy(2, 2)
See copyright notice
elsewhere in this deck.
18. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Join-point terminology
• Several kinds of join points
– method & constructor call
– method & constructor execution
– field get & set
– exception handler execution
– static & dynamic initialization
a Line
dispatch
method call
join points
method
execution join
points
See copyright notice
elsewhere in this deck.
19. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
The language construct
“pointcut”
• Pointcuts provide a means to identify join points.
• A pointcut is a kind of predicate on join points that:
– can match or not match any given join point, and
– optionally, pulls out some of the values at that join point.
• Example:
call(void Line.setP1(Point))
• Meaning:
Matches if the join point is a method call with this signature.
See copyright notice
elsewhere in this deck.
20. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Pointcuts compose like predicates, using &&, || and !.
Example:
Meaning:
Composition of pointcuts
Matches whenever a Line receives a
“void setP1(Point)” or “void setP2(Point)” method call.
a “void Line.setP2(Point)” call
or
a “void Line.setP1(Point)” call
call(void Line.setP1(Point)) ||
call(void Line.setP2(Point));
See copyright notice
elsewhere in this deck.
21. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Anonymous and named pointcuts
• Pointcuts can be named – for reuse.
• Example:
pointcut move():
call(void Line.setP1(Point)) ||
call(void Line.setP2(Point));
See copyright notice
elsewhere in this deck.
22. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
After advice:
actions to be taken after computation at join point
pointcut move():
call(void Line.setP1(Point)) ||
call(void Line.setP2(Point));
after() returning: move() {
<code here runs after each move>
}
See copyright notice
elsewhere in this deck.
23. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
A simple aspect for
display updating
aspect DisplayUpdating {
pointcut move():
call(void Line.setP1(Point)) ||
call(void Line.setP2(Point));
after() returning: move() {
Display.update();
}
}
See copyright notice
elsewhere in this deck.
24. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Tangled code without an aspect
• Update calls are tangled through the code.
• Discipline of updating must be checked by full inspection.
• BTW, “weaving” effectively results in this code.
class Line {
private Point p1, p2;
Point getP1() { return p1; }
Point getP2() { return p2; }
void setP1(Point p1) {
this.p1 = p1;
Display.update();
}
void setP2(Point p2) {
this.p2 = p2;
Display.update();
}
}
See copyright notice
elsewhere in this deck.
25. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Pointcuts – some elaborations
• Crosscutting multiple classes
• Crosscutting based on interface signatures
pointcut move():
call(void Line.setP1(Point)) ||
call(void Line.setP2(Point)) ||
call(void Point.setX(int)) ||
call(void Point.setY(int));
pointcut move():
call(void FigureElement.moveBy(int, int)) ||
call(void Line.setP1(Point)) ||
call(void Line.setP2(Point)) ||
call(void Point.setX(int)) ||
call(void Point.setY(int));
See copyright notice
elsewhere in this deck.
26. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Pick up values at join point
Example: the target of a join point
Variable fe is bound to type by pointcut declaration.
Variable fe is bound to value at join point.
Advice can access value.
pointcut move(FigureElement fe):
target(fe) &&
(call(void FigureElement.moveBy(int, int)) ||
call(void Line.setP1(Point)) ||
call(void Line.setP2(Point)) ||
call(void Point.setX(int)) ||
call(void Point.setY(int)));
after(FigureElement fe) returning: move(fe) {
<fe is bound to the figure element>
}
parameter
mechanism
See copyright notice
elsewhere in this deck.
27. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Pick up values at join point
Example: the arguments of an intercepted method
Variables x and y are bound to type by pointcut declaration.
Variables x and y are bound to values at join point.
Advice can access arguments.
pointcut move(int x, int y):
args(x, y) &&
call(void FigureElement.moveBy(int, int)
See copyright notice
elsewhere in this deck.
28. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Recall: the earlier aspect
for display updating
aspect DisplayUpdating {
pointcut move():
call(void Line.setP1(Point)) ||
call(void Line.setP2(Point));
after() returning: move() {
Display.update();
}
}
See copyright notice
elsewhere in this deck.
29. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
A revision of the aspect
for display updating
aspect DisplayUpdating {
pointcut move(FigureElement fe):
target(fe) &&
(call(void FigureElement.moveBy(int, int)) ||
call(void Line.setP1(Point)) ||
call(void Line.setP2(Point)) ||
call(void Point.setX(int)) ||
call(void Point.setY(int)));
after(FigureElement fe) returning: move(fe) {
Display.update(fe);
}
}
See copyright notice
elsewhere in this deck.
30. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Intermediate summary
• A design concern is crosscutting (CC) if:
– involves several objects or operations, and
– implemented w/o AOP leads to distant code locations
• doing the same thing
• doing a coordinated single thing
• Expected benefits of aspectual modularization of CC:
– Good modularity, even in the presence of crosscutting concerns
• less tangled code, more natural code, smaller code
• easier to maintain and to evolve
• easier to reason about, debug, change
• more reusable
• more possibilities for generalization, plug and play
See copyright notice
elsewhere in this deck.
31. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Pointcuts cont’d
call(void Point.setX(int))
method/constructor call join points (actual method call)
execution(void Point.setX(int))
method/constructor execution join points (actual running method)
initialization(Point)
object initialization join points
staticinitialization(Point)
class initialization join points (as the class is loaded)
See copyright notice
elsewhere in this deck.
32. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Pointcuts cont’d
• Field reference (“right value”)
Example:
get( int Point.x )
Meaning: match if field x of type int of an object of class
Point is referenced in right-value manner.
• Assignment (“left value”)
Example:
set( int Point.x )
Meaning: match if field x of type int of an object of class
Point is referenced in left-value manner.
See copyright notice
elsewhere in this deck.
33. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Pointcuts cont’d
this( TypeName )
within( TypeName )
withincode( MemberSignature )
any join point at which
currently executing object is an instance of type name
currently executing code is contained within type name
currently executing code is specified methods or constructors
See copyright notice
elsewhere in this deck.
34. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
AspectJ -- How does it work?
Two kinds of classes:
a) Classes compiled by AspectJ
b)Classes not compiled by AspectJ
Two weaving approaches:
a) Generated bytecode contains aspects.
b)Preexisting bytecode is transformed.
36. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Controlling actions at join point
• before before proceeding at join point
• after returning a value at join point
• after throwing a throwable at join point
• after returning at join point either way
• around on arrival at join point gets explicit
control over when&if computation proceeds
See copyright notice
elsewhere in this deck.
37. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
An example to illustrate before/after/around
“Contract checking”
• Pre-conditions
–check whether parameter is valid
• Post-conditions
–check whether values were set
• Condition enforcement
–force parameters to be valid
See copyright notice
elsewhere in this deck.
38. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Before advice: assert preconditions
aspect BoundPointPreCondition {
before(int newX):
call(void Point.setX(int)) && args(newX) {
assert newX >= MIN_X;
assert newX <= MAX_X;
}
before(int newY):
call(void Point.setY(int)) && args(newY) {
assert newY >= MIN_Y;
assert newY <= MAX_Y;
}
}
See copyright notice
elsewhere in this deck.
39. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Pick up values at join point
Example: the arguments of an matched call
before(int newX):
call(void Point.setX(int)) && args(newX) {
assert newX >= MIN_X;
assert newX <= MAX_X;
}
Pointcut parameter,
as used previously,
see “target”.
Bind parameter to
arguments of
matched call
See copyright notice
elsewhere in this deck.
40. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
After advice: assert postconditions
aspect BoundPointPostCondition {
after(Point p, int newX) returning:
call(void Point.setX(int)) &&
target(p) && args(newX) {
assert p.getX() == newX;
}
after(Point p, int newY) returning:
call(void Point.setY(int)) &&
target(p) && args(newY) {
assert p.getY() == newY;
}
}
See copyright notice
elsewhere in this deck.
41. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Around advice: make calls valid
aspect BoundPointEnforcement {
void around(int newX):
call(void Point.setX(int)) && args(newX) {
proceed( clip(newX, MIN_X, MAX_X) );
}
void around(int newY):
call(void Point.setY(int)) && args(newY) {
proceed( clip(newY, MIN_Y, MAX_Y) );
}
private int clip(int val, int min, int max) {
return Math.max(min, Math.min(max, val));
}
}
See copyright notice
elsewhere in this deck.
42. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Context of around advice
For each around advice with the signature
ReturnType around(T1 arg1, T2 arg2, …)
there is a special method with the signature
ReturnType proceed(T1, T2, …)
available only in around advice.
Meaning: “run what would have ran if this advice had not been defined”
See copyright notice
elsewhere in this deck.
44. Control-flow-related pointcuts
cflow( Pointcut )
all join points in the dynamic control flow of any join
point picked out by Pointcut
cflowbelow( Pointcut )
all join points in the dynamic control flow below any
join point picked out by Pointcut
See copyright notice
elsewhere in this deck.
45. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
A revision of the aspect for
display updating
aspect DisplayUpdating {
pointcut move(FigureElement fe):
target(fe) &&
(call(void FigureElement.moveBy(int, int)) ||
call(void Line.setP1(Point)) ||
call(void Line.setP2(Point)) ||
call(void Point.setX(int)) ||
call(void Point.setY(int)));
pointcut topLevelMove(FigureElement fe):
move(fe) && !cflowbelow(move(FigureElement));
after(FigureElement fe) returning: topLevelMove(fe) {
Display.update(fe);
}
}
See copyright notice
elsewhere in this deck.
47. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Another example:
Enforce factory methods makePoint and ...Line
class Figure {
public Line makeLine(Line p1, Line p2) { new Line... }
public Point makePoint(int x, int y) { new Point... }
...
}
aspect FactoryEnforcement {
pointcut illegalNewFigureElement():
(call(Point.new(..)) || call(Line.new(..)))
&& !withincode(* Figure.make*(..));
before(): illegalNewFigureElement() {
throw new Error("Use factory method instead.");
}
}
See copyright notice
elsewhere in this deck.
new is
rejected
We use
wildcards.
48. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
“Compile-time advice”
• Normally pointcuts define points in the actual execution of
the program to be affected by advice.
• We can also define a pointcut just to produce a compile-
time action (typically an error) for any code location that
matches with the pointcut.
See copyright notice
elsewhere in this deck.
49. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
“compile-time advice” as an improvement
Compile error if factory methods are bypassed
class Figure {
public Line makeLine(Line p1, Line p2) { new Line... }
public Point makePoint(int x, int y) { new Point... }
...
}
aspect FactoryEnforcement {
pointcut illegalNewFigureElement():
(call(Point.new(..)) || call(Line.new(..)))
&& !withincode(* Figure.make*(..));
declare error: illegalNewFigureElement():
"Use factory method instead.";
}
}
Special kind
of advice
See copyright notice
elsewhere in this deck.
50. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
“compile-time advice” as an improvement
Compile error if factory methods are bypassed
class Figure {
public Line makeLine(Line p1, Line p2) { new Line... }
public Point makePoint(int x, int y) { new Point... }
...
}
aspect FactoryEnforcement {
pointcut illegalNewFigureElement():
call(FigureElement+.new(..))
&& !withincode(* Figure.make*(..));
declare error: illegalNewFigureElement():
"Use factory method instead.";
}
}
Use
subtyping
wildcard
See copyright notice
elsewhere in this deck.
51. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Display updating with
compile-time factory check
DEMO
See package figures
53. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Inter-type declarations
• An orthogonal concept compared to advice.
• Purpose: add members to existing types:
– (static and instance) fields
– (static and instance) methods, virtual ones included
– …
• Syntax: prefix member name by target class:
For instance:
public int Point.numbersOfPoints;
• New members are visible in aspect only.
See copyright notice
elsewhere in this deck.
54. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Scenario
• An object model for an expression language.
• The classes do not support any operations.
• Add operations for evaluation and pretty-printing.
Solving the expression problem
with inter-type declarations
DEMO
See package expressions
55. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
http://101companies.org/wiki/
Contribution:aspectJ
DEMO
56. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Summary
• More seriously:
• AOP helps avoiding code tangling.
• AOP helps with code modularization.
• AOP supports modularization of crosscutting concerns.
• Less seriously:
• AOP is an intriguing way to break encapsulation.
• AOP is all about tracing and logging.
• AOP has been obsoleted in Cobol.
57. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Byte-code transformation based
on API for byte-code engineering
(A technique for AOP language implementation)
• Approach:
–Load .class file
–Use API to analyze and transform byte code.
–Then, either:
• Load result into JVM, or
• Save result into same or different .class file.
• BTW:
• This is a form of meta-programming!
• This is borderline reflection.
(We are using Java to transform byte code.)
Not covered in the
lecture. This is for
those interested.
58. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Scenario
• Add timing code to a method in an existing .class file.
• Update .class file itself; transformation is effective upon load.
This is demo-only subject. We don’t go any deeper into it.
DEMO
Byte-code engineering
See package bcel
Not covered in the
lecture. This is for
those interested.
59. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Language extension – summary
• Pointcuts
– Pick out join points (“points in the execution of the program”) and
values at those points (arguments, results, exceptions)
• Advice
– Additional action to take at join points in a pointcut
• Before
• After (returning or throwing)
• Around
• Inter-type declarations (aka “open classes”)
• Aspect
– A modular unit of crosscutting behavior
– A generalization of the class form of modular unit
– Comprised of declarations for:
• Advice
• Inter-types
• Pointcuts
• Fields, constructors, and methods
See copyright notice
elsewhere in this deck.
60. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Wildcards in pointcuts
• target(Point)
• target(graphics.geom.Point)
• target(graphics.geom.*) any type in graphics.geom
• target(graphics..*) any type in any sub-package of graphics
• call(void Point.setX(int))
• call(public * Point.*(..)) any public method on Point
• call(public * *(..)) any public method on any type
• call(void Point.setX(int))
• call(void Point.setY(*))
• call(void Point.set*(*))
• call(void set*(*)) any setter
• call(Point.new(int, int))
• call(new(..)) any constructor
“*”is
wild
card
“..”is
m
ulti-partwild
card
See copyright notice
elsewhere in this deck.
61. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Other AspectJ concepts
• Precedence among multiple aspects
• Pointcuts:
–Initialization
–Exceptions
• Reflection for join point
• Abstract pointcuts
• Aspect inheritance
• Subtyping constraints
• ...
See copyright notice
elsewhere in this deck.
62. (C) 2010-2013 Prof. Dr. Ralf Lämmel, Universität Koblenz-Landau (where applicable)
Further reading
• AspectJ/AOP tutorials
[1] Intro at eclipse.org
[2] The seminal “AspectJ overview”
[3] “I want my AOP” (provides sources, too)
[4] “The Paradoxical Success of AOP”
• AspectJ sample code:
– Install AspectJ and go to doc/examples directory
Examples are included in the suite for the present lecture.
– Some additional pointers:
• http://www.aspectprogrammer.org/eclipseaspectj/
• http://mail.eclipse.org/aspectj/sample-code.html
• http://www.cs.wustl.edu/~mdeters/seminar/fall2002/notes/code/
• http://stderr.org/doc/aspectj-doc/examples/