Featured FREE Whitepapers

What's New Here?


Atlassian JIRA v.4.4 Released

Few days ago Atlassian released a brand new version of its flagship issue and project tracking software: JIRA v. 4.4. Even though it’s a “minor” upgrade it introduces a bunch of great new features, both for users, project administrators and JIRA administrators. Installation Installing and upgrading JIRA standalone has always been easy but the new installer and configuration wizard really make it trivial. If you’re going to perform a new JIRA installation, the installer now takes care of everything, including the creation of a dedicated JIRA user to the registration of JIRA as a service in the operating system. The new configuration wizard lets you configure the external database used by JIRA (are you using one, aren’t you?) with a handy graphical user interface just during the installation phase. Now, manual configuration file editing and JIRA restarts are left to the geeky administrators. If you’re going to perform multiple JIRA installation, you’re going to like the new unattended installation mode that brings even more enterprise-like features to JIRA. Administrators can specify installations settings for JIRA in a dedicated file that can be fed to the installer. To make things even simpler, the JIRA installer is creating one for you when you perform an interactive installation. Just take it and use it as a template: apply the modifications you need and feed it to the installer. If you’re going to perform a JIRA update, something which is very common giving the pace at which Atlassian releases JIRA updates, life’s never been so easy. The installer has an update option that takes care of everything, from the backup of your JIRA home directory to the migration of the most common settings (such as web server configuration and database configuration). User Interface Improvements JIRA v. 4.4 introduces plenty of improvements targeted at users. User Time Zone If users of a single JIRA instance of yours are scattered around the globe, you’re going to appreciate the new User time zone property of the user profile. Users can now specify the time zone they’re working on so that other people can now what to expect when interacting with them.User Time ZoneWorkflow Viewer Users granted the appropriate privilege can now see the current status of an issue in a workflow viewer. Users are now able to quickly and visually identify where an issue is in the workflow.JIRA Workflow ViewerOther Improvements There are many other improvements available, such as:New mobile-friendly email templates. New defaults fields in workflow transition screen, such as Linked Issue. Multiple file selection when uploading attachments. JQL improvements. Refurbished Activity Stream gadget.Please read the official JIRA Release Notes for further information about this version or download a copy of JIRA and try it now. Improvements for the Administrators JIRA v. 4.4 introduces many interesting new features that aim to ease further the administration of JIRA and JIRA projects. The thing I like most is that Atlassian has succeeded in simplifying considerably the administration JIRA interface without losing any of the legendary JIRA configuration flexibility. New Administration Mode The new administration mode replaces the old administration window and its large administration panel on the left side of the window. The administrator can now enter the administration mode and use a totally new user interface. The administration mode welcomes the admin with a new dashboard-like control panel, where links to the administration windows are grouped by subject. I really feel that this new mode, beyond the eye candy of the new windows, provides a feeling of order and clarity that the old administration window was losing over time under the weight of more and more menu items. Workflow Designer This is a groundbreaking feature many, many administrators are going to love. Simply. Up to JIRA 4.3, administrators had to define workflows on tabular views, defining the states of the finite state machine and the transaction between them. Looking at a workflow was not possible, the only way being using pencil and paper to draw the finite state machine. The configuration was somewhat cumbersome, although quite clear with respect to other implementations I’ve seen. With JIRA 4.4, administrators can now define a workflow using a graphical user interface. Drawing the state machine has never been so easy and I expect that workflow implementation and maintenance costs are going to fall heavily with this new tool.JIRA Workflow DesignerImproved Project-Centric Administration JIRA powerful and flexible configuration features always come with some costs: administrators had to fully understand what JIRA schemes are and how they are supposed to be used. The old JIRA configuration interface was schema-centric and sometimes it could be difficult to easily grasp which scheme was supposed to be changed to apply the desired configuration in a project. Things have changed with JIRA 4.4. The new JIRA configuration interface is project-centric: it combines the power provided by JIRA schemes with an easy user interface that helps the administrator perform his tasks, guiding him through the various configuration steps, always starting from a project administration window.Conclusions In my opinion, this is one of the biggest JIRA updates in the recent years. If you think that this is just a minor upgrade, I’m sure you’d be surprised to discover that you’re wrong: maybe such an upgrade would have deserved a major version upgrade. Impressions were overall good. I was pleased to discover that I had not to go through diff-ing configuration files to migrate the Tomcat and database configuration from the old to the new JIRA instance: not only the odds of making a mistake are dumped to zero, but the already short time required to update JIRA has been almost zeroed as well. Both users and admins are going to love the new features introduced with this versions. I sincerely expect that administrators productivity is going to increase, as well as their “disposition” to accept user customization requests for their projects. Customizing JIRA has never been so easy and the new designer brings a totally new way to define new workflows and maintain existing ones. That’s pretty more to it than this, and the best thing you can do is do a JIRA test drive yourself. Here are the complete JIRA 4.4 Release Notes and here’s where you can download JIRA and try it yourself. Reference: Atlassian JIRA v. 4.4 Has Been Released from our JCG partner at The Grey blog. Related Articles :Java Tools: Source Code Optimization and Analysis Developing and Testing in the Cloud Using FindBugs to produce substantially less buggy code 10 Tips for Proper Application Logging...

Selling Yourself: Why? and How!

I know many good developers who are under the impression that they either don’t have to sell themselves, or selling themselves is wrong, but is that really true? First let me clarify by defining what I mean by “selling yourself”. I don’t mean “selling out”, I mean marketing yourself, what you’re doing and what your skills are. Especially to your organization.I don’t need to sell myself, my code speaks for itself. Really? Do you think your pristine code says enough about your skills especially to a non or semi-technical person? Think back about how many products with fancy UIs beat out excellent products with crappy UIs. The simple fact of life is that marketing is effective and required. Imagine creating a really good product and doing no advertising at all because you think that the product speaks for itself. No one will know about how good it is and no one will buy it. The only person who can recognize the quality of your code is another developer of equal or greater talent. Now I realize that someone of lesser skill may be able to recognize that your code is “good”, because it is easy for them to read and it looks pretty, but just like a connoisseur of fine wines can distinguish the small differences that really count, it takes a developer of significant talent to recognize excellent code from good or even great code. Being armed with this knowledge it is easy to see why your code will rarely speak for itself. As a professional developer you have to consider your audience. Mostly the people influencing your career in development are not the highly talented developers who can appreciate your code. In my experience, it is a collective of all developers, project managers, and recruiters. Because of this audience, you must do more than write good code. That good code must be seen and the effects of it must also be seen. It’s wrong to sell myself, it is politics, I don’t do politics, I just write code. If it’s so wrong to do, how come so many of us do it when we are interviewing for a new job? It’s like a courtship when they guy is taking the gal out to dinner and buying her flowers and romancing her, but as soon as they get married where did the romance go? Many of us developers are just like that. We polish our resumé and go out looking for the job, dressed up in a suit and tie, presenting ourselves as professionals, but then we get the job and we settle in, we turn off the charm. It’s not wrong to keep the charm turned on, not only is it not wrong, it’s expected. How about the politics of it? Well yes, there are politics involved in selling yourself, but thinking you can be a technical person and completely ignore politics is a sure way to dead-end you career. Most developers want to reduce the amount of political situations they have to deal with, and I agree with that, but trying to ignore the problem to just make it go away is like trying to make a hungry lion go away by closing your eyes. Even if you are the best hacker in the world people skills are important. It is my strong opinion that every professional, developer or not, should read How to Win Friends and Influence People, by Dale Carnegie. I think there is also a large difference between tasteful marketing of a product or service and offensive or annoying marketing. Just like the XXX spam mail that shows up in your email unrequested, a developer can market themselves in an unsolicited and annoying way. On the the other hand… There is a right or good way to market yourself. Selling yourself tastefully takes some practice and thought. It really is a soft skill that must be acquired and thought about. It takes some amount of social engineering. Like all products, the better the product, the easier it is to market. Here are some tips I find useful for marketing yourself as a professional developer. 1. Create a weekly report of exactly what work you did each day of the week. The report should include a brief description of the major and minor accomplishments each day and perhaps a summary or highlight of any major accomplishments you did. Especially mention mentoring or helping other people. Send the weekly report voluntarily to your boss and CC your boss’s boss as an FYI. I know it’s a bit difficult to find a good way to CC your boss’s boss, but try to find a good way to do it that is tasteful. (For example, something like “I thought you might also like to receive these weekly reports I am sending out just as a FYI.” ) The benefit of doing this is two-fold. First, you will be highlighting all the good work you are doing to your boss and his boss, in a way that isn’t like “tooting your own horn.” Second, you will provide yourself a documented history of work you accomplished which is useful for reviews, protection against wrongful termination, and resume building. 2. Update your resumé periodically, and your public profiles, LinkedIn etc. By keeping your resumé constantly up-to-date, you are ready to find a job quickly if you become unemployed. This will give you a safety net, which will allow you to feel more comfortable being a professional and sometimes saying “no”. In addition, opportunities will come to you when you have your public profiles up-to-date. 3. Get a library of books and put them up for display. (Read them, or you are just faking it.) If you have a mountain of books you have read, but they are sitting in a box at home, they are not marketing you. When I walk into a developer’s office and I look at his or her books I can tell many things about them already. When managers walk by and they see someone with a large number of programming books, it says something to them about your dedication and knowledge. 4. If you have certifications frame them and put them on your wall, or on your cube. Yeah, I know it may seem cheesy, and you may get poked fun at a bit. But take it light-hearted and don’t brag about the certification, deep down inside the people poking jabs about certs really are feeling threatened they don’t have certifications. 5. Help other developers, all the time. Be they guy that everyone asks their development questions to. When someone needs help figuring something out, volunteer. Help train the junior developers. Doing this will give you a reputation of being knowledgeable and helpful. Answering questions on Stackoverflow counts towards this if you have time. 6. Prepare some power points and offer to give demonstrations or presentations on a project you did, or a new technology or methodology you want to introduce. 7. Be vocal. Make sure that you are speaking up. In meetings, in design sessions, in general have something to say. Make sure you are not talking for the sake of talking, but contribute information and ideas. Doing this will help demonstrate your knowledge and critical thinking. 8. Make occasional visits to the boss. Make sure you are being seen by management every once in a while and when you do, mention new ideas you have of ways to make your team better or more efficient. Offer to spearhead the implementation of those ideas. 9. Take some risks in order to make things better. Sometimes you have to bet big to win big. Sometimes you have to do a controversial thing, or not get permission before you do something that will greatly improve development quality or output. Increasing developer quality through creating developer tools is very valuable and very visible. Just make sure if you take a risk that if you accomplish it, it will have high returns for the company. People who do things without permission that are stupid get fired. People who do things without permission that are brilliant get praised. The bottom line is if you’re not selling your self, you’re selling yourself short. Reference: Selling Yourself from our JCG partner John Sonmez at Making the Complex Simple blog. Related Articles :Hate Java? You’re fighting the wrong battle. Save money from Agile Development Selecting a new programming language to learn Things Every Programmer Should Know...

Android Game Development – Particle Explosion

Ever wondered how explosions are created? Let’s take a little detour and try to implement a basic particle explosion. An explosion is nothing more than a bunch of particles (be them pixels, small shapes or images) scattered across the screen, originating from a single point. Not all the time but mostly and for the sake of simplicity we’ll assume that all particles originate from a single point. Just think of fireworks. A tiny little rocket shoots up and explodes into hundreds of sparkling little stars that fade out as they fall down. What happens is that a huge force in the center of the rocket rips the body apart (thus creating particles) and scatters them randomly around the point of explosion. To make it simple we’ll create a few particles, we will place them in one place (the origin) and give them random forces. A force is a vector quantity. It means that it has magnitude and direction. The magnitude will determine its speed and its direction will tell the particle which way to go. The ParticleThe class file: public class Particle {public static final int STATE_ALIVE = 0; // particle is alive public static final int STATE_DEAD = 1; // particle is deadpublic static final int DEFAULT_LIFETIME = 200; // play with this public static final int MAX_DIMENSION = 5; // the maximum width or height public static final int MAX_SPEED = 10; // maximum speed (per update)private int state; // particle is alive or dead private float width; // width of the particle private float height; // height of the particle private float x, y; // horizontal and vertical position private double xv, yv; // vertical and horizontal velocity private int age; // current age of the particle private int lifetime; // particle dies when it reaches this value private int color; // the color of the particle private Paint paint; // internal use to avoid instantiation }The particle is nothing more than a little rectangle (this can be an image, circle or any other shape, but in our case we use a rectangle) with a few properties. It has a state. This indicates whether the particle is alive or dead. A particle is alive when its color is not black (it hasn’t faded) and its age hasn’t reached its lifetime. More on this a bit later. It has a position. It’s position in a 2D coordinate system is represented by 2 points: x and y. It also has a speed and a direction. As you recall speed is a vector so it has 2 components in 2D. In 3D it will also have the z component but we stay in 2D for now. To keep it simple now we add two properties for this. vx and vy The age of the particle is it’s 0 in the beginning and is incremented at each update. The lifetime is the maximum age a particle can reach before it dies. The rest are color and paint. These are for drawing only. If you recall the previous entries, the game update is nothing more than calling the update methods of every entities in the game and displaying them. The update method of the particle is pretty simple. But first we need to create the particle: public Particle(int x, int y) { this.x = x; this.y = y; this.state = Particle.STATE_ALIVE; this.widht = rndInt(1, MAX_DIMENSION); this.height = this.widht; this.lifetime = DEFAULT_LIFETIME; this.age = 0; this.xv = (rndDbl(0, MAX_SPEED * 2) - MAX_SPEED); this.yv = (rndDbl(0, MAX_SPEED * 2) - MAX_SPEED); // smoothing out the diagonal speed if (xv * xv + yv * yv > MAX_SPEED * MAX_SPEED) { xv *= 0.7; yv *= 0.7; } this.color = Color.argb(255, rndInt(0, 255), rndInt(0, 255), rndInt(0, 255)); this.paint = new Paint(this.color); }Check the creation of a particle and it should be straight forward. You will notice that a particle is created at position x,y. The state is set to alive. We want to randomise the size of the rectangles because an explosion creates particles in different sizes and shapes but we’ll just randomise the size and colour. I have written a few helper methods that give me random numbers, for this check the complete source code. Next the lifetime is set. Every particle will have the same lifetime. The age is 0 of course as the particle has just been born. Next is the interesting bit. It’s very amateurish. To set the speed I have used 2 random numbers for the 2 components of the speed vector (vx and vy). The smoothing is needed because if both components are near the maximum value then the resulting magnitude will be over the max speed. You could use simple trigonometric functions with a random degree instead of this. The las thing to set is the color which again is randomised. There you have it. The update() method for the particle. public void update() { if (this.state != STATE_DEAD) { this.x += this.xv; this.y += this.yv;// extract alpha int a = this.color >>> 24; a -= 2; // fade by 2 if (a <= 0) { // if reached transparency kill the particle this.state = STATE_DEAD; } else { this.color = (this.color & 0x00ffffff) + (a << 24); // set the new alpha this.paint.setAlpha(a); this.age++; // increase the age of the particle } if (this.age >= this.lifetime) { // reached the end if its life this.state = STATE_DEAD; } } }It’s pretty simple. Every update, the position is set according to the speed and the alpha component of the particle’s color is decremented. In other words the particle is being faded. If the age exceeded the lifetime or the opacity is 0 (that means that it is completely transparent) the particle is declared dead. If you wonder about the magic with colours, it is quite simple once you get the bitwise operators. Don’t worry, I’m rubbish as well, just make sure you know where to look. Here is a good explanation of colour components and how to use bitwise operators to manipulate them: http://lab.polygonal.de/2007/05/10/bitwise-gems-fast-integer-math/. It’s faster than using the objects but you can safely use the android methods too. Just as a side note on colours You can specify colours in Android as an int. If you’re familiar with rgb and argb that is great. rgb is 24 bits color while argb is 32 bits. It also has the alpha component which is transparency/opacity. Opacity values: 0 = transparent, 255 = completely opaque. To represent an int in hex you just prefix it with 0x. A color in hex is simple: 0x00FF00 is green for example. The pattern is: 0xRRGGBB (Red, Green, Blue). Now to add the alpha you will add it to the beginning. 0xAARRGGBB. Because it is in hex, the values are between 00 and FF. 0 being 0 and FF being 255 in decimal. When you create a colour out of components like color(a, r, g, b) (for example: new Color(125, 255, 0, 0) creates a semi transparent red), you can simply create it with an integer expressed in hex like this: new Color(0x80FF0000); This is how you would extract the components of an argb colour. int color = 0xff336699; int alpha = color >>> 24; int red = color >>> 16 & 0xFF; int green = color >>> 8 & 0xFF; int blue = color & 0xFF;The draw() method is simple again. public void draw(Canvas canvas) { paint.setColor(this.color); canvas.drawRect(this.x, this.y, this.x + this.widht, this.y + this.height, paint); }At this stage try to create some particles in your game panel and see what happens. The Explosion The explosion is nothing more than hundreds of particles originating from one place, the origin.In the image above you see the first 4 updates of a simple explosion. All the particles have the same speed but they spread out in different directions. Each circle is one update. The main properties of an explosion are: public class Explosion {public static final int STATE_ALIVE = 0; // at least 1 particle is alive public static final int STATE_DEAD = 1; // all particles are deadprivate Particle[] particles; // particles in the explosion private int x, y; // the explosion's origin private int size; // number of particles private int state; // whether it's still active or not }It contains an array of particles. The size is the number of particles. An explosion is alive if it has at least one particle alive. The update is extremely simple. It iterates through all the particles and calls the update() method on each particle. The draw() ditto. In our application we will create explosions on the screen where we touch it. The constructor is very simple: public Explosion(int particleNr, int x, int y) { Log.d(TAG, "Explosion created at " + x + "," + y); this.state = STATE_ALIVE; this.particles = new Particle[particleNr]; for (int i = 0; i < this.particles.length; i++) { Particle p = new Particle(x, y); this.particles[i] = p; } this.size = particleNr; }The array of particles is being filled at the touch down position. In our application we will allow up to 10 explosions. So in the MainGamePanel we declare an array of explosions. private Explosion[] explosions;In the surfaceCreated method we instantiate the array and fill it with null. explosions = new Explosion[10]; for (int i = 0; i < explosions.length; i++) { explosions[i] = null; }The onTouchEvent is where we create explosions. public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { // check if explosion is null or if it is still active int currentExplosion = 0; Explosion explosion = explosions[currentExplosion]; while (explosion != null && explosion.isAlive() && currentExplosion < explosions.length) { currentExplosion++; explosion = explosions[currentExplosion]; } if (explosion == null || explosion.isDead()) { explosion = new Explosion(EXPLOSION_SIZE, (int)event.getX(), (int)event.getY()); explosions[currentExplosion] = explosion; } } return true; }What we do is iterate through the explosions and when we find the first null (this means we never used it for an instance) or the first dead explosion we create a new one at the touch position. The update and render methods are straight forward. Iterate through the explosions and if they are not null and are alive then call their update and draw methods respectively. In the final code I added a border for the screen as the wall and added a basic collision detection for the particles so they bounce off the walls. The wall is being transmitted as a reference and the update method checks for collision with it. Use it as an exercise and remove the collision and try attaching an image to the particle instead of being a rectangle. To create explosions just click on the screen. It should look like this:Explore the code and have fun. Download it here (android.particles.tgz). Reference: Particle Explosion with Android from our JCG partner Tamas Jano from “Against The Grain” blog. Do not forget to check out our new Android Game ArkDroid (screenshots below). You feedback will be more than helpful!Related Articles:Android Game Development Tutorials Introduction Android Game Development – The Game Idea Android Game Development – Create The Project Android Game Development – A Basic Game Architecture Android Game Development – A Basic Game Loop Android Game Development – Displaying Images with Android Android Game Development – Moving Images on Screen Android Game Development – The Game Loop Android Game Development – Measuring FPS Android Game Development – Sprite Animation Android Game Development – Design In-game Entities – The Strategy Pattern Android Game Development – Using Bitmap Fonts Android Game Development – Switching from Canvas to OpenGL ES Android Game Development – Displaying Graphical Elements (Primitives) with OpenGL ES Android Game Development – OpenGL Texture Mapping Android Game Development – Design In-game Entities – The State Pattern Android Games Article Series...

Android Interview Questions and Answers

Here are some basic Android related interview questions and their respective answers. What is Android? Android is a stack of software for mobile devices which includes an Operating System, middleware and some key applications. The application executes within its own process and its own instance of Dalvik Virtual Machine. Many Virtual Machines run efficiently by a DVM device. DVM executes Java languages byte code which later transforms into .dex format files. What is an Activity? A single screen in an application, with supporting Java code. What is an Intent? A class (Intent) which describes what a caller desires to do. The caller will send this intent to Android’s intent resolver, which finds the most suitable activity for the intent. E.g. opening a PDF document is an intent, and the Adobe Reader apps will be the perfect activity for that intent (class). What is a Sticky Intent? sendStickyBroadcast() performs a sendBroadcast(Intent) known as sticky, i.e. the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver(BroadcastReceiver, IntentFilter). In all other ways, this behaves the same as sendBroadcast(Intent). One example of a sticky broadcast sent via the operating system is ACTION_BATTERY_CHANGED. When you call registerReceiver() for that action — even with a null BroadcastReceiver — you get the Intent that was last broadcast for that action. Hence, you can use this to find the state of the battery without necessarily registering for all future state changes in the battery. How the nine-patch Image different from a regular bitmap? Alternatively, what is the difference between nine-patch Image vs regular Bitmap Image? It is one of a resizable bitmap resource which is being used as backgrounds or other images on the device. The NinePatch class allows drawing a bitmap in nine sections. The four corners are unscaled; the middle of the image is scaled in both axes, the four edges are scaled into one axis. What is a resource? A user defined JSON, XML, bitmap, or other file, injected into the application build process, which can later be loaded from code. How will you record a phone call in Android? or How to handle an Audio Stream for a call in Android? Permission.PROCESS_OUTGOING_CALLS: Will Allow an application to monitor, modify, or abort outgoing calls. So using that permission we can monitor the Phone calls. Does Android support the Bluetooth serial port profile? Yes. Can an application be started on powerup? Yes.  What is the APK format? The APK file is compressed AndroidManifest.xml file with extension .apk. It also includes the application code (.dex files), resource files, and other files which are compressed into a single .apk file. How to Translate in Android? The Google translator translates the data of one language into another language by using XMPP to transmit data. You can type the message in English and select the language which is understood by the citizens of the country in order to reach the message to the citizens. Describe Briefly the Android Application Architecture Android Application Architecture has the following components:Services like Network Operation Intent – To perform inter-communication between activities or services Resource Externalization – such as strings and graphics Notification signaling users – light, sound, icon, notification, dialog etc. Content Providers – They share data between applicationsWhat is needed to make a multiple choice list with a custom view for each row? Multiple choice list can be viewed by making the CheckBox android:id value be “@android:id /text1″. That is the ID used by Android for the CheckedTextView in simple_list_item_multiple_choice. What dialog boxes are supported in android?Android supports 4 dialog boxes:AlertDialog: An alert dialog box supports 0 to 3 buttons and a list of selectable elements, including check boxes and radio buttons. Among the other dialog boxes, the most suggested dialog box is the alert dialog box. ProgressDialog: This dialog box displays a progress wheel or a progress bar. It is an extension of AlertDialog and supports adding buttons. DatePickerDialog: This dialog box is used for selecting a date by the user. TimePickerDialog: This dialog box is used for selecting time by the user.General Android questionsThe Activity life cycle is must. Different phases of Activity Life cycle. For example: when and how the activity comes to foreground? Knowledge on AndroidManifest file, For example: Why do we need this file, What is the role of this file in Android app development. Different Kinds of Intents Different Kinds of Context Different Storage Methods in android Kinds of Log debugger and Debugger Configuration How to debug the application on real device. How do you ensure that the app design will be consistent across the different screen resolutions Thread concepts also plus points as we deal with the treads more. Can you able to build custom views and how? How to create flexible layouts, For example to place English, Chinese fonts. What is localization and how to achieve? What are 9-patch images How to avoid ANR status How to do Memory management Inter Process Communication (IPC) What is onCreate(Bundle savedInstanceState), Have you used savedInstanceState when and why? Fragments in an Activity When to use a service How to use a broadcast receiver and register it both in the manifest and in code Intent filters The types of flags to run an application How to do data intensive calculations using threads Passing large objects (that can’t be passed via intents and shouldn’t be serialized) via a service Binding to a service and the service lifecycle How to persist data (both savedInstanceState and more permanent ways)Let us know if you have any other questions that should be added in the list. And don’t forget to share! Reference: Android Interview Questions And Answers from our JCG partner at the Android-Tutorials blog. Related Articles :Incorrect Core Java Interview Answers Android Game Development Tutorials Things Every Programmer Should Know “Android Full Application Tutorial” series Embracing the Android awesomeness: A quick overview...

Best Of The Week – 2011 – W31

Hello guys, Time for the “Best Of The Week” links for the week that just passed. Here are some links that drew JavaCodeGeeks attention: * Java SE 7 Released: First Major Update Since December 2006: Big news for Java this week, the new Java SE 7 is released. New features include the Fork/Join Framework, the “try-with-resources” statement, switch statement for Strings, new APIs for file system access, the first new bytecode instruction (invokedynamic) and more. * Web 2.0 Killed the Middleware Star: An article discussing middleware (JMS, ESB, etc.) and how it is coming out of the picture for web 2.0 applications. As the author states, between cloud computing models and Web 2.0 having been forced to solve the shared messaging concept without middleware – and having done so successfully – that middleware as a service is obsolete. * QoS for Applications: A Resource Management Framework for Runtimes: A very interesting article that describes how we can use concepts used in the networking field in order to implement resources management in runtimes and containers. Using a similar framework we may be able to provide Quality of Service for applications all running in the same container. * Parallel programming in Java: A small interview around the Ateji PX Java extensions, an extension of Java that makes parallel programming easier. Parallelism is expressed by simple composition operators and multiple models are supported. * Functional thinking: Immutability: Immutability is one of the building blocks of functional programming.This great article explains how to implement immutability in Java and Groovy. * The Principles of Good Programming: Title says it all. Among them are the Don’t Repeat Yourself principle, the Open/Closed, the Single Responsibility and others. Also check The top 9+7 things every programmer or architect should know and Things Every Programmer Should Know. * Why is JBoss AS 7 so fast?: This article explains why JBoss AS 7 is so fast at startup. Except for the modular approach used, the reason is the effective parallelization of work based on Ahmdahl’s law. This is leveraged by using an entirely new, highly performant, and manageable core architecture. * What’s New in MySQL 5.6: An overview of the new features in MySQL 5.6 which provides new performance and scalability improvements. Among them are a NoSQL Interface via memcache, explicit partition selection, multi-threaded slaves for replication etc. * Persistent Model Framework for Android: This article explains how to use Androrm, a persistent relational data mapper especially for Android, which can alleviate the pain of writing ContentProviders and SQL queries. Also check out our Android development Tutorials. That’s all for this week. Stay tuned for more, here at JavaCodeGeeks. Related Articles:Best Of The Week – 2011 – W30 Best Of The Week – 2011 – W29 Best Of The Week – 2011 – W28 Best Of The Week – 2011 – W27 Best Of The Week – 2011 – W26 Best Of The Week – 2011 – W25 Best Of The Week – 2011 – W23 Best Of The Week – 2011 – W22 Best Of The Week – 2011 – W21 Best Of The Week – 2011 – W20...

C++ or Java, which is faster for high frequency trading?

Overview There are conflicting views as to what is the best solution for high frequency trading. Part of the problem is that what is high frequency trading varies more than you might expect, another part is what is meant by faster. My View If you have a typical Java programmer and typical C++ programmer, each with a few years experience writing a typical Object Oriented Program, and you give them the same amount of time, the Java programmer is likely to have a working program earlier and will have more time to tweak the application. In this situation it is likely the Java application will be faster. IMHO. In my experience, Java performs better at C++ at detecting code which doesn’t need to be done. esp micro-benchmarks which don’t do anything useful. ;) If you tune Java and C++ as far as they can go given any amount of expertise and time, the C++ program will be faster. However, given limited resources and in changing environment a dynamic language will out perform. i.e. in real world applications. In the equities space latency you need latencies sub-10 us to be seriously high frequency. Java and even standard OOP C++ on commodity hardware is not an option. You need C or a cut down version of C++ and specialist hardware like FPGAs, GPUs. In FX, high frequency means a latencies of sub-100 us. In this space C++ or a cut down Java (low GC) with kernel bypass network adapter is an option. In this space, using one language or another will have pluses and minuses. Personally, I think Java gives more flexibility as the exchanges are constantly changing, assuming you believe you can use IT for competitive advantage. In many cases, when people talk about high frequency, esp Banks, they are talking sub 1 ms or single digit ms. In this space, I would say the flexibility/dynamic programming of Java, Scala or C# etc would give you time to market, maintainability and reliability advantages over C/C++ or FPGA.The problem Java faces The problem is not in the language as such, but a lack of control over caches, context switches and interrupts. If you copy a block of memory, something which occurs in native memory, but using a different delay between runs, that copy gets slower depending on what has happened between copies. The problem is not GC, or Java as neither of these play much of a part. The problem is that part of the cache has been swapped out and the copy itself takes longer. This is the same for any operation which accesses memory. e.g. accessing plain objects will also be slower. private void doTest(Pauser delay) throws InterruptedException { int[] times = new int[1000 * 1000]; byte[] bytes = new byte[32* 1024]; byte[] bytes2 = new byte[32 * 1024]; long end = System.nanoTime() + (long) 5e9; int i; for (i = 0; i < times.length; i++) { long start = System.nanoTime(); System.arraycopy(bytes, 0, bytes2, 0, bytes.length); long time = System.nanoTime() - start; times[i] = (int) time; delay.pause(); if (start > end) break; } Arrays.sort(times, 0, i); System.out.printf(delay + ": Copy memory latency 1/50/99%%tile %.1f/%.1f/%.1f us%n", times[i / 100] / 1e3, times[i / 2] / 1e3, times[i - i / 100 - 1] / 1e3 ); }The test does the same thing many times, with different delays between performing that test. The test spends most of its time in native methods and no objects are created or discarded as during the test. YIELD: Copy memory latency 1/50/99%tile 1.6/1.6/2.3 us NO_WAIT: Copy memory latency 1/50/99%tile 1.6/1.6/1.6 us BUSY_WAIT_10: Copy memory latency 1/50/99%tile 3.1/3.5/4.4 us BUSY_WAIT_3: Copy memory latency 1/50/99%tile 2.7/3.0/4.0 us BUSY_WAIT_1: Copy memory latency 1/50/99%tile 1.6/1.6/2.6 us SLEEP_10: Copy memory latency 1/50/99%tile 2.3/3.7/5.2 us SLEEP_3: Copy memory latency 1/50/99%tile 2.7/4.4/4.8 us SLEEP_1: Copy memory latency 1/50/99%tile 2.8/4.6/5.0 us The typical time (the middle value) it takes to perform the memory copy varies between 1.6 and 4.6 us depending on whether there was a busy wait or sleep for 1 to 10 ms. This is a ratio of about 3x which has nothing to do with Java, but something it has no real control over. Even the best times vary by about 2x.The code ThreadlatencyTest.javaConclusion In ultra-high frequency, the core engine will be more C, assembly and custom hardware than OOP C++ or Java. In markets where the latency requirements of the engine are less tight C++ and Low GC Java become an option. As latency requirement become less tight, Java and other dynamic languages can be more productive. In this situation, Java is faster to market so you can take advantages of changes in the market/requirements. Reference: C++ or Java, which is faster for high frequency trading? from our JCG partner Peter Lawrey at the Vanilla Java. Related Articles:Low GC in Java: Use primitives instead of wrappers Java Lambda Syntax Alternatives How does JVM handle locks Erlang vs Java memory architecture Java Fork/Join for Parallel Programming Java Best Practices Series How to get C like performance in Java...

Java Tools: Source Code Optimization and Analysis

Below is a list of some tools that can help you examine your Java source code for potential problems: 1. PMD from http://pmd.sourceforge.net/ License: PMD is licensed under a “BSD-style” license PMD scans Java source code and looks for potential problems like: * Possible bugs – empty try/catch/finally/switch statements * Dead code – unused local variables, parameters and private methods * Suboptimal code – wasteful String/StringBuffer usage * Overcomplicated expressions – unnecessary if statements, for loops that could be while loops * Duplicate code – copied/pasted code means copied/pasted bugs You can download everything from here, and you can get an overview of all the rules at the rulesets index page. PMD is integrated with JDeveloper, Eclipse, JEdit, JBuilder, BlueJ, CodeGuide, NetBeans/Sun Java Studio Enterprise/Creator, IntelliJ IDEA, TextPad, Maven, Ant, Gel, JCreator, and Emacs. 2. FindBug from http://findbugs.sourceforge.net/ License: L-GPL FindBugs, a program which uses static analysis to look for bugs in Java code. And since this is a project from my alumni university (IEEE – University of Maryland, College Park – Bill Pugh) , I have to definitely add this contribution to this list. 3. Clover from http://www.cenqua.com/clover/ License: Free for Open Source (more like a GPL) Measures statement, method, and branch coverage and has XML, HTML, and GUI reporting. and comprehensive plug-ins for major IDEs. * Improve Test Quality * Increase Testing Productivity * Keep Team on Track Fully integrated plugins for NetBeans, Eclipse , IntelliJ IDEA, JBuilder and JDeveloper. These plugins allow you to measure and inspect coverage results without leaving the IDE. Seamless Integration with projects using Apache Ant and Maven. * Easy integration into legacy build systems with command line interface and API. Fast, accurate, configurable, detailed coverage reporting of Method, Statement, and Branch coverage. Rich reporting in HTML, PDF, XML or a Swing GUI Precise control over the coverage gathering with source-level filtering. Historical charting of code coverage and other metrics. Fully compatible with JUnit 3.x & 4.x, TestNG, JTiger and other testing frameworks. Can also be used with manual, functional or integration testing. 4. Macker from http://innig.net/macker/ License: GPL Macker is a build-time architectural rule checking utility for Java developers. It’s meant to model the architectural ideals programmers always dream up for their projects, and then break — it helps keep code clean and consistent. You can tailor a rules file to suit a specific project’s structure, or write some general “good practice” rules for your code. Macker doesn’t try to shove anybody else’s rules down your throat; it’s flexible, and writing a rules file is part of the development process for each unique project. 5 EMMA from http://emma.sourceforge.net/ License: EMMA is distributed under the terms of Common Public License v1.0 and is thus free for both open-source and commercial development. Reports on class, method, basic block, and line coverage (text, HTML, and XML). EMMA can instrument classes for coverage either offline (before they are loaded) or on the fly (using an instrumenting application classloader). Supported coverage types: class, method, line, basic block. EMMA can detect when a single source code line is covered only partially. Coverage stats are aggregated at method, class, package, and “all classes” levels. Output report types: plain text, HTML, XML. All report types support drill-down, to a user-controlled detail depth. The HTML report supports source code linking. Output reports can highlight items with coverage levels below user-provided thresholds. Coverage data obtained in different instrumentation or test runs can be merged together. EMMA does not require access to the source code and degrades gracefully with decreasing amount of debug information available in the input classes. EMMA can instrument individial .class files or entire .jars (in place, if desired). Efficient coverage subset filtering is possible, too. Makefile and ANT build integration are supported on equal footing. EMMA is quite fast: the runtime overhead of added instrumentation is small (5-20%) and the bytecode instrumentor itself is very fast (mostly limited by file I/O speed). Memory overhead is a few hundred bytes per Java class. EMMA is 100% pure Java, has no external library dependencies, and works in any Java 2 JVM (even 1.2.x). 6. XRadar from http://xradar.sourceforge.net/ License: BSD (me thinks) The XRadar is an open extensible code report tool currently supporting all Java based systems. The batch-processing framework produces HTML/SVG reports of the systems current state and the development over time – all presented in sexy tables and graphs. The XRadar gives measurements on standard software metrics such as package metrics and dependencies, code size and complexity, code duplications, coding violations and code-style violations. 7. Hammurapi from Hammurapi Group License: (if anyone knows the license for this email, let us know) Hammurapi is a tool for execution of automated inspection of Java program code. Following the example of 282 rules of Hammurabi’s code, we are offered over 120 Java classes, the so-called inspectors, which can, at three levels (source code, packages, repository of Java files), state whether the analysed source code contains violations of commonly accepted standards of coding. Relevant Links: http://en.sdjournal.org/products/articleInfo/93 http://wiki.hammurapi.biz/index.php?title=Hammurapi_4_Quick_Start 8. Relief from http://www.workingfrog.org/ License: GPL Relief is a design tool providing a new look on Java projects. Relying on our ability to deal with real objects by examining their shape, size or relative place in space it gives a “physical” view on java packages, types and fields and their relationships, making them easier to handle. 9. Hudson from http://hudson-ci.org/ License: MIT Hudson is a continuous integration (CI) tool written in Java, which runs in a servlet container, such as Apache Tomcat or the GlassFish application server. It supports SCM tools including CVS, Subversion, Git and Clearcase and can execute Apache Ant and Apache Maven based projects, as well as arbitrary shell scripts and Windows batch commands. 10. Cobertura from http://cobertura.sourceforge.net/ License: GNU GPL Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. It is based on jcoverage. 11. SonarSource from http://www.sonarsource.org/ License: LGPL Sonar is an open platform to manage code quality. As such, it covers the 7 axes of code quality: Architecture & Design, Duplications, Unit Tests, Complexity, Potential bugs, Coding rules, Comments. Feel free to suggest your own tools in the comments section. Reference: Java Tools for Source Code Optimization and Analysis from our JCG partner at the Our Tech Stop blog. Related Articles :Using FindBugs to produce substantially less buggy code Why Automated Tests Boost Your Development Speed Not doing Code Reviews? What’s your excuse? Save money from Agile Development Top 25 Most Dangerous Software Errors – 2011...

Software Estimation is not a Black Art

Construx Software is one of the few companies that take the problems of estimation in software development seriously. Earlier this year I attended Steve McConnell’s Software Estimation in Depth course based on his book Software Estimation: Demystifying the Black Art. Two days reviewing factors in estimation and the causes of errors in estimating, the differences between estimates and targets and commitments, how to present estimates to the customer and to management, the importance of feedback and data, estimating techniques that work and why they work, and when and how to apply these techniques to different estimating problems. You can get a lot out of reading Steve’s book, but the course setting gives you a chance to work with other people and solve real problems in estimation and planning, dig deep into questions with the man himself, and it introduces new material and research not included in the book. The key takeways from this course for me were: The Basics Even simple techniques work much better than “expert judgment” (aka wild ass guesses). With training and using straightforward tools and simple mathematical models and following a bit of structure, you can get to 70-75% accuracy in estimating, which is good enough for most of us. Never estimate on the spot – it is professionally irresponsible, and you’re setting yourself, your team, and your customer up to fail. Always give the person who is doing the estimate time to think. Everyone knows this, but it’s important to be reminded of it, especially under pressure. People’s systemic error tendency is to underestimate. Many organizations underestimate by a factor of at least 2x. This also applies to comparing back to actual costs: a common mistake is to remember how much you estimated something would take, not how long it actually took. Estimates are always better if you can use real data to calibrate them: to compare estimates against evidence of how your organization has performed in the past. I knew this. But what I didn’t know is that you don’t need a lot of data points: even a few weeks of data can be useful, especially if it contradicts with judgment and forces you to question your assumptions. Use different techniques at different stages as you move along a project’s Cone of Uncertainty, depending on how much information you have available at the time, and how high the stakes are – what the cost of estimation errors could be to the business. If you need higher confidence or higher quality estimates, use multiple techniques and compare the results. I like T-Shirt sizing to help in planning and making a business case. Developers come up with a rough order of magnitude estimate on cost or effort (small, medium, large, extra-large) while the Customer/Product Owner/Product Manager does the same for the expected business value of a feature or change request. Then you match them up: Extra-Large business value and Small development cost gets a big thumbs-up. Small business value and Extra-Large cost gets a big thumbs down. Estimating by analogy – comparing the work that you need to estimate to something similar that you’ve done before – is a simple technique that we use a lot. It works well if you are adding “another screen”, writing “another report”, or building “another interface”. It’s a good fit for maintenance, if you’ve been working with the same code for a while and know most of the gotchas. Intact teams (like mine) tend to view problems in a similar way – ideas and experience converge. This is good if you work on similar problems, in maintenance or a long-running project, because you can make decisions quickly and confidently. But this is bad if you are confronted with new problems – you need techniques like Wideband Delphi to challenge people’s thinking patterns and let new ideas in. Agile Estimating and Story Points and Velocity We spent more time than I expected exploring issues in estimating Agile development work. Incremental and iterative planning in Agile development poses problems for a lot of organizations. The business/customer needs to know when the system will be ready and how much it will cost so that they can make their own commitments, but the team ideally wants to work this out iteratively, as they go. This means instead that they have to define the scope and cost as much as they can upfront, and then work out the details in each sprint – more like staged or spiral development methods. Once they have the backlog sized, they can plan out sprints based on forecast velocity or historical velocity – if they can figure this out. I’m still not convinced that Agile story point estimating is better than (or as good as) other techniques, or that programmers sitting around a table playing Planning Poker is really an effective alternative to thoughtful estimating. Story points create some problems in planning new project development, because they are purposefully abstract – too abstract to be useful in helping to make commitments to the business. You might have an idea of how many story points give or take you have to deliver, but what’s a story point in the real world? People who use story points can’t seem to agree on how to define a story point, what a story point means and how or when to use them in estimating. More fundamentally, you can’t know what a story point costs until the team starts to deliver, by measuring the team’s velocity (the actual story points completed in an iteration).This leaves you with a bootstrapping problem: you can’t estimate how long it is going to take to do something until you do it. You can look at data from other projects (if you’ve tracked this data), but you’re not supposed to compare story points across projects because each project and each team is unique, and their idea of story points may be different. So you have to make an educated guess as to how long it is going to take you to deliver what’s in front of you, and now we’re back to the “expert judgement” problem. The good news is that it won’t take long to calibrate Story Point estimates against evidence from the team’s actual velocity. Mike Cohn in Succeeding with Agile says that you need at least 5 iterations to establish confidence in a team’s velocity. But Construx has found that you can have a good understanding of a team’s velocity in as little as 2 iterations. That’s not a long time to wait for some kind of answer on how long it should take to get the work that you know that you have in front of you done. There is more to estimating There is a lot more to estimating, and to this estimation course: details on different techniques and rules of thumb, models and software tools, how to measure estimation error, how to turn estimates into schedules, how to handle schedule compression and how to stay out of the Impossible Zone. To get a taste of the course, check out this webinar on the 10 Deadly Sins of Software Estimation. Software estimation, like other problems in managing software development, doesn’t require a lot of advanced technical knowledge. It comes down to relatively simple ideas and practices that need to be consistently applied; to fundamentals and discipline. That doesn’t mean that it is easy to do it right, but it’s not dark magic either. Reference: Estimation is not a Black Art from our JCG partner Jim Bird at the Building Real Software blog. Related Articles :Developing and Testing in the Cloud Lessons in Software Reliability Not doing Code Reviews? What’s your excuse? Save money from Agile Development 9 Tips on Surviving the Wild West Development Process...

Contribute to Java Code Geeks Today

Hi all, As you probably have noticed, we have been running the Java Code Geek (JCG) program for a while now. The JCG program aims to build mutually beneficial partnerships between Java Code Geeks and community bloggers whose articles are of interest to the Java developer community. The program simplifies the process of publishing selected blog articles by JCG members onto the Java Code Geeks site. Through this process, our JCGs enjoy substantially increased visibility, while our audience enjoys great content. The program’s goal is to create the ultimate Java to Java resource center. And we would like to ask your contribution for it. You can read all the details in the JCG Program official page. Currently, we are counting around 40 partners who have contributed a lot of top notch articles. At the same time, they have reaped the benefits of being our partners by enjoying increased exposure to their personal blog or site. Additionally, we are now introducing the Write For Geeks (W4G) program. We’re always looking for opportunities to team up with talented people in the software development world, people who are willing to contribute unique, useful, creative and exciting articles to the community. With the W4G program, you can share one of your articles with the community, operating in a “push” mode. You can email us the whole article or better yet provide us with the link if it is already posted. We will evaluate the article and repost it under the Java Code Geeks umbrella, mentioning of course the author and the original source. After your first post is published, you will also be included in our guest writers list. The W4G program offers an alternative way of generating targeted traffic for your site, while improving your writing skills. You can read all the details in the W4G Program official page. Thanks for reading, we would love to hear from you! Don’t forget to share with those that might be interested in this. Cheers! Related Articles:The Java Code Geek (JCG) Program Java Code Geeks on Facebook Top 10 JavaCodeGeeks posts for 2010...

Best Of The Week – 2011 – W30

Hello guys, Time for the “Best Of The Week” links for the week that just passed. Here are some links that drew JavaCodeGeeks attention: * Test-Driven Development Is Not Slower: An article praising the advantages of Test Driven Development (TDD) in terms of development speed, dispersing the myth that developers do not have enough time for unit testing. * SQL vs NoSQL in the Cloud: Which Database Should You Choose?: A nice, short article describing the differences of SQL and NoSQL solutions and discussing the advantages of each approach. In the end, a hybrid solution is examined (SQL database implementation that uses NoSQL infrastructure). * Visual Studio v. Eclipse: a Comparison of Automation Tooling: An introduction of the methodology for creating Eclipse and Visual Studio-based toolkits, and introduce Visual Studio Pattern Automation Toolkit, a toolkit for toolkit developers. . * Reverse Engineering Applications: A presentation explaining why someone would use reverse engineering, outlining some of the tools for managed .NET and Java code, along with demoing techniques. * OutOfMemoryError warning system with Spring: This article examines the common OutOfMemoryError JVM error and provides a Spring based application that triggers it. JMX is used in order to monitor the application and create metrics. * Performance-driven SQL databases and virtualization: A short article on SQL deployment on virtualized and non-virtualized environments. Performance versus expenses are examined in each case. * EJB 3.1 Cookbook by Richard Reese review: A review on the new book “EJB 3.1 Cookbook” written by our JCG partner Tomek Nurkiewicz. * Hidden Java 7 Features – System and Process CPU Load Monitoring: This article discusses a new MBean in Java 7 that allows Java developers to access overall System and current process CPU load monitoring. Also, check out “Java 7: try-with-resources explained” and “A glimpse at Java 7 MethodHandle and its usage”. That’s all for this week. Stay tuned for more, here at JavaCodeGeeks. Related Articles:Best Of The Week – 2011 – W29 Best Of The Week – 2011 – W28 Best Of The Week – 2011 – W27 Best Of The Week – 2011 – W26 Best Of The Week – 2011 – W25 Best Of The Week – 2011 – W23 Best Of The Week – 2011 – W22 Best Of The Week – 2011 – W21 Best Of The Week – 2011 – W20 Best Of The Week – 2011 – W19...
Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.

Sign up for our Newsletter

20,709 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books