Software Development – Bar54 http://www.bar54.de Software Engineering, Web Technologies, eCommerce and some more Mon, 12 Aug 2019 03:10:43 +0000 en-US hourly 1 https://wordpress.org/?v=5.9.4 Eclipse font size change made easy http://www.bar54.de/2015/02/eclipse-font-size-change-made-easy/ Sat, 28 Feb 2015 14:14:19 +0000 http://www.bar54.de/?p=773 Have you ever asked yourself why it is so complicated to change the font size of your eclipse working environment? Easpecially when you are working with a notebook and switching between the build in display and different external displays it make sense to adapt your font size to the different screen resolutions.

Note: Since Eclipse Neon (4.6) this is a build in feature. By default, you can use Ctrl+”+” or Ctrl + “-” to increase or decrease the font size of your active text editor or view.
Today, I found a simple plugin making life easier and saving time during your everday work. Just checkout the plugin Eclipse Font available on google code: https://code.google.com/p/eclipse-fonts/

Just install the plugin from the according update site: http://eclipse-fonts.googlecode.com/svn/trunk/FontsUpdate/
and use Ctrl+- or Ctrl++ to decrease or increase your font size.

Note: If you manually changed your editors’ font size before, you might need to reset this to make the plugin effect your settings.

Enjoy adapting your font size to your current screen resolution!

eclipse-font

]]>
SVN to GitHub Migration on Windows http://www.bar54.de/2014/06/svn-github-migration-windows/ Wed, 18 Jun 2014 13:48:31 +0000 http://www.bar54.de/?p=728

Table Of Content

SVN and GitHub are both valid source code repositories and depending on your project context you should decide for one or the other. However, as SVN is out there for some time, and many projects starts to move on]]>

SVN and GitHub are both valid source code repositories and depending on your project context you should decide for one or the other.
However, as SVN is out there for some time, and many projects starts to move on to GitHub because of it’s additional infrastructure, such as forks and pull requests, more and more people needs to perform a migration.

On linux systems, it’s quite easy to use your package installer for the svn2git tool recommended by GitHub for the migration.
However, on a windows machine, this is possible as well and you just need a few extra steps to get this done.

1 Migration in a Nutshell

There is a good article by omranic on how to get a git repository from your svn repository: http://omranic.com/svn2git-subgit-win/.
In short:

  1. Install Git: http://git-scm.com/download/win
  2. Install Ruby: http://rubyinstaller.org/downloads/
  3. Update the Ruby Package Manager (gem): Execute “gem update –system” on the command line
  4. Create a text file that maps your svn commiters to the according github users (see notes below)
  5. Run svn2git to create a local git repository
  6. Link your local repository with GitHub and send it over (push)

2 Author Mapping

You need a file mapping your svn users to according git/GitHub users to correctly assign the commits. The file looks like

svnuser1=gituser1 <gituser1@mail.com>
svnuser2=gituser2 <gituser2@mail.com>
...

To find out who has contributed to your svn repository you can use the command:

svn log --quiet http://path/to/root/of/project | grep -E "r[0-9]+ \| .+ \|" | cut -d'|' -f2 | sed 's/^ //' | sort | uniq

3 Run svn2git

Open a command line, switch to the directory you want to create your local repository at and run svn2git.
There are a couple of different parameters, depending on wether you want to take over your branches, tags, or what else.
If you are intersted in the trunk only, simply use

svn2git <your/repository/url/trunk/> --authors <path/to/authormappings.txt> -v --rootistrunk

No, grap a coffee, lean back and wait for the tool to finish…

4 Send Content to GitHub

Once your local repository is fine, you can link it with a remote GitHub Repository and push it to the remote host using the following comments (do not forger to adapt GITHUB_USERNAME and REPO_NAME to whatever you settings are).

git remote add origin git@github.com:GITHUB_USERNAME/REPO_NAME.git
git push origin master

5 Trouble Shooting

5.1 GitHub Connection

If you are not able to push your content to GitHub yet, this might because of a not yet configured connection.

Open a command line and run
ssh -v git@github.com
If you see a permission denied at the end somewhere above issues like

debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/identity
debug1: Trying private key: /.ssh/id_rsa
debug1: Trying private key: /.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).

You might need to generate a new ssh key and make it available for your ssh connection.

How to generate the key is well described by Daniel Hüsken at http://danielhuesken.de/git-fur-windows-installieren-und-ssh-keys-nutzen/
Your ssh-keygen might tell you about “//.ssh/id_rsa” as default directory. Note the two //. You should change this to a single slash: “/.ssh/id_rsa” to match git’s local ssh directory.

If you still not able to connect, but your users .ssh sub directory contains your key file, you should take a look at your Git installation directory. It might have happend that the git installation overloaded your ssh installation with it’s own implementation. So you can take a look if your git installation directory has a subdirectory named .ssh. If so, copy your id_rsa and id_rsa.pub files into that directory and try again.

5.2 No tracking information for current branch

If you try to push your content to the remote repository, you might need to specify the branch to commit to.

If you get error messages such as the following ones:

warning: no common commits
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From github.com:kopl/SPLevo
 * [new branch]      master     -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

choose the second offered command to link your local master with the remote master:

git branch --set-upstream-to=origin/master master

5.3 Empty Directories

Git does not support empty directories. This might become an issue depending on how your project / code is set up.
Sometimes you have empty directories for temp directories, convinience, due to default project creations or what ever. In Subversion no issue, in git not possible (except of dirty and error prune hacks).

So far, by the migration itself, this might be not an issue except of minor warnings easy to ignore 😉
However, when it comes to checking your code out again (by human or build server), the downstream build process might fail because of missing class path settings or others.
So be aware of that and keep it in mind during error research.

5.4 Changed Files right after Eclipse Import

When you are working with Eclipse and see many changed files right after the import, this might because of one of the following reasons:

Line Ends
Your system might automatically change the line ends in your text files to adapt it to your local file system. To prevent this behaviour you can discable the auto carriage return and line feed setting of git by running the following command on a shell or command line:

git config --system core.autocrlf false

bin Directories
When Eclipse compiles your projects, it might create bin directories with content. To not get this recognized as changes to commit, you can add a .gitignore file to your project containing a single line of “/bin”

If you operate several projects, you might want to place the .gitignore file in the parent folder. Note that you need to specify the excluder rule as “*/bin” to get it applied to the sub directories.

6 Further Topics

6.1 Jira-GitHub Integration

Jira is a very powerfull issue management system and if you used it before, you might want to keep it. However, integrating it with your code repository is an essential feature you do not wanna miss. Setting this up wiht GitHub is quite easy.

In your Jira System, install the Jira DVCS Plugin.
Then log in to your GitHub account and create credentials for a remote application. Open your profile, select “Applications” and register a new application. This will provide you a client key and secret you will need to specify a GitHub account in the DVCS Plugin.
Next, go to your Jira Administration and select Plugins -> DVCS Accounts and create a new GitHub account. There you will need the key and secret provided by GitHub. And there you go.
Now, the commit messages used in GitHub must contain the key of a Jira issue and the commit will be linked to the according issue: https://confluence.atlassian.com/display/AOD/Processing+JIRA+issues+with+commit+messages

6.2 Jenkins-GitHub Integration

For the Jenkins continous integration server a GitHub specific git plugin is provided. This plugin comes with a remote API. GitHub allows for configure a web service connection specific to the Jenkins GitHub plugin. The settings of your GitHub repository contain an option named “Webhooks & Services”. Here you can add a new service and select from a list of available ones. Choose the “Jenkins GitHub plugin” service and provide it with the url to your jenkins server. Further details about the GitHub Plugin configuration can be found on the plugin’s website.

6.3 Line Endings

As line endings are treated different between Windos (CRLF) and Unix (LF) operating systems, they are always an error-prone and annoying topic.
Git provides capabilities to normalize line endings when code is commited and/or pushed into the repository. This behaviour can be configured in many different ways.
However, working in teams with people using different operating systems, it is always a good choice to work with Unix style line endings (LF).

The following set of practices is recommendable to ensure everything runs smooth in your daily work:

1. Explicit Repository Settings
Git repositories can be configured to use an explict setting independent from what a user has configured for his overall system.
Create a .gitattributes file in the root of your repository. Below, you can see an example for treating all files as text files with LF file endings by default. Furthermore, for a set of specific file endings, files will be treaten as binary.

# Set the default behavior, in case people don't have core.autocrlf set.
* text eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.gif binary
*.class binary
*.jar binary

Checkout the GitHub recommendations for how to update your repository if you need to normalize an existing repository: https://help.github.com/articles/dealing-with-line-endings

2. Configure Eclipse
Make sure to configure your Eclipse workspace for UTF-8 file encoding and UNIX style line ends:
eclipse-workspace-settings

7 Noteworthy Features from Working with GitHub

From migrating to GitHub, we identified several features really helpful in daily work.

Working Offline
Great while working a lot on the road, airplane or train

Line Level Code Links
Great to lightweight pointing people to specific code snippets such as “look here!

Line End Management
Working in teams with people using different operating systems it’s good to enforce a specific line ending. See the GitHub recommendations how this can be enforced on a per repository base:
https://help.github.com/articles/dealing-with-line-endings

]]>
Java String.split() vs. Pattern.split() http://www.bar54.de/2014/01/java-string-split-vs-pattern-split/ http://www.bar54.de/2014/01/java-string-split-vs-pattern-split/#respond Sun, 05 Jan 2014 10:23:55 +0000 http://www.bar54.de/blog/?p=546 If you need to split a string into an array of parts based on a split character, Java provides a very simple to use convinience method. You just need to call split() on the String object you would like to split.

For example:

String myString = "Hy my name is bob";
String[] words = myString.split(" ");

If you need to perform the same kind of split frequently, the Java Regular Expressions API provides a good oportunity for a performance improvement.
The API provides a Pattern class to precompile a split pattern and execute it on a string.

The example above would look like:

Pattern p = Pattern.compile(" ");
String myString = "Hy my name is bob";
String[] words = p.split(myString);

Now, why would this lead to performance improvement?

Internally, String.split() is implemented as

public String[] split(String regex, int limit) {
    return Pattern.compile(regex).split(this, limit);
}

As you can see, String.split() instantiates a new Pattern object on the fly. The garbage collector can remove it quickly, but if you perform the same split again and again, this requires a reasonable overhead.
So what you can do is:

  1. compile your Pattern in advance.
  2. Store it either with an object existing long enough to provide access to the Pattern instance, or in a static manner
  3. use the split of the precompiled pattern instead of the convinience String.split()

Further recommendation

Google Guava Splitter
The Google Guava commons library provides a nice Strings API including a Splitter class you should take a look at
Google Guava Splitter

Hidden evils of Java’s String.split()…
Prashant Deva wrote an interesting blog entry about the split() performance and provides some statistics:
Read the blog entry

]]>
http://www.bar54.de/2014/01/java-string-split-vs-pattern-split/feed/ 0
Online UML Drawing Tools http://www.bar54.de/2013/06/online-uml-drawing-tools/ http://www.bar54.de/2013/06/online-uml-drawing-tools/#respond Thu, 20 Jun 2013 04:50:23 +0000 http://www.bar54.de/blog/?p=376 From time to time, you might need to draw a UML diagram for documentation, discussion or other purposes. And you might need to do this on a device (e.g. your computer or tablet) without an uml tool installed on. For me, this sometimes happens when discussing with a team and using a wiki for the common online documentation.

If possible, I would recommend to add a plugin to your wiki allowing to edit your diagrams directly on the wiki page. This enables remote editing and versioning based on your known wiki infrastructure.

However, adding a plugin to your wiki is not possible in every case. Especially when working with a distributed team of mixed departments or componies, or in open source projects with an open community, you should prepare for people not having a UML tool on their computer and you might not be able to modify your wiki.
In such cases, online uml drawing tools can be very helpful. There are plenty of them with pros and cons and you should select the right one carefully.

I recently tested a couple of tools while writing the documentation for the Palladio Workflow Engine. Below, you will find a short abstract per tool and pros and cons about it. If possible I added a screenshot of the tooling.

creately.com

Creately Activity Example
For all of those already familar with tools such as Microsoft Visio, you will be able to use this online tool immediately. Creately provides a flash application that also allows for collaboration and publishing of a diagram. They allow for a braught set of diagram types such as UML Activity, Classes, and much more. Even some non-uml diagrams are supported.
The tool is a flash application and provides drag&drop of elements from a pallette and the positioning and composition of the diagrams. In the majority, you create your diagram using mouse or touchpad.
Creately allows to download your diagram in several image formats and you can share links for editing or viewing your diagrams to others.
For a small bootstrap and wide acceptance, they provide a free access to a limit account. However, if you want to really use it in your team, you will have to choose one of the commercial options. The free edition allows for a very limited number of interactions / diagram only.

yUML

yUML Example
yUML is an online tool you write your diagram in a specific textual representation, press enter to draw a diagram based on your textual description. Finally, yUML provides you a link to share your diagram with others and to download your diagram in several image formats.
yUML Website

If you run a media wiki, a yUML is available for you: http://wiki.sindri.info/wiki/YUML_MediaWiki_Extension

]]>
http://www.bar54.de/2013/06/online-uml-drawing-tools/feed/ 0
Using svn:externals to integrate external sources in your own development code base http://www.bar54.de/2013/02/using-svnexternals-to-integrate-external-sources-in-your-own-development-code-base/ http://www.bar54.de/2013/02/using-svnexternals-to-integrate-external-sources-in-your-own-development-code-base/#respond Sat, 02 Feb 2013 10:57:06 +0000 http://www.bar54.de/blog/?p=323 Sometimes, you have to include an external library in your code base and would like to get updates for this immediately as they are published. For example: you have included the zend framework in your PHP application and would like to get updates as soon as possible into your development code base.
The best way is to include their svn code base into yours. But, your code base is located in your own svn. The solution is to use svn:Externals. This facility allows to integrate an external repository into your local checked out repository without pushing the external library into your repository while still be able to update from theirs. This is the major difference from simply placing their code in your local code base and choosing svn:ignore.
I explain how to use svn:Externals with tortoise svn. It would also be possible with the command line tool.
To make use of svn:external, select the directory you would like to include the external library into. (_lib/ in the example). Make a right click to open the context menu and chose “Tortoise SVN -> Properties”

A dialog opens to edit the properties. Choose “New > Externals”

In the second dialog that opens to edit the externals click on “New …” to configure the new svn:externals settings.

In this dialog, you can specify the name of the subdirectory you would like to place in the external sources (“Zend” in the screenshot) as well as the svn url you would like to checkout the sources from (Zend version 1.11 in the screenshot). As shown in the example, you can choose the head of a branch for a specific version, for example, to get the bug fixes and patches for a specific release.
As soon as you have confirmed all these dialogs by clicking “OK”, you can perform an svn update on the base directory you added the svn:external dependency to and tortoise svn will immediately start to download the external content.

In the example shown in the screenshot, I have included the Zend Framework Release 1.11 as an external dependency in my php application code base.
Zend framework release repository: http://framework.zend.com/svn/framework/standard/branches/release-1.11/library/Zend/

]]>
http://www.bar54.de/2013/02/using-svnexternals-to-integrate-external-sources-in-your-own-development-code-base/feed/ 0
GraphStream API: Custom Label Attribute Proxy http://www.bar54.de/2012/12/graphstream-api-custom-label-attribute-proxy/ http://www.bar54.de/2012/12/graphstream-api-custom-label-attribute-proxy/#respond Fri, 28 Dec 2012 22:53:17 +0000 http://www.bar54.de/blog/?p=319 The GraphStream API provided by graphstream-project.org is a pretty nice library to work with graphs for analysis, calculation, presentation or anything else.

All elements, such as nodes and edges can carry attributes with any literal key you would like to set ( addAttribute(String key, Object… value) ).
If one opens a graph in the included viewers (e.g graph.display()), a predefined attribute named “ui.label” is checked and any value of the attribute is used as a label in the visualization of this element.

If you would like to derive the label from another custom attribute instead of setting the “ui.label” attribute in parallel, this can be achieved by using the proxy concept of the GraphStream API.

When a graph is opened in a viewer, this can not only be done by simply calling the display method of the graph, but by opening a Viewer explicitly and setting a Proxy in between of the Viewer and the graph itself:


Viewer v = new Viewer(new CustomEdgeLabelAttributeProxy(graph, "my.attribute"));
v.enableAutoLayout();
v.addDefaultView(true);
v.setCloseFramePolicy(CloseFramePolicy.HIDE_ONLY);

This ensures that visualizing the graph in the ui will pass the created nodes, edges and attributes through the CustomEdgeLabelAttributeProxy.
This proxy class is derived from the class ThreadProxyPipe and the method to react on a newly set node attribute is overridden.


@Override
public void sendEdgeAttributeAdded(String sourceId, long timeId, String edgeId, String attribute, Object value) {
if (attribute.equals(this.labelKey)) {
super.sendEdgeAttributeAdded(sourceId, timeId, edgeId, "ui.label", value);
attribute = "ui.label";
}
super.sendEdgeAttributeAdded(sourceId, timeId, edgeId, attribute, value);
}

The method registers when the custom label attribute, identified by the attribute’s key, passes by. It passes the submitted parameters twice to the super method. Once with the custom attributes id to set this in the GraphicElement as usual, and a second time to set the attribute’s value also for the ui.label attribute to be presented by the viewer.

To also adapt the edge label when the graph respectively the edges are modified when the graph is already updated, you should also override the method

edgeAttributeAdded(String graphId, long timeId, String edgeId, String attribute, Object value)

The implementation of this method follows the same concept as the sendEdgeAttributeAdded() method above.

The proxy provides methods not only for the edge attributes, but also for node and graph attributes to react on.

The complete code of the CustomEdgeLabelAttributeProxy is provided below:


package org.splevo.vpm.analyzer.graph;

import org.graphstream.graph.Graph;
import org.graphstream.stream.thread.ThreadProxyPipe;

/**
* A proxy to change the edge's labels to the value of a custom
* attribute if a value is set for it.
*
* @author Benjamin Klatt
*
*/
public class CustomEdgeLabelAttributeProxy extends ThreadProxyPipe {

/** The key of the label attribute to use instead of the ui.label. */
private String labelKey;

/**
* The constructor for the edge label.
*
* @param graph
* The graph to present.
* @param labelKey
* The label key to be aware of.
*/
public CustomEdgeLabelAttributeProxy(final Graph graph, final String labelKey) {
super(graph, true);

this.labelKey = labelKey;
}

@Override
public void sendEdgeAttributeAdded(String sourceId, long timeId, String edgeId, String attribute, Object value) {
if (attribute.equals(this.labelKey)) {
super.sendEdgeAttributeAdded(sourceId, timeId, edgeId, "ui.label", value);
}
super.sendEdgeAttributeAdded(sourceId, timeId, edgeId, attribute, value);
}
}

]]>
http://www.bar54.de/2012/12/graphstream-api-custom-label-attribute-proxy/feed/ 0
Visualizing your JGraphT Graph Instance http://www.bar54.de/2012/12/visualizing-your-jgrapht-graph-instance/ http://www.bar54.de/2012/12/visualizing-your-jgrapht-graph-instance/#respond Wed, 26 Dec 2012 16:47:08 +0000 http://www.bar54.de/blog/?p=317 A very common library handle graphs in Java is provided by the JGraphT project: http://jgrapht.org/.

If you have produced a graph in your program and would like to visualize this there are two easy and straight forward ways to get a result:

GraphViz DOT Format

JGraphT provides an exporter for the GraphViz DOT format. To generate this format, simply use the following code:


DOTExporter exporter = new DOTExporter();
String targetDirectory = "testresults/graph/";
new File(targetDirectory).mkdirs();
exporter.export(new FileWriter(targetDirectory + "initial-graph.dot"), graph);

To view a .dot graph file in Eclipse, you can install the GraphViz Viewer provided by the TextUML project:
http://sourceforge.net/apps/mediawiki/textuml/index.php?title=TextUML_Toolkit
Their update site includes a separate feature for the GraphViz viewer.

JGraphT / JGraph Integration

JGraphT provides an integration with the JGraph library for graph visualisation (http://jgrapht.org/visualizations.html).

Here you will find some example code how to run a simple visualization of your graph.
Note: This code does not take any layouting into account and simply draws all nodes on top of each other.

import javax.swing.JFrame;

import org.jgraph.JGraph;
import org.jgrapht.ext.JGraphModelAdapter;
import org.junit.Test;
import org.splevo.tests.SPLevoTestUtil;
import org.splevo.vpm.analyzer.graph.VPMGraph;
import org.splevo.vpm.analyzer.graph.VPMRelationshipEdge;
import org.splevo.vpm.variability.VariationPoint;
import org.splevo.vpm.variability.VariationPointModel;

JFrame frame = new JFrame();
frame.setSize(400, 400);
JGraph jgraph = new JGraph(new JGraphModelAdapter(graph));
frame.getContentPane().add(jgraph);
frame.setVisible(true);
while (true) {
Thread.sleep(2000);
}

This code is compatible to the JGraph library shipped with JGraphT only.

]]>
http://www.bar54.de/2012/12/visualizing-your-jgrapht-graph-instance/feed/ 0
Do you really want to rewrite your software? http://www.bar54.de/2012/12/do-you-really-want-to-rewrite-your-software/ http://www.bar54.de/2012/12/do-you-really-want-to-rewrite-your-software/#respond Mon, 03 Dec 2012 08:10:57 +0000 http://www.bar54.de/blog/?p=300 Have you ever been in the situation facing a really grown software product that seems to be a code mess and nothing more?
One might consider it best to take what you’ve learned from this implementation, throw it away and re-implement it from scratch. But are your really able to do this?

There are two really nice blog posts providing examples where companies failed to re-implement their software and disuss the reasons for this:

So re-check if you really want to rewrite your software and better think about a smooth and controlled modernization before throwing away your business.

The long and short of it can be summed up quite simply: this is why your Phoenix business needs custom development software. Trying to use someone else’s tools will soon lead to bumps in the road; it wasn’t custom built for your needs, but theirs after all. You will find that there are things that seem easy at first but that thanks to this tool that specializes in something else it is far more complicated. A custom built piece of software can be constructed from the ground up to suit your needs, and be as effective as them as you require.

In the long run, you’ll find the time and stress saved from using custom software built for your business’s particular needs has added up and proven beneficial at an incalculable level.

]]>
http://www.bar54.de/2012/12/do-you-really-want-to-rewrite-your-software/feed/ 0