Improve your code using Sonar with Flex plugin


Bad code leads to bugs, hard understanding, hard maintenance. We should really learn to write good code, and with so much open source tools for code analysis we could improve it one step higher. Sonar is a tool for code quality analysis. It helps improving software quality using static analysis tools. It targets Java code, but there are plugins for Flex, C, PHP, .Net and other languages. The Flex plug-in specifically uses FlexPMDFlexMetricsFlexCPD and FlexMojos. In this post we will show you the features that FlexPMD gives us within Sonar. We think that this tool is not really known by Flex developers, so we thought as necessary to show it.

Have you used eclipse for Java developing? It is great when warnings like unused variables and not called methods appear. Well FlexPMD does this for us along with a lot more things. It even can be used inside of Eclipse to show you live reports. There are defined rules that FlexPMD follows to catch issues in the code and bad practices. Great thing is that you can also define your own rules using this flex app

Step 1. So first go and download Sonar. After that download the flex plugin for it. It is a jar file. Now extract the contents of the sonar archive in a desired location, and place the sonar-flex-plugin-x.x.x.jar in extensions\plugins directory of sonar. That’s pretty much what you need to start sonar. By default it uses an embeded Apache Derby database, that you can change to whatever you want in sonar.properties file in conf folder. So now start Sonar. I start it from bin\windows-x86-32\StartSonar.bat as I am a windows user, if you are on other operating system start it from bin\YOUR_SYSTEM\sonar.sh. Have in mind that it takes a while to start so have patience. To assure that it is started open a browser and navigate to http://localhost:9000/

Step 2. Create a flex project. We will create a small test project with one class written really ugly and bad and doesn’t actually do a thing it is here to show you what errors Sonar will find. MyTestComponent.as

public class MyTestComponent extends UIComponent
{
 private var r:Number;

 private var variableNotUsed:Object;

 override protected function updateDisplayList(
			unscaledWidth:Number,
			unscaledHeight:Number):void
 {
  r = Math.random()* 85;

  var child1:UIComponent = new UIComponent();
  addChild(child1);
 }

 public function
 myFunctionWithVeryLongNameAndLotsOfParametersThatDoesNothing(
			p1:String, p2:Number, p3:Object,
			p4:Boolean, p5:int, p6:*,
			p7:Array):void
 {
  return;
 }
}

Step 3. Run analysis built with Maven. For this step you should have Maven 2 on your computer (or Maven 3). Assuming that you have Maven on your computer, as the documentation on the sonar site suggests, add

<profile>
  <id>flex</id>
  <pluginrepositories>
    <pluginrepository>
      <id>flexpmd.opensource.adobe</id>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <name>FlexPMD repository on opensource.adobe.com</name>
      <url>http://opensource.adobe.com/svn/
            opensource/flexpmd/maven-repository/release/</url>
    </pluginrepository>
  </pluginrepositories>
</profile>

this to the settings.xml file of maven located either in $M2_HOME/conf/settings.xml or${user.home}/.m2/settings.xml

And now in the flex project folder add a new file named pom.xml

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemalocation=
                "http://maven.apache.org/POM/4.0.0
                 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelversion>4.0.0</modelversion>  

  <name>Test Sonar Project</name>
  <groupid>com.tgeorgiev</groupid>
  <artifactid>sonar.test</artifactid>
  <version>0.1</version>
  <packaging>pom</packaging>

  <build>
    <sourcedirectory>src</sourcedirectory>
  </build>
  <properties>
    <sonar.language>flex</sonar.language>
    <sonar.dynamicanalysis>false</sonar.dynamicanalysis>
  </properties>
</project>

Now open a console, navigate to the location of your flex project and type “mvn sonar:sonar -Pflex”.

Step 4. After some time of downloading the needed jars for the build and running the analysis task we can check what happened when we open http://localhost:9000/ There should be displayed our project with all the violations that were detected. For our test project we have

Blocker 12
Critical 0
Major 9
Minor 0
Info 1

And when we select to see the Blocker issues for example we see:

Of course, we agree with this result, because it is obvious how bad written this code was.

Do you use Sonar for static analysis of the code, or maybe some other tool? If so, feel free to share

[Original article from: http://tgeorgiev.blogspot.com/2011/03/improve-your-code-using-sonar-with-flex.html]

0 | comment

Comparison of Video Chat Applications


Here at Obecto we are interested in human-to-human interaction and communication, so we decided to make a simple comparison of a few applications that fulfill that role.

In order to have a look at an application, it has to first meet some basic requirements:

- Audio / video chat – we seek rich and realistic human interaction. Simple text and audio lack the immersion we are interested in.

- No special equipment – some solutions rely on the client buying specialized audio/video hardware. We believe that the entry cost for the users should be minimal. A regular webcam may not be the best tool money can buy, but it should be sufficient.

- Cloud / web based – same rule applies here as well, we feel that forcing the user to install additional software is an unnecessary burden.

- Multi party – talking 1 on 1 is limited. We’d rather explore the more general field of group collaboration. Otherwise popular apps like “vChatter” and “Rounds” fail here.

- General purpose – there are some overly complicated enterprise solutions like “Adobe Connect” and “WebEx” that aim at solving the communication problem in the business infrastructure of big corporations. Great, but we seek a simpler and more accessible experience.

- Free

In addition to those strong requirements, our ideal candidate will also:

  • Encourage video communication over texting by all means
  • Allow a decent number of cams on screen, 6 is acceptable, 8 and above is great
  • Not force us to register. If I am a new user and just want to have a quick random chat, I should only type my name.
  • Allow profile creation. We all know how important it feels for people to be able to shape how others see them
  • Have support for popular social networks, so users can import and keep previous contacts
  • Allow us to structure our social interactions in contextual groups – family, colleagues, sexual relationships, hobby friends, etc
  • Seamlessly make our closest contacts easier to find and interact with
  • Give us control over our privacy
  • Allow searching and interacting with people we do not yet know
  • Have sizable user base so it is easy to find people
  • Have NO obscene sexual content. Some people are just pigs. We do not want to encounter them, even by accident.
  • Allow collaborative sharing of documents, presentations, whiteboards, videos, files – for those of us that want to do some actual work together.
  • Do not force us to use any of those features, just allow us if we need to
  • Have interface that make every task require minimal effort on our part
  • Provide a stable experience, no bugs or crashes
  • Provide a quality audio-video experience. We want at least a workaround for the echo cancellation problem that currently plagues the video chats that use flash player
  • Not blind us with adds. Adds are not cool
  • Support some minimal text messaging as well

Now lets have a look at the 4 apps we examined:

Tiny Chat

www.tinychat.com

Entry Cost – registration and Facebook profile is required. The registration process was unnecessarily complicated though – first the name was taken, then it was too long, then it did not allow underscore or spaces … Sure it was our mistake, but man that was an annoying experience.

Social Interactions – you can enter public rooms with unknown people, but cannot search for people or rooms by name or any other means. I can also make my own room and invite Facebook friends there. The problem is that everywhere broadcasting video stream is not the default behaviour of your cam. You have to explicitly start broadcasting. That is a problem, because most people don’t even bother to do that.

Interface is generally simple, few tabs, few buttons. On the other hand there are a couple of serious problems here. The button for creating a chat room is labeled incorrectly and that feature is almost hidden now. There are 2 methods for inviting friends and one of them is hidden. Inviting friends screen does not support name searching or Facebook groups. We also found a bug in the contacts list. On the plus side the app provides push-to-talk functionality for avoiding echo. Generally a dirty solution, but a solution nonetheless.

Features:

  • Supports good profiles
  • Supports MySpace, Twitter, Facebook. Even has a dedicated Facebook application and the experience is surprisingly consistent with the actual Tiny Chat website. That cannot be said for other video chat apps like “Rounds”
  • Contacts cannot be structured, they are one big group instead
  • Regarding privacy during chat you can ban, ignore and report people and have extensive privacy settings outside chat. Gets the job done, but the system feels a bit too overcomplicated.
  • Some sexual obscenity
  • 12 and more webcams at once
  • Supports room text chat
  • User base is big. The app is pretty popular, so it is likely a friend of yours to already have a profile there.
  • Supports collaborative sharing of documents, white boards, playing youtube video or showing your desktop

Tokbox

www.tokbox.com

Entry Cost – the application entry point is a bit hidden in the TokBox site, so it is not explicitly clear this is a video chat platform. Registration is also required but it is surprisingly smooth and straightforward.

Social Interactions – you can search for new people by words in their profiles, but have to add them to your contacts first, then they have to confirm and just then interaction is possible. The application provides numerous ways to join a conversation – sending mail invites, Facebook invites, simple links or through the app interface for other online TokBox users. Comfortable. You can also send video messages to people.

Interface looks simple, minimal clutter makes orientation is easy. Buttons are few, but everything you need is usually 1 click away. Also starting a video chat displays a message that headphones will reduce echo. It does not solve the problem every app has but at least informs the users in advance. At places iconography is a bit unintuitive and we encountered a minor bug in the contact list.

Features:

  • Supports good profiles
  • Supports contacts from Facebook, MySpace, AIM, MSN, Google, Yahoo
  • Contacts are structured by the place they are imported from. Facebook users can arrange their friends in groups and that structure is preserved in TokBox as well. The app also keeps simple and accessible history of recent and upcoming calls. It is still not enough. You cannot be invisible to a group (ex: work superiors) while talking to a friend (ex: my children). In addition to that your closest people are mixed with people you haven’t talked to in ages. Those are problems in all apps and TokBox is on the right track, but still very far from good.
  • Regarding privacy TokBox provides a menu with few simple but effective options. Good job here. On the other hand we did not find a way to kick or ban people out of current chat. Considering the social idea of the app, this is not a problem.
  • No sexual obscenity
  • More than 8 webcams at once
  • Supports 2 different types of text messaging. Texting people in your current video chat is OK, but chatting with people not in video chat is hidden interaction with different interface. We do not approve this inconsistent approach.
  • User base is big. Finding people is not a problem.
  • You can share youtube videos but nothing else.
  • TokBox have paid plans with additional features for video conferencing and businesses.

Chatablanca

www.chatablanca.com

Entry Cost – registration is necessary and the name we chose was taken. We believe more apps should behave like TokBox where an arbitrary number of different people can share the same name.

Social Interactions – you can enter rooms with strangers or make a private rooms and invite friends. There are numerous problems everywhere. Searching for users is overcomplicated. There are 2 separate search modes. While you are offline, you can use few limited search fields and you cannot interact with the search results. While online, you search by user names and the system informs you of the room the person is in and you cannot talk to him if he is not in a room. Another problems is that you can whisper to people during chat, but the system doesn’t give you any feedback on weather you are whispering and to who. You can also rate people and rooms, so everybody has reputation called karma, but it is just a gimmick that does not affect anything else in the system. Generally everything causes confusion here.

Interface is very cartoony and colorful. It can be quite charming if you are 12 or younger. Unfortunately there is an overwhelming number of interactions with small icons on screen, while lots of space stays empty. And some windows are buggy and cannot be closed.

Features:

  • Profiles are very limited, BUT you can customize your chat window and a personal room with accessories and gifts and furniture and gimmicks like that. Those have the same purpose – influence the initial impression you make in others. It speaks more of the aesthetic appeal of a person than his personality and that is a nice change. The bad news is that all those customization accessories are paid feature. And they are too expensive to be worth it.
  • No support for social networks
  • Contacts are one big unstructured group
  • Regarding privacy you can rate, report, block and ignore people – bare minimum here.
  • Clear of sexual obscenity
  • Some adds spoil the fun here
  • Maximum 6 webcams on screen
  • Supports text chat
  • User base size is very small. Combined with the fact that very few people use cams here, actual video chat is a rarity.
  • No sharing support

Chat for free

www.chatforfree.org

Entry Cost – no registration is needed, write a name and start chatting. Unfortunately if the name is taken, you have to pick another one.

Social Interactions – meeting new people is the goal here, you pick a room full of strangers. Ironically no searching function is present. Meeting friends is much more difficult, you have to pass through the public rooms first and then make a private room and invite them. Once in a chat room you can manually turn on and off the webcams of the people you want to interact with. Considering the whole profanity of this app, it is actually a nice idea. You have great flexibility in who you pay attention to and who you ignore, it feels natural. User feedback should be improved for the idea to work, though. Now you have no idea who looks back at you.

Interface is visually primitive, looks like something a student made for a boring web class. Lots of wasted space, icons are very small and difficult to hit, some system notifications are not explicit enough and often missed. The system is not transparent enough and as a result we felt confused most of the time.

Features:

  • User profiling is available for registered users, but it is so limited, that it feels more like a useless gimmick than a full-fledged feature.
  • No support for social networks here.
  • No persistent contacts.
  • No moderation so lots of sexual obscenity.
  • Some adds here and there hurt our eyes.
  • Privacy support – you can create private rooms or ignore people (a hidden interaction), but overall the system does not inform me who can still see me. Not a good job here, only the bare minimum is done
  • Maximum 4 cams on screen.
  • Text Chat is a central feature, we do not approve.
  • User base is small.
  • No file sharing.

Conclusion:

If you can overlook its shortcomings,Tiny Chat gets the job done. TokBox has less features but considerably less problems, so it is our preferred choice. Unfortunately all current solutions are very far away from our ideal candidate. It seems the best application in this field is yet to be created.

Additional References:

http://en.wikipedia.org/wiki/List_of_video_telecommunication_services_and_product_brands #Software_Client_brands
http://en.wikipedia.org/wiki/Web_conferencing

0 | comment

FLit – A Lightweight Flex for Flash Apps


A whole class of RIA applications is getting judiciously ignored by technology vendors like Adobe and Microsoft with the argument that these are way too custom to be utilized in any direction. In the recent years both vendors were focusing their efforts on streamlining the enterprise RIAs, both neglecting the class of applications that was previously the predominant type of RIA. I’m talking about marketing platform applications or Rich User Experiences that are not focused on providing a particular business function. Such applications most typically are not extensively using common UI controls and usually they don’t have to deal with visualizing and manipulating large sets of data in grids and charts.

Adobe have done a great job with Flex (and in the years to come it will hopefully improve)! But Flex comes with a certain weight that makes it nearly impossible to use when we have to develop the class of applications that I want to stress on. The overhead of the framework is too big to be ignored. Our main concern is that this will eventually result in poorer user experiences, because of initial download times and performance overhead. But even if we circumvent this issue in some way (check Vladimir’s article on Totally Custom Preloaders), the SWF will still include code dependencies that are used nowhere in the application. Not to mention that the whole component model is too heavy and complicated and will eventually stand in our way when we have to implement a totally custom experience. This complicated model also requires too much processing power to handle the advanced aspects of the business applications that results in poor performance when you are focusing on the user experience.

Introducing FLit

But on the other hand Flex comes with a set of tools and concept that we really love and still want to be able to use. So what we end up doing in our free time in Obecto is a framework that would enable us to use Flex for really custom Flash apps with a minimal overhead from the framework. And we called this framework FLit – a light-weight Flex for Flash apps. We’ve been developing it as open source from line 1 – so feel free to check out the source from Google Code. There you’ll find some samples too!
Introducing FLit!

Why we call it FLit?

First, FL stands for Flash. We want to build plain AS3 projects without the need to use <mx:Application> as a root object for our apps, and we want it to be as fast and as small as a plain AS3 project could be.

FLit is Flash

How do we use Flex in FLit?

As you might guess FL also stands for Flex, but we only use a small subset of the Flex Framework, like Data Binding and MXML, and nothing else – no UIComponent, no Flex Application. How do we succeed in using MXML inside of a plain AS3 project? Well, this is a topic for another post.

We are also using a concept pretty close to the view contract in Spark, thus enabling the separation of concerns between the designer and the developer.

FLit is Flex

What do we mean by lite?

We understand liteness as to have minimum dependencies between components, thus there are no components in the framework that will induce as dependencies a substantial part of the framework itself.

We understand liteness as the ability to include only those concern that interest you and not having behavior “hard-coded” in the framework. This should be beneficial both as download size as well as performance increase.

We also understand liteness as having a lite build process. Previously when building custom Flash apps we needed to use the designers’ machines and the designers’ productivity tools for the build. With FLit this is not the case – the designer is responsible only in preparing assets that must contain the parts specified in the view contract, so the productivity tools are not used for the build. So, this is also a pretty lite skinning process.
FLit is lite

The current state of FLit

FLit is in early experimentation phase. Maybe this sample somewhat summarizes what’s inside the framework now? You can also check out the sample’s code!
A summary of features:

● light-weight base component
● light-weight base container
● view contract specification through metadata tags
● skin asset
● several layout strategies
● transition manager that supports declarative transitions between states
● tasks (an idea which originated from the GuggaFF) – Sequence and Parallel are also tasks
● declarative input validators
● skin-able button component
● tweening engine

0 | comment