Archive

Archive for January, 2011

Where’s my Java reflection?, Part II

January 30th, 2011

Just to give the final implementation started in “Where’s my Java reflection“, here it goes the implementation of the generator for the method bindErrors (check last post “Where’s my Java reflection“ to get into context):

private void composeBindErrorsMethod(TreeLogger logger,
			SourceWriter sourceWriter, TypeOracle typeOracle) {

		sourceWriter.println("public void bindErrors("
				+ parameterizedType.getQualifiedSourceName()
				+ " object, Map<String, List<String>> errors) {");

		// Get the fields declared in the parameterized type
		JField[] fields = parameterizedType.getFields();
		for (JField field : fields) {

			JClassType classType = field.getType().isClass();
			if (classType != null) {

				JClassType erroableType = typeOracle.findType(Errorable.class
						.getName());

				if (classType.isAssignableTo(erroableType)) {

					sourceWriter.println("if (errors.containsKey(\""
							+ field.getName() + "\")){");
					sourceWriter.println("object." + field.getName()
							+ ".setErrors(errors.get(\"" + field.getName()
							+ "\"));");
					sourceWriter.println("}");

				}
			}

		}
		sourceWriter.println("}");

Again, hope it helps anyone.

GWT, java, programming, WEB 2.0

Where’s my Java reflection?

January 30th, 2011

Some people like it, others don’t. I like it, it’s so cool to make generic code, but as I ‘ve been experimenting with GTW to know it’s capabilities I found that GWT does not support Reflection. It uses instead a mechanism called Deffered Binding to overcome the lack of reflection.

When doing some kind of framework code with GWT, soon you’ll realize that you need reflection, as I did. Bad luck, you’ll have to dig into the underground features of GWT, namely deferred bindings and generators. You can learn the theoretical traits of Deferred Bindings in the documentation: http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsDeferred.html

Let me explain my scenario.

Read more…

GWT, java, Javascript, Software, WEB 2.0

Ahh, a responsabilidade…

January 30th, 2011

Na semana passada estive presente numa formação onde se tocaram em temas bastante interessantes. Um dos temas abordados e que me chamou a atenção foi o “Modelo de Responsabilidade“.

O “Modelo de Responsabilidade” tenta descrever como nós, humanos,  geralmente nos comportamos face aos problemas que encontramos diariamente. Acho que este modelo descreve algo que nasce conosco, as atitudes e sentimentos que foram cultivados durante milhões de anos de evolução.

Read more…

Agile, Gestão, Gestão de Projecto, SCRUM