FOSD 2014 Meeting

This last week I was in Schloß Dagstuhl, Germany for the annual Feature-Oriented Software Development (FOSD) 2014 Meeting. This meeting is an event to help young and aspiring research to exchange their work, ideas, and learn about others in the FOSD community.

For me, as the submission of my PhD thesis draws closer, I wanted to present the work that I have been carrying out since the Conference on Generative Programming: Concepts and Experiences (GPCE) 2013, in Indianapolis. This work included information on our extension to allow for runtime GUI adaptation, and also scalability data of the approach.

Schloß Dagstuhl

Schloß Dagstuhl

Schloß Dagstuhl is a wonderful centre for Computer Science, close to the small town of Wadern. It provides a unique atmosphere for Computer Science and Informatics researchers to present and discuss their research in seminars. Only a 5 minute walk away is the remains of the old Dagstuhl Fort. This fort provides a absolutely stunning view of the surrounding area as it exists on the top of hill. What also makes the complex unique is its reliance on trust. For example, none of the accommodation rooms have keys, and can only be locked from the inside. Also, the general available of food/alcohol, with the only requirement that you keep track of what you have, which you then pay for at the end of your stay.

FOSD 2014 Group Photo

FOSD 2014 Group Photo (myself in the middle)

The different talks from everyone at the event were fascinating. There were a range of different FOSD work being presented from testing and verification, analysis of current large SPLs e.g. the Linux Kernel, best practices in FOSD software engineering (Code Smells) etc. For me, it was interesting to be presenting my work on handling the Graphical User Interface in Dynamic Software Product Lines, and see what the community thought of my approach. During the event, I also had the time to discuss other research ideas in the field I’ve had for a while, and I was given some great ideas from people about where I can look for related work. It was just great to be able to discuss my ideas with Christian Kästner, Sven Apel, Martin Erwig, and Norbert Siegmund to just name a few. These conversations were often not during the actual sessions but during dinner, and social events in the evenings. To be honest, I expected I would spend some time alone at night doing work, but there was really never any time, which made the event even more special.

Lastly, as part of the FOSD meetings, there is a competition for the Coolest Tool Name. This was inspired by the Top Gear Cool Wall, and gives us researchers a reason to think of a really cool name for our tools. For the competition I entered my DSPL middleware, which I have named FeatureDroid. The reason why I have called it FeatureDroid is that it fits with two common naming conventions. The first is that often in FOSD tools, the tool names often start with the prefix “Feature”. Also, software designed for the Android mobile platform often end with the suffix “Droid”. So, for me, it seemed a nobrainer to call my middleware “FeatureDroid”. At least from the votes I saw before I left the event it looked like many people thought it was a cool name. Sadly, I didn’t win, but Tassio Vale from Brazil with his tool name SPLice (Software Product Line Integrated Construction Environment) won, justifiably (I voted for it also).

One of the best things I feel I got from FOSD is the increased ties with all the great researchers in my field. I hope this will in time lead to more research cooperation, and hopefully a greater involvement with the FOSD community. I thank the event organisers (Sandro Schulze, Christian Kästner, and Sven Apel) for inviting me, and I look forward to hopefully going to FOSD 2015!

My Time in San Francisco for ICSE 2013

So, late this May, I was in San Francisco, California to present my paper at the 4th International Workshop on Product LinE Approaches in Software Engineering (PLEASE 2013), part of the 35th International Conference for Software Engineering (ICSE 2013).

Presenting my paper

Presenting my paper

The paper I presented was on the topic of Graphical User Interfaces and Dynamic Software Product Lines, in which I set out a number of challenges related to this that I am currently tackling. The workshop was very good in the sense that unlike some workshops that I’ve been to are almost as if a mini conference, where by you give a presentation and view others. This workshop was different in the sense that there was organised ‘speed dating’, as to pair researchers together to discuss possible avenues for research, and get feedback on their own work. This I found was very helpful, and insightful from the people I spent my time with.

The second day of my week was time out of the conference, whereby I spent my time exploring San Francisco. I must have walked at least 20 miles that day! I saw such wonderful sights like Fisherman’s Whalf, the Palace for Fine Arts, Crissy Field, and the Golden Gate Bridge.

Golden Gate Bridge

Golden Gate Bridge

The first day of the main ICSE conference I found almost overwhelming in size. There were over 1,000 people there. The opening keynote was on a topic that is in the news alot nowadays, software patents. It was a great holistic keynote on the history of them, how they work, and the countless legal battles over them for decades (and I thought they have only been a problem for a few years!). I quickly met Sven Apel, a researcher to which I am a fan of his work. We had a great chat over lunch about my research topic. I met other big SPL researchers also like Klaus Schmid, and Christian Kästner, which I got fantastic insight. There were many parallel sessions running during the conference, so sadly I couldn’t attend all, but I am happy with the ones I did go to.

The second day was even better! The keynote was by Tony DeRose, the lead scientist at Pixar Research Group. The keynote presented was on the similarities between film making (animated films), and software development. He firstly discussed how Pixar movies are developed, and linked it with software development. He then spoke about a very large software system that they tried to develop in house using traditional software development methodologies (the waterfall model I believe) and how it just didn’t work. Then he spoke how they applied their film making methodology for developing the software, which went well. There were also great outtake snippets show, that obviously got everyone laughing (physics errors causing funny behaviour). For lunch, they invited students to a get-together lunch with industry, whereby we got to speak with people representing IT companies, and how they got into industry. This I found was great, as got advice by a Googler, a Microsoft Researcher, and a Software Developer at EMC^2. We then had the banquet on a boat that took us out into the bay at night. Got to see some truly beautiful sights. Great food/drink, and dancing!

Banquet Boat Trip

Banquet Boat Trip

For the last day, the keynote was about the issue of scale, and the emergence of ultra large software systems (100M-1B lines of code). Very interesting indeed. There were less sessions and final awards were presented (best paper etc). So I went exploring more of San Francisco, walking through China Town.

Overall, I had a wonderful time at the event, which I would not have been able to do if it was not for a support grant that I was lucky enough to get from the ACM Special Interest Group for Software Engineering (SIGSOFT).

Using the Decorator Pattern with Android

The decorator pattern is a great design pattern enabling developers to add additional behaviour to a particular object. Below is a UML Diagram (from Wikipedia) showing the design pattern. To start, you have a interface that specifies all the methods that you wish to be able to extend. Then you have the concrete component or base class. This is the original class that will be running. The decorators then contain the additional logic that you wish to add the to base object. In this guide, we look at how we can do this at runtime.

UML Diagram of the Decorator Pattern

Decorator Pattern in UML, Wikipedia

 

Using this pattern, we can enable runtime behavioural variations of classes within an Android application by adding and removing decorators from the decorator stack. One problem with Android (and probably other frameworks), this pattern makes use of Object-Oriented concepts like object construction. On Android, many of the essential classes you work with e.g. Activities and Services, you have no control or ability to construct these objects. Other problems can be attributed to the fact that you do not have real (if I am wrong, then it probably is not the recommended way) control of the activity in terms of updating its reference to another (needed for decorator methods to be invoked). In other languages like C++ it is possible to do pointer manipulation, and therefore get around this problem, but in Java, you can’t.

While this method may not be ideal or perfect, it is a workaround that I am using. With that in mind lets have a look at my example code.

Interface

Firstly, we have the interface MainActivityInterface. In this class we have a single method signature pushMeClick(View V); . This method corresponds to the touch event for the button named “Push Me” (Not very imaginative I know, but you get the point).

Activity

Next, we have the core Activity MainActivity, and this class obviously extends Activity, but also implements MainActivityInterface. Within this class we have decorator class MainActivityDecorator member named toplevel. This reference is needed to direct an invocation to the top of the decorator stack. Also we have a TextView object named txtMe, used to show a piece of text in the Window. In the OnCreate(Bundle) method we get the TextView object from the View.

The method pushMeClick(View v) as declared in the interface checks to see if the class is decorated, if it is not, then a core version of that method is invoked (the base behaviour). If the class is decorated, then the decorator version of that method is invoked. We also have a method named toggleClick(View v). When the button named “ToggleDecorator” is clicked, it checks if it the activity has been decorated. If it hasn’t, then the first decorator is added to the stack. If it has been decorated once, then the second is added to the stack. And if the second has been added, it is removed, leaving only the first.

MainActivityDecorator

Next we the add the base decorator class named MainActivityDecorator. In this class we add the base activity MainActivity naming it activity (I know, I really do pick great names). We also add another class member, of the type MainActivityInterface named parent. This member is used in a decorator chain that is more than 1, with the parent object pointing to the next decorator in the chain/stack. In the decorator we have two constructors whereby the activity is used as a parameter and in one of the constructors allow for the parent decorator to be added.

Next we have the method pushMeClick(View v), to which if there is a parent decorator, the parents version of the method is invoked, if there is no parent, the core version in the base activity MainActivity is invoked. Normally in the decorator pattern you do not need this, can just run the super version. But if you do in this, you will get caught up in a recursive loop and cause a Stack Overflow. The reason this is different, is because like we said before, we can’t update the reference of an activity, and therefore the base activity has to handle the method call at first.

We also add a method to the decorator called removeSelf(). This method removes the reference to the activity (to help cut any ties that will not allow it being collected by gc), and return the decorators parent (so the activity updates its toplevel decorator reference).

Each Specific Decorator
Next we add specific decorators which extend MainActivityDecorator, and in example we just call them MainActivity_decorator_one and MainActivity_decorator_two for simplicity. In these classes I have to add a constructor which just calls its super version. I then add a pushMeClick(View v) method in each. In these methods I firstly call the super version first, I then get the TextView from the activity (package protected) and append either “, decorator1” or “, decorator2”.

 

Screenshots:

Obviously, because of the extra instructions needed, this pattern is not computationally free. When I have time, I will try and profile the effect, and update this entry with its effect

You can find this code at https://deansserver.co.uk/gitweb/?p=codeExamples/AndroidDecorator.git;a=summary where you can view and download (click on snapshot on which revision you want).

Enjoy all.

An Openssource Context Engine for Android : The Concepts

Smart phones in recent years have seen high proliferation, allowing more users to stay productive while away from the desktop. This proliferation has seen the increasing amount of mobile applications being developed and becoming available to consumers through centralised application repositories. It has become highly predictable for these devices to have an array of sensors including GPS, accelerometers, digital compass, proximity sensors, sound etc.

Using these sensors with other equipment already found in phones, a wide set of contextual information can be acquired. This contextual information is consumed by context-aware mobile applications. Context aware applications have been described to be intelligent applications that can monitor the user’s context and, in case of changes in this context, consequently adapt their behaviour in order to satisfy the user’s current needs or anticipate the user’s intentions.

Within this article, I will introduce an openssource engine for context acquisition and composition for Android. This engine is primarily intended to be used in two cases:

  1. Packaged with your application, adding your own context components
  2. Packages outside your application, using the engine with your application(s)
Engine Usage

Engine Usage

Ideally, we hope this engine can turn-into a globally used engine that is used by several applications on the device, leading to more efficient resource handling, preserving precious battery power.

Essentially within the engine context types are contained within their own Component. A Component can be seen as an encapsulation of constants, and methods for acquiring & reasoning that context value from the sensor/data resource.

Component Class

Component Class

Where this gets interesting is, in many situations a context wont be based on a single point or single component, but more based on the composition of many contexts. Because of this, its quickly foreseeable that many contexts will be used in more than one Composite context. With this, and the increasing interest to incorporate context-awareness into mobile applications, its important to manage this carefully to prevent wasteful use of resources.

How our engine attempts to help this issue is to work with context tree structures, in which context changes for individual contexts are broadcasted up the tree to the level above for reasoning and so on. These contexts should not need to know who is listening/requesting the context changes, but just broadcast its state on context change and carry on. Using this approach we aim to make contexts completely self contained and generic.

To help explain this tree structure, we can consider the following Composite context:

Example Context

Example Context

In the Connection Composite, there is a Data Sync Composite, which uses the Wifi and 3G context, and the Battery Context. If there is a change in the Wifi or 3G contexts, the Data Sync context receives the broadcast and then checks its own state. If its state has changed, then it then broadcasts its state, which is then received by the Connection context.

These contexts are then listened to by the application, which then can define its different adaptation logic.

Because of this approach, we need not implement Composite Components for each composition, but instead just define this context composition and let the engine do the work, allowing the engine to be more dynamic in its use.

For more details, please see our paper:

Kramer, D., Kocurova, A., Oussena, S., Clark, T., Komisarczuk, P. (2011) An extensible, self contained, layered approach to context acquisitionIn the Proceedings of the 3nd International Workshop on Middleware for Pervasive Mobile and Embedded Computing.

This software is licensed using the Apache License. Please see https://deansserver.co.uk/~dean/software/context-engine-for-android/ for upto date information of where the source is hosted.

Vintage or Tawny? Middleware 2011

This week I was lucky enough to take a trip to the Middleware 2011 Conference in Lisbon, Portugal. The first two days were for the various workshops with the final three days for the main conference. As I landed late that evening, I just checked into the hotel and met Anna for dinner. The hotel I stayed in was the VIP Inn Berna, which so happens to be just across the road from an old bull fighting arena. Overall I have no complains about the hotel, but it was slightly basic, and I wish Internet was included.

M-MPAC Workshop

On the first day, there were a number of workshops to which I attended the PhD symposium in the morning and the M-MPAC workshop (to present a paper) in the afternoon. There were a number of interesting work published at this workshop, though one I wasn’t so sure about, as it was obvious they had not tested their concept on an actual device as they lead me to believe. It’s really this that I dislike in research where if someone claims something works on a mobile device I expect to have been tested on one, not assume it will work, as with mobile devices there are lots of different hardware and software constraints (some deliberate, some not) that can make the concept limiting or in some cases void.

When it came to presenting, I have to admit it was the most nervous presentation I’ve given, not sure exactly why as the paper had been accepted, but I was apprehensive about what the reaction/questions to the paper will be. At the end of the presentation, no quick questions were asked.

At the end of the workshop there was a panel section where all attendees sat in a circle to ask questions about the work presented. One question in particular that interested me was  brought up by David Evans from Cambridge University for the general discussion of all which was the notion of trust, and how can you ensure that context data/information is actually true or honest? Particularly if your context is based on what people submit to a service, it can be misused by different businesses to gain some unfair advantage.

For the presentation slides go to: https://deansserver.co.uk/files/presentations/ContextEngine_presentation.pdf

The Main Conference

The main conference began really the night before it started (if that makes sense?) where there was an organised dinner and few drinks for everyone to meet and socialize. I just continued to the mingle with some of the PhD students, and meet some of the conference delegates.

Most of the focus of the conference was on large datacenters, interoperability, data, and network efficiency. Particular some of the more interesting I found were on a filesystem for Virtual machine image storage for cloud computing systems, a middleware for managing software and hardware modules, and scaling micro blogging services.

At the end of the first day there were poster presentations, where Anna presented her poster and answered questions while delegates walked around. I spoke with a student researching into a context aware middleware for ambient intelligence, as it looked broadly the same as our ContextEngine. The student said that nothing had really been implemented yet and he only has an architecture diagram, to which I suggested he reads our paper and maybe there is room for extension or collaboration. During the poster session there was also roasted chestnuts with some local drink which was made from wine and fruit juice, which was a nice touch to the poster sessions.

Other research at the poster sessions that interested me was a poster on a way of streaming video to mobile devices using telephone masks and ad-hoc networks as a way of lowering the amount of load on the phone masks. This method broadly works on a similar method to Skype, whereby some nodes end up being like super nodes which others connect to, forming a connection chain, instead of each node needing a direct connection to the source.

Social Event

The social event was set at the Oceanario de Lisbon (Lisbon Aquarium). Currently there is an exhibit on different species of turtles, which was really interesting. We were given a tour guide who showed us different turtle species, what they eat etc. I managed to see a couple of them in the tanks, but most I think were out of sight sadly.

After a quick whip around the exhibit, we then went on to wine tasting which was great. I got to try local white, red, and some port. Until that night I never knew there were different styles of port, and I have to say I prefer tawny style port to vintage.

Sightseeing and Exploring

When it came to exploring the local surroundings, I spent two afternoons to try and at least see some of the city. First time round, Anna and I walked all the way from our hotels to the city center, taking photos of different sights on the way. We then progressed up the hill towards the Castelo Sao Jorge to see the castle.

View from Castelo Sao Jorge

View from Castelo Sao Jorge

The Castle was a fantastic place to visit and I would strongly recommend anyone visiting the area to put that on your list! The views from the castle are breathtaking, which are also 360 degrees. The castle itself was an interesting spectacle with history going back to the 12th century. There was in the castle an indoor view of the city, with the use of a hole in the ceiling and something else (perhaps a mirror?) projected a view of the city onto a large bowl like structure, which I found extraordinary.

On the last day of my stay in Lisbon, because Anna and I had checked out of our hotels we decided it would be best to not walk about with all our luggage so we hopped on a tour bus which took us from the city center round the coast line eastwards and round back  seeing the shipping ports, some convents, the first train station in Portugal, the Expo building, some of the newer developments and the parliament building. Overall a good decision, before going to the airport to return home.

Overall I had a fantastic time at the Middleware conference, met some great people, and are very thankful to those that organised and made the conference happen. I do think Lisbon is a very interesting place with lots to see, and would recommend anyone thinking of visiting Portugal to at least take a trip into the city.

DevXS 2011

DevXS

On the 11th November, I went to the JISC event DevXS. As I am a fan of the Dev8D events held every February, and this event is for undergrad and postgrad students I thought it would be a great chance to meet some very talented computer science students from all over the country.

This event was set to cover the whole weekend, and instead of a focus on teaching sessions like Dev8D, it focused purely on competitions in which teams are given 24 hours to implement their projects in a ‘code marathon’.

Friday Night

As there were a few of us going from UWL, I decided rather than travel to Lincoln alone, I’d go with one of my colleagues, which like me wanted to explore some of Lincoln during the day before the evening event registrations. Have to say I was fascinated with the Cathedral, Castle and Roman remains. I think that after the brief look I got, I would like to go back to explore more of the city.

After some exploring, Malte and I went to registration and then went on to get the hotel keys for the hotel room. The evening was then filled with food, socialising and drinking. The organisers created a game called bingo, which required the person to meet people and see if the statements contained in their grid fitted that person and then get a signature. Once all the grid statements were signed you shouted “bingo”, got a badge and got another drink ticket. This proved a very good way of getting everyone to talk and get to know everyone. After the food and drink, me and another of my colleagues went into Lincoln town to experience the nightlife.

Saturday

Have to say I was rather hungover for the morning, but still ready to get going on one of the competitions. Because there were only 4 of us from my institution we decided to form a team named Team UWL. We decided to try and do a bluetooth system for distribution location based information and events, as part of the Freshers App competition. During the day they had an array of sweets and drink which was good, and we got a good lunch. In the course of the day there were several keynotes, but to be perfectly honest other than the magic show in the evening, I’m unsure how many people really were listening to them.

The Venue

What I found amazing was the amount of people still working hard at 2am, the atmosphere was great, and proved a great way of getting help and support from lots of people. I found also the tip to use f.lux given in the midnight keynote to be fantastic. My team managed to keep programming until about 02:30.

Sunday

In a somewhat funny way, the organisers put “Wham – Wake me up before you go-go” on the speakers to wake us up. There was a great breakfast, and a final rush to try and get everything working and finished in time. If you view our git repo featured in the last post you will see the amount of activity increasing closer to the noon deadline.

We then had to pitch the idea of our work to the whole hall, as a way of the everyone including the judges to see our projects explained, in 60 seconds or less. This was a great way of hearing and in some cases seeing some of the fantastic work done by everyone. Sadly my team had trouble getting both parts of the system to work together but we have agreed it would be great to continue the work.

Overall I had a fantastic weekend, met some great people and now looking forward to Dev8D 2012.

Anyone interesting in knowing more about the event, go to http://devxs.org.

Blueyeti – DevXS team challange

Blueyeti

As part of DevXS, Team UWL decided to implement a bluetooth based indoor tracking software which provides location related information to students inside a university, named Blueyeti. The idea behind is to provide a mechanism to deliver information to students based on their location within the campus. This can help new students find out information regarding the place where they are, activities being held, without them needing to check any website/twitterfeed etc.

The software works by the use of a bluetooth application running on several base stations, that listens for bluetooth clients nearby, its then logs the device mac address, and sends its information out.

On the other end, the user has a mobile application running on a smart phone. This is then ideally left to listen for any connections from the base stations (when walking within range), receiving this information and then informing the user.

 

 

The sourcecode repo can be found at: https://gitorious.org/blueyeti/blueyeti

Aspect Oriented Android Development – Tool Integration

In the last post, I demonstrated a really simple example of how to use AspectJ in a Java program. In this post I will be taking it further and showing you how you can easily integrate the AspectJ and Android Development tools, and quickly be able to run Aspects within your Android app.

First thing though, a little theory about why integrating these tools will make your life of AOP much easier. Though programming applications for Android is mostly in Java (you could use C/C++ with the NDK), its doesn’t run Java bytecode. Android uses the Dalvik VM, as apposed to the Java VM. Now, you may ask why do I care? Well it means that you need to use the Android Toolchain. The first image shows the steps it takes to compile an Android application.

Android Build Processes

Android Build Processes

Now you (hopefully) understand the build process of android applications, lets talk about how aspects are compiled and weaved to an application. When compiling an AspectJ project, it firstly compiles Classes and Aspects to Java bytecode. Then an AspectJ Weaver weaves the Aspect bytecode into the Class bytecode. Now this presents a small issue. Within the build process you see that the class files are changed to Dalvik bytecode using the Dex tool. This means that we need to add a process after the javac and before the dx tool, but the use of the AspectJ builder, which compiles and weaves. This does mean that weaving can only be done compile-time and not run-time, because dynamic weaving would only create Java bytecode, not Dalvik.

I’ve seen over the internet examples of this being done using Ant and other scripts. But surely the better approach would be to integrate the AspectJ tools with the Android tools? In this article I will explain how you can do this. bringing AOP to Android development, while allowing you to still use the tools created for AspectJ and Android development.

Firstly you want to have the AspectJ Developement Tools plugin to Eclipse installed (http://eclipse.org/ajdt//), and the Android SDK and the Android Developer Tools plugin for Eclipse installed (http://developer.android.com/sdk/index.html). Once these have been installed, we will start a new android project, calling it HelloAndroidAspect, and call the first activity HelloWorldActivity, adding the code found in the following image:

Activity

Activity

Now we need to make alterations to the project so we can use AspectJ. Firstly you need to add the AspectJ library to the project. You need to include the AspectJ library (aspectjrt) into the project, which can be found in your Eclipse plugins folder. The folder you are looking for is named org.aspectj.runtime_1.x.x.x depending on what version you have. The library you need from that folder is called aspectjrt.jar.

Add AspectJ Library

Add AspectJ Library

Now we have done that we need to make alterations to the projects .project file. This file should be altered outside Eclipse. Within this file we need add the weaver, so that it weaves the bytecode after compilation but before dex and packaging. Also we need to add the nature of the project, so that the project can be seen as an Android project, as well as a AspectJ project. You add the weaving section by adding the following in the <buildSpec> section of the file:

<buildCommand>
<name>org.eclipse.ajdt.core.ajbuilder</name>
<arguments>
</arguments>
</buildCommand>

This buildCommand should be the first in the <buildSpec> section. After adding this, add the following to the <natures> section of the file:

<nature>org.eclipse.ajdt.ui.ajnature</nature>

This nature should be in the middle of the two already there. For reference I have included a whole .project file.

Now, the tools have been integrated for your Android AspectJ project. We now want to right click on the project and click on New->Other. Then go to the AspectJ folder and click on Aspect. In the form just call it Test and add the code in the following image:

Aspect

Aspect

Now, if you compile and run the code you should see the following on your android phone/emulator and in the DDMS LogCat:

Android Screenshot

Android Screenshot

Android DDMS

Android DDMS

 

 

 

As you can see the AspectJ is working with your Android Application. In this example I am running just a fairly static method, but in the next post I will show you how you can do UI manipulation in Aspects, that are required to run on Activity instances.

To download all the source files please Click Here. Feel free to comment if you have problems with it.

An introduction to Aspect Oriented Programming – AspectJ

As I have been finding in my research, software modularity is crucial to maintainable, separable code. Sadly in modern times, Object Oriented Programming though allowing for common class related code to be modularised, it lacks the modularity needed to avoid code scattering (you know when you have some type of functionality found in parts all over a program) and code tangling (when you have different aspects of your program all mixed up in a single method). Anyhow, this is where the use of Aspect Oriented Programming can come in handy. Aspect-Oriented Programming is based around the idea of modularising “aspects” of your program into their own modules, called Aspects (you was expecting that wasn’t you?).

Common examples to how this can be useful is normally in the situations of say security: On particular class methods you need to do some sort of security checks.  Now in OOP, you would probably have this tangled and scattered across all the classes which require this checking. Though at first may feel normal, what happens when you want to alter the security checking? You need to go through all the classes/methods affected, wasting time (which otherwise can be wasted on facebook).

In this post I will be going through a simple example of AspectJ, an AOP extension to Java.

Firstly, to use aspectj you need to download the tools, these can be for a number of IDEs but I recommend the eclipse plugin (http://eclipse.org/ajdt//). Once the plugin is installed and enabled we are all set and ready to begin.

Starting a new AspectJ Project

Once you have the development tools installed and enabled, we will start by starting a new AspectJ project. For this you may find it isn’t in the menu when clicking on “new”, so click on other. We setup normal Java project settings and make a very basic HelloWorld program.

 

Now, for this example I will work with an aspect called “Logger”. The beauty of AOP is being able to crosscut concerns (code tangling and scattering). For instance, if you updating security aspects of your program that were involved all over your program, you would have these parts in lots of different methods, making it difficult to track. With AOP, you can put all these concerns within a single aspect, needing to edit/update that single aspect file…simple!

Within the aspect, we now first specify the pointcut (where do you want to apply advice) in line 8. Then you want to then want to program what advice you want it to execute and when (before, around, or after the pointcut). As you see in the second screenshot, the string ” Aspect” is appended to the string “Hello World” already outputted.

I strongly suggest after trying this simple example you experiment with other more complex examples. In the next post I will tell you guys how this method can be integrated and used within Android programming as an alternative programming paradigm to OOP.

Until next time!

Dev8D 2011

dev8D

For my third year running, I have attended Dev8D. I was hoping that even though I had a great time last year, can it get better? Well the answer to that is yes! Since having a tiny exposure to Scheme, I decided to try some of the code labs learning different functional languages.

On the first day, I attended the Erlang course (session 1 in the morning, and session 2 in the afternoon). This session was excellently done, obviously by a professional trainer. Being I had only done alittle bit of functional programming previously I was surprised how quickly I was able to keep up and start doing stuff. I have to say I am very impressed at Erlang’s ability to deal with processes, I think I spawned 100,000 processes in just over 2 seconds! Also I liked how easy it is to send messages between processes and give responses, no wonder Facebook use it for their chat system. I also went to the Python session, this language was interesting (though I was slightly miffed at the concept of no atomic types and everything is a object idea).

On the second day, I attended the Kinect Hacking session. I really enjoyed this session as it really shows great potential for interesting HCI in many different areas. I didn’t personally get involved but more took a backseat on it, as I didn’t have a Kinect with me and the hacking software seemed slightly ropy and I didn’t want that all on my macbook. I found it great how it mapped out arms, I just wished I had the chance to see the helicopter flying with the Kinect! :(. For the afternoon, I attended the clojure session. This session was great, where by we were taught the basics of clojure using a squareroot example program. This was very interesting and insightful, though have to admit heavy on my head. I have loved learning something new at this event.
Overall this year was somehow even better than last! And I can’t wait until the next.