A Experiência na Gamificação

Um dos factores mais importantes para o sucesso da Gamificação num determinado ambiente, é a experiência.

small_3803517719 Há 2 tipos de experiência, a do Jogo que se está a implementar e a experiência pessoal que se adquire ao jogar o Jogo! A experiência que é o Jogo, é apenas o Jogo e as suas mecânicas, regras, elementos, design, facilidade de utilização e compreensão. Agora a experiência de jogar o Jogo é o que sentimos, antes, durante e depois de uma sessão(ões) no jogo! Para mim, esta última é a mais importante. (Embora não exista sem a primeira, a base!) Vamos ver um exemplo prático. Se for implementado um sistema gamificado que ajuda a ultrapassar problemas de saude, como lesões, doenças prolongadas, etc, (felizmente já há sistemas destes), qual é a experiência mais importante? O jogo e as suas regras, elementos, design, mecânica, ou o que a pessoa sente durante o decurso do Jogo? Eu acredito que será a alegria quando atinge um objectivo como conseguir dar 10 passos, se estava numa fisioterapia para andar após uma lesão grave! Creio que quando a pessoa consegue esse objectivo, motivado, acompanhado e orientado pelo Jogo (provavelmente com uma componente social de pessoas em situações idênticas ou que já estiveram nessas situações), a sua experiência vai ser fenomenal e vai com certeza recomendar o “Jogo” a outras pessoas em situações semelhantes! Não porque o Jogo era desafiante, bem desenhado, equilibrado, fácil de usar, com componente social,  mas sim porque a sua experiência com o Jogo a fez sentir-se muito bem em diversos níveis  e de encontro às suas expectativas, e acima de tudo, o Jogo ajudou-a numa situação real, da vida real, e isto não é mais que o objectivo da Gamificação!

photo credit: thephotographymuse via photopin cc

LinkedIn Recommendations–Do you know the risks?

There are a lot of people asking for recommendation in LinkedIn and other social networks.
My focus will be on LinkedIn, because it’s the most popular business professional network, where many people are trying to gain and increase their “personal brand”.
Although it seems a great way to gain some free “personal brand”, I think the person who will write a recommendation for a friend or colleague must think twice before do it:

Among other questions I will start with:

1) In your professional analysis is it really true what are you writing about your friend?
2) Are you ready to answer about the words you used to recommend your “friend”, to your boss, ex boss, future boss, colleague, friend, etc.?
3) Do you want to be accountable for a future failure of your recommendation just because someone who trusts your judgment accepted it has true?

On LinkedIn it’s not about what people are saying about you, I can value more your value, reading the recommendations written by you, because it reflects your judgments, person analysis, technical and personal soft skills, etc. If you can do a good analysis, probably you know something about the subject you are talking about, and that values you, not the person that you are recommending.
Even being a friend of yours, it’s your reputation in the game, and above all in the the social network, visible to thousands of people, including head hunters and job opportunities.
Sometimes people ask me if I know/recommend someone to a specific job. Sometimes I know someone, sometimes not, but I always try to recommend a person that I know it will do the job, and be careful enough to say what I know about the person and don’t risk to blindly recommend her/him, and in the future be the guy who cant analyze people, who has recommended a failure, that will be my failure. How can I, in the future, present my self as a Team Leader, Project Manager or a Senior if I cant analyze the skills of someone? And, these skills must be not just technical ones, but soft skills too.

So, my “recommendation”: be very honest when you recommend someone on LinkedIn or other social network, because its not about the person who are recommending, but its, above all, the content of your recommendation about that person, which will reflect you as a professional. And it will be your name and your reputation, and your capacity as a business professional.

Don’t jeopardize your future just because he’s a friend.
Sometimes, it’s hard to say no to a friend, he could not understand a friend saying no to a “little help” for is professional life. In that case, I recommend you to be honest, try to focus on things that are really true, and if that friend had to work with you, what role do you think will fit in him? That, I think, it will be the content of your recommendation.

Hope it helps you in the future!

José Cruz

Java Blocks–Advanced–Part 1

Following a previous post I will deep into the discussion about anonymous blocks mixed with static variables.

Lets see a simple example, and then we will complicate a little bit.

public class TestStaticInitializer {

{
System.out.println(“block 1”);
}

public TestStaticInitializer() {
System.out.println(“static x = ” + x);
}

private static int staticInitialization() {

System.out.println(“static initialization of x”);

return 5;
}

{
System.out.println(“block 2”);
}

static int x = staticInitialization();

public static void main(String[] args) {

System.out.println(“static main block before calling the constructor”);

TestStaticInitializer test = new TestStaticInitializer();

System.out.println(“static main block after constructor”);
}

{
System.out.println(“block 3”);
}

}

You can observe that:
– There is a static variable ‘x’ that its initialized calling a static method.
– There are 3 anonymous blocks.
– The constructor calls the static variable.

The main method references the class.

At first sight we can think the anonymous blocks are called in sequence, which it’s true. Although if there is a static variable initialized in anyway, this initialization runs before any anonymous block.(Why? Because a class is loaded in 2 phases: load class, run class. At load the JVM after some verification, initialized every static variable and runs any static anonymous initializer, and only after runs the class, or our instance.)

You can observe this by looking to the execution output:

static initialization of x
static main block before calling the constructor
block 1
block 2
block 3
static x = 5
static main block after constructor

The anonynous blocks are executed by sequence, but the initialization variable “static initialization of x” runs first, although its declaration is after “block 2”.

The sequence is:

1 – Initialize the static variable x

2 – run main method

3 – initialize the class (because I’m calling the constructor)

4 – run anonymous blocks

5 – runs the constructor (only after the static blocks)

6 – runs the other “main” statements.

You must be wondering why I underlined “The main method references the class” above.

Lets see if I remove (I will just comment it) the call to the class constructor.

public class TestStaticInitializer {

{
System.out.println(“static block 1”);
}

public TestStaticInitializer() {
System.out.println(“static x = ” + x);
}

private static int staticInitialization() {

System.out.println(“static initialization of x”);

return 5;
}

{
System.out.println(“static block 2”);
}

static int x = staticInitialization();

public static void main(String[] args) {

System.out.println(“static main block before calling the constructor”);

//TestStaticInitializer test = new TestStaticInitializer();

System.out.println(“static main block after constructor”);
}

{
System.out.println(“static block 3”);
}

}

and the output is:

static initialization of x
static main block before calling the constructor
static main block after constructor

Well, where are the anonymous blocks initializers? Thet are not needed! We haven’t crated any instance of the class, so the JVM just considered the static stuff!

And if a static block references the static variable x?

public class TestStaticInitializer {

{
System.out.println(“block 1”);
x = 7;
System.out.println(“block 1 after x = 7”);
    }

public TestStaticInitializer() {
System.out.println(“static x = ” + x);
}

private static int staticInitialization() {

System.out.println(“static initialization of x”);

return 5;
}

{
System.out.println(“block 2”);
}

static int x = staticInitialization();

public static void main(String[] args) {

System.out.println(“static main block before calling the constructor”);

//TestStaticInitializer test = new TestStaticInitializer();

System.out.println(“static main block after constructor”);
System.out.println(“x = ” + x);
    }

{
System.out.println(“block 3”);
}

}

The output:

static initialization of x
static main block before calling the constructor
static main block after constructor
x = 5

The initialization of “x = 7” in the first anonymous block is simple ignored, because the code was never ran!

static int x;// = staticInitialization();

The output will show you “x = 0”.

I hope this post will help you understand the mix between anonymous and static initialization blocks. In a future post I will bring some class hierarchy to this discussion.

Anonymous Java Classes and Interfaces

In java you can use Anonymous Classes and Anonymous Interfaces.

Anonymous classes

class MyMessage {
public void printMessage() {
System.out.println("Original message");
}
}

public class TestAnonymousClass {

public static void main(String[] args) {
TestAnonymousClass tac = new TestAnonymousClass();

MyMessage m = new MyMessage();
m.printMessage();

tac.showGeneralMessage(new MyMessage() {
public void printMessage() {
System.out.println("Override message");
}
}
);
}

void showGeneralMessage(MyMessage msg) {
msg.printMessage();
}
}

The Bold source shows how to create the anonymous class. As you can see it’s not so anonymous as we expected, it’s just the name that is anonymous.

In anonymous classes the only think we can do it’s to instantiate an existing class, and override or add some methods. What are we really doing is extending another class(in our example we are extending “MyMessage”) with the possibility to override or add new methods.

If you run the code above the output will be:

Original message

Override message

Anonymous Classes with interfaces

interface MyMessage {
void printMessage();
}

public class TestAnonymousClass {

public static void main(String[] args) {
TestAnonymousClass tac = new TestAnonymousClass();

tac.showGeneralMessage(new MyMessage() {
public void printMessage() {
System.out.println("Override message");
}
}
);
}

void showGeneralMessage(MyMessage msg) {
msg.printMessage();
}
}

Now with interfaces, you can observe that the syntax it’s the same, but we are creating a class by “implementing” the interface MyMessage.

Look that I only changed the MyMessage class to be and interface, but the remaining code is still the same and works with the same behavior (ok, now the output doesn’t have the “Original Message”, because we don’t have one! We lost it when we changed the class to be an interface.)

Hope it helps you in your projects, to implement callbacks, using swing components to register listeners, etc..

Technorati Tags: ,,,

Windows Live Tags: Anonymous,Java,Classes,Interfaces

WordPress Tags: Anonymous,Java,Classes,Interfaces

Java Initialization Blocks

Java has some features that are not well know from a lot of Java Developers, even developers with 5 and 10 years of Java Experience.As a Oracle/Java trainer I must study all of them to teach my students and prepare them well for the Java Certification.

One of these bot well know features are java Initialization blocks. One of these are blocks runs before the JVM runs any code (at class loader level) and the other one runs at constructor time.

Lets see an example and an explanation:

Instance Block
class MyClass {
private int x;
{
x = 7;
System.out.println(“This is called inside constructor, just after super(…)”);
}

public MyClass() {
System.out.println(“the constructor”);
}
}
Static Block
class MyClass {
private int x;
public static int y;
static {
y = 7; // y must be static!
System.out.println(“This is called by class loader before your program runs!”);
// x = 5; it’s illegal because this is class context and not instance context
}

public MyClass() {
System.out.println(“the constructor”);
}
}

So, there are 2 types of code initialization blocks:

Instance

When we talk about instances we talk about objects, something that was already created and has memory allocated.

The instance code block is executed right after the call to super in any constructor called.

It’s a way to initialize variables in all constructors without write code in any of them, which it’s a great way to organize initialization code, too.

Static

Static context it’s called class context too. Everything that is static it’s only visible when we use de class name before the field, method or inner class. (ok, unless we use import static…)

When we talk about classes we are talking about the blueprint or definition of the object. This definition “runs” before the instance is created, so the static initialization block runs before the java interpreter and before any constructor called. So, who runs the static initialization blocks? The class loader of the Java Virtual Machine.

This is the place to initialize ONLY static variables, because they are the only ones that are visible at this time and in this context.

In the future I will post more about not so know java features.

Technorati Tags: ,,,,,,,,,
Windows Live Tags: Java,Initialization,Blocks,Instance,Static,constructor,initialize,variables,context,class
WordPress Tags: Java,Initialization,Blocks,Instance,Static,constructor,initialize,variables,context,class

Error starting jBoss inside eclipse

You install jBoss 7. Unzip it to a folder like d:\jboss.

Now install jboss tools 3.3 for eclipse indigo.

When you start the jboss from eclipse (servers tab) you get an error. The console in eclipse doesn’t show any log activity and jboss doesn’t start.

After some research you discover that eclipse cant “talk” with jboss. You can confirm this by reading jboss logs.

You start jboss with standalone.bat and it works.

I got this problem in our dev team, and after some research around I found this solution. It was so simple and at the same time one of that problems that make us thinking about changing to other version or product that I thought it was a good idea to share it.

Possible solution:

1) Go to runtime environment in eclipse options and add jdk runtime environment. Not jre.

2) Make sure that you remove the JRE probably already installed and configured from eclipse. (really! Remove it from eclipse and just let the jdk as an environment).

3) Now, start jboss from the tab servers. It must work by now.

Technorati Tags: ,,,,,
Windows Live Tags: troubleshooting,java,eclipse,j2ee,Error,jboss
WordPress Tags: troubleshooting,java,eclipse,j2ee,Error,jboss

Learning PHP – Step 4 – Statements

In my last post I’ve talked about variables and operators. Now, lets see what can we do with them.

Statement: if

The “if” statement has 3 main forms:





Learning PHP – Step 2


$name = "José Cruz";
$even = 10 % 2;
$odd = 10 % 3;
$someValue = $even * 4;
$ifvar = 1;

// it’s even – simple "if"
if($even == 0) {
echo "10 its even!";
}

// it’s even – simple "if" with an else
if($even == 0) {
echo "10 its even!";
} else {
echo "10 its odd! Really?";
}

// it’s even – complex "if"
if($even == 0) {
echo "10 its even!";
} elseif($ifvar == 1) {
echo "Althougth true, the first branch has already taken the flow! :(";
} elseif($ifvar == 2) {
echo "Just to ensure you understand this construction!";
} else {
echo "10 its odd! Really?";
}
?>

Statement: switch

“switch” it’s a variation of “if”, but for cases where we have some kind of a list of values belonging to a common domain, like: weekdays, months, (1,3,4,5), etc.

The expression inside “switch()” its evaluated and the result will be compared with each of the “case ”. Each “case” can have the “break” statement, which terminates the statement. If its missing, the execution flow goes to the very next “case” (if its valid) until a “break” it’s found.

If a “case ” was not found, then the “default” its used (it it exists).





Learning PHP – Step 2


$weekday = 1; // assuming a week starts on sunday with value 1

switch($weekday) {
case 1:
echo "Sunday";
break;
case 2:
echo "Monday";
break;
case 3:
echo "Tuesday";
break;
case 4:
echo "Wednesday";
break;
case 5:
echo "Thursday";
break;
case 6:
echo "Friday";
break;
case 7:
echo "Saturday";
break;
default:
echo "big mistake1";
}


?>

And that’s it!

Next post about loops!

Technorati Tags: ,,,,,,,
Windows Live Tags: programming,else,switch,if,php,Statements,expression,break
WordPress Tags: programming,else,switch,if,php,Statements,expression,break

Learning PHP – Step 3 Basics

Following previous posts, lets start with the basics.

Variables:

– Always start with $ and can have the following chars _ [a-z] [A-Z] and [0-9]. the first symbol must be an _ ou a letter.

$count = 0;
$name = “José Cruz”

What about types? If you know python, ruby or the “var x = 0;” construction from C# you know how PHP works. It converts the variable for the type defined by the value initialized. For instance: $count = 0; will be an “integer”.

Lets use some variables in our script:





Learning PHP – Step 2


$name = "José Cruz";
echo $name . " is starting to understand PHP!";
?>

If you run the script above it will display “José Cruz is starting to understand PHP!”

PS: The dot between $name and “ is starting… ” is the concatenation in strings. This is new. Other languages usually use the plus sign or some function to do it.

The operators are the same as C or mainstream languages:

Arithmetic: +, ++, –, –, *, /, %

Assignment: =, +=, –=, *=, /=, %=, .=

Comparasion: ==, <=, <, >= >, <>, !=

Logic: &&, ||, !

PS: You can use “(“ and “)”

Some examples:

$a = 5 + 2 * (7 + 5);
$a++;
$b = $a –4;
$c = $a / $b;
$even = 10 % 2;
$a+=7; // same as $a = $a + 7;
$even = 10;
$even %= 2;
$verytrue = 2 < 7;
$veryfalse = 6 >= 3;
if( $a > 3 ) …. // future post we talk about if and other statements.
if( $a > 3 && $b < 10 || $even == 0 ) …

As with other languages:

– Unary operators precede all other ones ( “!” )

– then: *, / and &&

– Last: +, –, ||

Lets try this in our php website:





Learning PHP – Step 2


$name = "José Cruz";
$even = 10 % 2;
$odd = 10 % 3;
$someValue = $even * 4;

echo $name . " is starting to understand PHP with some operators" . "
";
echo "even values: ". $even . "
";
echo "odd values: ". $odd . "
";
echo "some value = " + $someValue . "
";
?>

Run it!

Next post: statements.

Technorati Tags: ,,,,
WordPress Tags: language,programming,Variables,Basics,PHP

Learning PHP – Step 2

Following my previous post I’m now preparing an environment to develop in PHP.

1) Install XAMPP – There are other alternatives, but this one, after some research was my choice. Why? Because in the future I’m thinking developing some skills in Perl and with XAMPP it’s a 2 in 1! (Besides mysql included!)

2) IDE – I’m trying Netbeans 7.1. There are a lot others IDEs out there like: komodo, phpstorm, phpide, aptana, eclipse, phpdesigner. My choice probably it’s not the best one, but I develop in Visual Studio and Eclipse and as a Oracle trainer, sometimes I have to use Netbeans. I will try it, if the experience gets troubled I will change to another and keep this learning. I think, anyway, the experience will be always positive.

I’m now following the steps to create a project in Netbeans…

  • New Project PHP
  • Advantage – Netbeans detected my xampp instalation and discovered where to put the php files.
  • Project name: LearningPHP (in my drive sits at: D:\xampp\htdocs\LearningPHP)
  • Local Web Site
  • Project URL: http://localhost:8001/LearningPHP/
  • I will not use any PHP framework… maybe in a future post I’ll try one besides WordPress.

After the wizard I have the file below already created:

index.php (the first file in any web tech is always index.








// put your code here
?>

Now I will change the Title and put some basic code inside the





Learning PHP – Step 2


echo "My second step to learn php!";
?>

Let’s run it (In Netbeans just hit the “play”!

PS: Make sure xampp is running and the port it’s the correct one. In my example the url is: http://localhost:8001/LearningPHP/index.php

and the result, as expected, it’s the browser output:

My second step to learn php!

Now, I have an environment to run php and a first “hello word” example.

Next post: The usual language basics of php!

Learning PHP – Step 1

I develop in several programming languages like C#, VB.NET, VB, Java, JavaScript, Python, Groovy, Powershell, PL-SQL, T-SQL, a little of Ruby, C, C++, Assembly (in the last years not so often), Prolog, List/Scheme, F#, Perl and and few others less used. I’ve read and I can understand PHP, from the knowledge I have from “C” Languages, but I never developed a complete project in PHP, and I don’t know if in the future I will need to do it, but from what I’ve been reading PHP is used in the TOP CMS Frameworks/Applications as WordPress, Drupal, Joomla, etc.

I’m thinking to create a synergy here, I will deep my understanding and knowledge about PHP and WordPress, tweaking my blog, this blog! Which I think will enrich my CV and, in the future, my career, making me a better team leader and software architect.

Starting PHP.

1) It’s a language to use in web sites.

2) You mix HTML with PHP, which is different from ASP.NET and JSP for instance. To differentiate the HTML from PHP you use in the middle of the HTML. The server will know how to process the PHP and merge it with HTML.



My first example in PHP


This code will output “My first PHP!” in the browser.

Great! It’s the first step!

Next Post let’s install the software we need to run this example. Then, the sky it’s the limit!

Bad Behavior has blocked 141 access attempts in the last 7 days.

Hyper Smash