preload
Sep 21

Since 25th of August 2015 I am PMP (Project Management Professional). It was some kind of hard work for this 4h exam regarding preparation. However, it was not as hard as I thought. Many people claim it is really tough and you need up to several hundred hours of preparation. Of course it may depend how much preparation you need based on your experience/knowledge, nevertheless I am convinced that if you have some experience in project management, and that is of course required for applying as pmp, it is absolutely doable.

Here are some tips or topics which helped me:

  • A prepration course really helps. The reason is simple, experienced coaches know what is most relevant and what not. It gave me a thread to follow.
  • For me Ritas PMP Prep book did the job. And that was it. One book is enough. But I am convinced that many other will do it as well.
  • Do the test questions in your book.
  • Do Test-Exams and do many of them. I did only one (near) real simulation length with 175 questions in 3,5h. That prepared me a bit for the exam, although the exam is a bit harder, just because it is an exam :)
  • I did a bunch of 50-100 question tests and tracked the score. That gives an impression how “prepared” you are for the exam. Check the wrong questions and understand why you did them wrong.
  • Do a plan upfront when you will do read how much pages of your book and which tests (how many questions) you do. Track against your plan. And as you should have learned, “no plan survives first contact”, of course you must/should adapt it when appropiate.
  • I was pretty happy with the Oliver Lehmann Test app, of around 4.99 EUR in-app purchase. The app has some usability problems, but the questions have quite the similar difficulty as the real exam questions. The app allows also doing some “Quicktests” with 10-15 questions, whenever you have time for it. I did a lot of these.
  • Many people write about a correctness score of above 80% in your tests, then you should be ready, I rarely reached that score in a 4 week preparation period learning in the evenings and on weekends, overall I had an average of 74% and that was enough. Honestly I was not sure if that is sufficient, but moderate proficient 4 times and proficient in execution is perfect for me. I assume more proficient rates will be the result if you continue prep-testing and have higher score in your preparation test.
Tagged with:
Apr 22

Finally it is done! My Master Thesis at the Fernuni Hagen! It was graded with a 1.0!!! Thx a lot Dr. Wolfgang Wilkes for giving me the chance to write a thesis and the support.

Writing a thesis while working full time is really really hard. The reason is simple: you need some time to get back to the point where you stopped. You can most of the time work only on the weekends, thus only working a few hours does not make senses as you really need up to half an hour since you are back deep in into the topic and can work efficiently.

However, I am happy that is is done and here is the topic of the thesis:

“Implementierung eines Webservices nach ISO 29002-31 »Query for characteristic data«

In English:

“Implementing a Webservice according to ISO 29002-31 Query for characteristic data”

For those who are interested in the Master Thesis, you can download it here:

https://bitbucket.org/ssobek/masterarbeit/downloads/01_Masterarbeit_Stefan_Sobek_final.pdf

But it is in german! Only the abstract is in englisch.

For those you are interested in the LaTeX-Sources of the Thesis:

git clone https://bitbucket.org/ssobek/masterarbeit.git

My development work for the thesis can be downloaded here with git:

git clone https://bitbucket.org/ssobek/plib-query.git

Feb 17

Wer Maven einsetzt stößt schnell auf genau das Problem, es gibt keine Oracle JDBC JAR in irgendeinem öffentlichen Repository.

Problem:

Den Oracle JDBC Treiber liegt auf Grund von Lizenzbeschränkungen nicht in öffentlichen Maven-Repositories. Das ist ärgerlich, wenn die Applikation allerdings Maven einsetzt, da gerade die Verwaltung der Abhängigkeiten mit Maven sehr praktisch ist.

Lösung:

1. Die aktuelle Oracle Version auslesen, wenn nicht bereits bekannt:

SQL> SELECT * FROM v$version;

Ausgabe in etwa wie folgt:

Oracle Database 11g Express Edition Release 11.2.0.2.0 – Production
PL/SQL Release 11.2.0.2.0 – Production
CORE 11.2.0.2.0 Production
TNS for 32-bit Windows: Version 11.2.0.2.0 – Production
NLSRTL Version 11.2.0.2.0 – Production

2. Download des passenden JDBC Treibers von der Oracle Seite:
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html

3. Treiber Datei ins maven repository einfügen
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.2.0 -Dpackaging=jar -Dfile=ojdbc6.jar -DgeneratePom=true

4. Dependency in pom.xml deines Projektes hinzufügen

<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.2.0</version>
</dependency>

Jetzt liegt die oracle jdbc jar im Repository und kann in den entwickelten Applikationen per dependency wie gehabt benutzt werden.

Tagged with:
Jan 24

Problem
Ein bestimmter Bereich eines Excel-Sheets soll nur bearbeitbar sein. Der Rest des Arbeitsblattbereiches soll gesperrt werden.

Lösung
Da gibt es mehrere Lösungen, jedoch bin ich auf die nachfolgende gestoßen, die sehr simpel und effektiv ist.

Nehmen wir an, der Bereich A1-D10 soll editierbar sein. Alle weiteren Zellen müssen gesperrt werden, ob dort Text steht oder nicht.

  • Geht in den Visual Basic Editor in Excel (unterschiedlich nach Office-Version – Office 2007 Tab Entwicklertools)
  • Dort unter VBAProject mit der rechten Maustaste auf das entsprechende Sheet klicken (z.B. Tabelle1)
  • “Code anzeigen” auswählen
  • Nun das nachfolgende Snippet einfügen:

Private Sub Worksheet_Activate()
'Set/restrict sheet's scroll area.
Me.ScrollArea = "A1:D10"
End Sub

Jetzt ist bis auf den Bereich A1:D10 jede weitere Zelle auf dem Blatt gesperrt

Tagged with:
Jan 10

Ever had problems in IE7 with z-index css attribute?

Problem:
The Menu created with superfish plugin for jquery will be shown behind the main content on mouseover.

Solution:
With Jquery dynamically reverse the CSS zindex stacking order of the page element so that higher elements in HTML source have highter z-index number

1
2
3
4
5
6
7
       	$(function() {
		var zIndexNumber = 1000;
		$('div').each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber -= 10;
		});
	});

Check this link for more information: http://www.vancelucas.com/blog/fixing-ie7-z-index-issues-with-jquery/

Tagged with:
Dez 11
Override equals

Although some people think it might be easy to override the equals method of a class, you can do it wrong in many cases and this can cause problems.

The easiest case is not to override the equals method, then each class is equals only to itself and equals from object is used. Do this only in following cases:

  • When each instance is inherently unique. For example classes as Thread. These represent active entites rather than values. So for value objects this is no applicable.
  • You don’t need a “logical equality” test. For example the java.util.Random where it does not make sense to check if two random numbers are equal.
  • The superclass equals is fully appropriate. E.g. Set -> AbstractSet, List -> AbstractList
  • The class or the package is private and it is assured that it will not been invoced

When to override equals method?

When the logical equality differs from object identity. This is the case for value classes. This class represents a value such as Integer or Date. If these objects will be compared you want to know if the values are the same and not if the objects are the same.

The Java6 specification says about the contract which must be assured when overriding equals:

• Reflexive:Foranynon-nullreferencevaluex,x.equals(x)mustreturntrue.
• Symmetric:Foranynon-nullreferencevaluesxandy,x.equals(y)mustre- turn true if and only if y.equals(x) returns true.
• Transitive:Foranynon-nullreferencevaluesx,y,z,ifx.equals(y)returns true and y.equals(z) returns true, then x.equals(z) must return true.
• Consistent: For any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, pro- vided no information used in equals comparisons on the objects is modified.
• For any non-null reference value x, x.equals(null) must return false.

How should equals be overridden?

This list was taken from Effective Java 2nd Edition.

  • Use the == operator to check if the argument is a reference to this object.
  • Use the instanceof operator to check if the argument has the correct type.
  • Cast the argument to the correct type.
  • For each “significant” field in the class, check if that field of the argument matches the corresponding field of this object.
  • When you are finished writing your equals method, ask yourself three questions: Is it symmetric? Is it transitive? Is it consistent?
Override hashCode

Always override hashCode when you override equals.

Here is the contract from the Java specification:

Here is the contract, copied from the Object specification [JavaSE6]:
• Whenever it is invoked on the same object more than once during an execu- tion of an application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execu- tion of an application to another execution of the same application.
• If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
• It is not required that if two objects are unequal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

Furthermore two equal objects must have the same hash code.

How to create a good has method?

Here are some tips taken from Effective Java book:

  • Store some constant nonzero value, say 17, in an int variable called result.
  • For each significant field f in your object (each field taken into account by the equals method, that is), do the following:
    • Compute an int has code c for the field:
      • If the field is a boolean, compute (f ? 1 : 0)
      • if the field is a byte, char, short, or int, computer (int) f.
      • If the field is a long, computer (int) (f^>>>32)).
      • If the field is a float, computer Float.floatToIntBits(f).
      • If the field is a double, compute Double.doubleToLongBits(f), and then hash the resulting long as in step for long.
      • If the field is an object reference and this class’s equals method compares the field by recursively invoking equals, recursively invoke hashCode on the field. If a more complex comparison is required, compute a “canonical representation” for this field and invoke hasCode on the canonical representation. If the value of the field is null, return 0 or some other constant.
      • If the field is an array, treat it as if each element were a separate field. That is, compute a hash code for each significant element by applying these rules recursively, and combine these values per step 2 for byte,short etc. If every element in an array field is significant, you can use one of the Arrays.hasCode methods added in release 1.5.
    • Combine the has code c computed in step 2 into result as follows:
      result = 31 * result + c;
  • Return result.
  • When you are finished writing the hashCode method, ask yourself whether equal instances have equal hash codes. Write unit tests to verify your intuition! If equal instances have unequal hash codes, figure out why and fix the problem.

Override toString

If you do not override toString method and print an object you usally see something like this PhoneNumber@434b65. Ok, it is clear that this is a phone number, but wouldn’t it be better to have a representation like “(0221) 77744499″?

So when overriding the toString method it should return all of the interesting information contained in the object. If you have large objects or objects with a not conductive state you can return something like “Yellow pages (2355333 listings)”.

Provide your toString method with good documentation and describe your format. Here is an example taken from Effective Java 2nd Edition:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/** 
* Returns the string representation of this phone number. 
* The string consists of fourteen characters whose format 
* is "(XXX) YYY-ZZZZ", where XXX is the area code, YYY is 
* the prefix, and ZZZZ is the line number. (Each of the 
* capital letters represents a single decimal digit.) 
* 
* If any of the three parts of this phone number is too small 
* to fill up its field, the field is padded with leading zeros. 
* For example, if the value of the line number is 123, the last 
* four characters of the string representation will be "0123". 
* 
* Note that there is a single space separating the closing 
* parenthesis after the area code from the first digit of the 
* prefix. 
*/
@Override public String toString() { 
    return String.format("(%03d) %03d-%04d", areaCode, prefix, lineNumber);
}

If you want not a specific format make something like this:

1
2
3
4
5
6
/**
* Returns a brief description of this potion. The exact details 
* of the representation are unspecified and subject to change, 
* but the following may be regarded as typical:
* "[Potion #9: type=love, smell=turpentine, look=india ink]" 
@Override public String toString() { ... }
Tagged with:
Dez 02

Imagine you would like to create a payment in banking domain and you have to create an instance with many parameters. The first two parameters are mandatory and the others are optional. You would normally create it like:

1
Payment credit = new Payment(Payment.CREDIT, "1000", "Beneficiary account", "Beneficiary bank name", "Remitter account name", "Remitter bank name" );

This could be a long line, depending on the number of parameters. Also from the code you don’t know which parameter you actually set in the constructor. Ok, lets use Java Beans style with getter and setters:

1
2
3
4
5
6
7
Payment credit = new Payment();
credit.setType(Payment.CREDIT);
credit.setAmount(1000);
credit.setBeneficiaryAccountName("Beneficiary account name");
credit.setBeneficiaryAccountBankName("Beneficiary bank name");
credit.setRemitterAccountName("Remitter account name");
credit.setRemitterAccountBankName("Remitter bank name");

So far so good, now we know exactly what we set and we use Java Beans spec. But now we have the problem that the creation process is split between multiple calls of the setters. This could lead to an inconsistent state during the creation process. If somewhere between these setter calls a problem occurs, the objects could be initialized incompletely.

What if you could create an instance like the following:

1
2
3
4
5
6
Payment credit = Payment.Builder(Payment.CREDIT, 1000)
                        .beneficiaryName("Beneficiary name")
                        .beneficiaryAccount("Beneficiary account name")
                        .remitterName("Remitter name")
                        .remitterAccount("Remitter account name")
                        .build();

We seperated the optional from the mandatory parameters and improved readability. Also this is only one call and so is the instance in a consistent state.

Here is the example code of the class Payment:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
public class Payment {
   private final static int CREDIT = 0;
   private final static int DEBIT = 1;
   private final int type; // required
   private final double amount; // required
   private final String beneficiaryAccount; // required
   private final String beneficiaryName; // required
   private final String remitterName; // optional
   private final String remitterAccount; // optional
 
 
   public static class Builder {
     // Required parameters
     private final int type;
     private final double amount;
     // Optional parameters - initialized to default values
     private String beneficiaryAccount = "";
     private String beneficiaryName = "";
     private String remitterName = "";
     private String remitterAccount = "";
 
     public Builder(int type, double amount) {
       this.type = type;
       this.amount = amount;
     }
 
     public Builder beneficiaryAccount (String val) { remitterAccount = val; return this; }
     public Builder beneficiaryName (String val) { remitterAccount = val; return this; }
     public Builder remitterName (String val) { remitterAccount = val; return this; }
     public Builder remitterAccount (String val) { remitterAccount = val; return this; }
     public Payment build() { return new Payment(this); }
   }
 
   private Payment(Builder builder) {
     type = builder.type;
     amount = builder.amount;
     beneficiaryAccount = builder.beneficiaryAccount;
     beneficiaryName = builder.beneficiaryName;
     remitterName = builder.remitterName;
     remitterAccount = builder.remitterAccount;
   }
}

Examples modified from the Book “Effective Java” http://www.amazon.de/gp/product/0321356683

Another great article can you find here: http://www.javablog.ch/2008/08/23/effective-java-builder-pattern/

Tagged with:
Okt 26

I recently read in a chapter of Rod Johnsons Book “expert one-to-one, J2EE Design and Development” an interesting sentence:

A professional programmer or architect cares more about learning and discovering the best solution than the buzz of finding their own solution to a particular problem.

This is so true. Don’t waste (project) time with finding a very own solution and reinventing the wheel. Find solutions that fit your needs, learn how they solved the problem. Of course they must fit to your problem with a coerage of lets say >90%. But these solutions are tested.

Tagged with:
Okt 14

Situation:
You created a composite component in JSF 2.0. This component now should have some attributes which contains direct links. This links should now be declared when you use the component.
Example:

1
2
3
    <composite:attribute type="java.lang.String" required="false"
        name="logoutURL" default="/faces/logout.jsf"
        shortDescription="The logout URL." />

Later in the implementation you use it like the following example:

1
2
		<h:commandLink action="#{cc.attrs.helpURL}"
			value="#{textbundle['status.linktext.logout']}" />

Problem
You now get a class cast exception. JSF excepts a String result of a method which you can use in the action attribute of commandLink. Directly putting a String in this result is ok.

Solution
Use toString (although you declared the attribute as type of String)

1
2
		<h:commandLink action="#{cc.attrs.helpURL.toString}"
			value="#{textbundle['status.linktext.logout']}" />
Tagged with:
Jun 04

Situation:
Imagine your customer has a bunch of Excel-files which he wanted to display on a website in html-form.

Problem:
What can you do here? You can write an importer to a database, or let the customer upload the excel file on a webserver and write a parser for the excel files etc. These are all non-trivial solutions for the problem that you want to easily display your information from the csv on a webpage into a table.

Solution:
I found a plugin called jquery csv2table. This is very simple to use. A CSV-file will be read asynchrounosly and a HTML-table will be created of it. So you can simply let your customer load his csv file up and the table will be created automatically. Optional support of sorting, highlighting etc. Link: http://plugins.jquery.com/project/csv2table

Example:

?View Code JAVASCRIPT
1
2
3
4
5
6
<div id="view1"></div>
<script type="text/javascript">
$(function(){
    $('#view1').csv2table('./data/Book12.csv');
});
</script>

This code will load the data from Book12.csv into the div “view1″.

Tagged with: