Feed on
Posts
Comments

Thanks John

Today I’m very sorry at the news of the death of John McCarthy, definitively one of the most fascinating person in Computer Science, according to my poor opinion.
Yes, I’m not using LISP in my day work, but still I considered one of the best programming language you can learn from any perspective.
A good and funnny guide is definitively this one http://lisperati.com/

This reminds me also that’s time to read something more about AI :)

I strongly believe that the real challenge in the SW development as nothing to deal with the engineering process, but much more on the team management and human resources.
I came across this article about Steve Jobs and it’s extremely clear which was the “difference”
http://www.thedailybeast.com/newsweek/2011/08/28/steve-jobs-his-10-commandments.html?fb_ref=interactive&fb_source=home_oneline

  • Go for perfect
  • Tap the experts
  • Be ruthless
  • Shun focus groups
  • Never stop studying
  • Simplify
  • Keep you secrets
  • Keep teams small
  • Use more carrot than sticks
  • Prototype to the extreme
  • My favourite? Of course the last one!

Apache CXF

For a large project I’m currently involved we were discussing a good technology to use in combination with Spring 3.0 to create a light SOA infrastructure based on a few Web Service and several restful services.

The solution came with Apache Cxf a very easy to adapt technology in combination with Spring and extremely fast to develop.

2 Minutes Guide
Basically to declare a Restful service, you need just to annotate a normal Business Logic class:

1
2
3
4
5
6
7
	@Override
	@Transactional
	@GET
	@Path("get/{grantId}/")
	public Grant get(@PathParam("grantId") Integer </code>id) {
		return grantService.getGrant(id);
	}

Not very different if you want a Soap Service

1
2
3
4
5
6
@WebService(endpointInterface = "eu.innovationengineering.matchpoint.service.soap.GrantSearch")
@Component("grantSearch")
public class DefaultGrantSearch implements GrantSearch {
 
	@Autowired
	private GrantService grantService;

Also the combination with Spring it’s fairly simple. After you define the path of your Apache Cxf servlet in the web.xml

1
2
3
4
5
6
7
8
9
10
11
<!-- APACHE CXF WEB SERVICE -->
	<servlet>
		<servlet-name>CXFServlet</servlet-name>
		<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
 
	<servlet-mapping>
		<servlet-name>CXFServlet</servlet-name>
		<url-pattern>/service/*</url-pattern>
	</servlet-mapping>

to avoid overlapping with spring MVC servlet for example, you can plug in apache cxf into the normal spring beans injections using the support for namespace.

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
43
44
45
46
47
48
49
50
51
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:jaxws="http://cxf.apache.org/jaxws"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context-3.0.xsd
     http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
     http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
        ">
 
 
	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
 
	<import resource="classpath:matchpoint-serviceContext.xml" />
 
	<jaxrs:server id="restServices" address="/rest">
		<jaxrs:serviceBeans>
			<bean
				class="eu.innovationengineering.matchpoint.service.restful.impl.DefaultGrantRestService" />
 
				<bean
				class="eu.innovationengineering.matchpoint.service.restful.impl.DefaultContactsService" />
 
					<bean
				class="eu.innovationengineering.matchpoint.service.restful.impl.DefaultProjectRestService" />
 
 
		</jaxrs:serviceBeans>
		<jaxrs:extensionMappings>
			<entry key="json" value="application/json" />
			<entry key="xml" value="application/xml" />
		</jaxrs:extensionMappings>
		<jaxrs:languageMappings />
	</jaxrs:server>
 
 
	<jaxws:server id="searchGrant"
		serviceClass="eu.innovationengineering.matchpoint.service.soap.impl.DefaultGrantSearch"
		serviceBean="#grantSearch" address="/SearchGrant" />
	<!-- <jaxws:endpoint id="searchGrant" implementor="grantWebService" implementorClass="eu.innovationengineering.matchpoint.service.soap.impl.DefaultGrantWebService" 
		address="/SearchGrant" /> -->
	<!-- <jaxws:client id="searchGrantClient" serviceClass="eu.innovationengineering.matchpoint.service.soap.GrantWebService" 
		address="http://localhost:8080/matchpoint/service/SearchGrant" /> Connect 
		a client use as a normal Spring Bean -->
 
</beans>

As you can see, support for XML/JSON in restful is automatically provided by the framework but in order to use not primitive objects in your response you need to annotate your domain object class with the following Jaxb annotation

1
2
3
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD) 
public class Grant implements Cloneable, Serializable{

Basically that’s it, and in my case it solved a lot of problems :)

Ops, if you use maven just add this to your pom

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!-- APACHE CXF -->
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxws</artifactId>
			<version>${cxf.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-http</artifactId>
			<version>${cxf.version}</version>
		</dependency>
 
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxrs</artifactId>
			<version>${cxf.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-core</artifactId>
			<version>${cxf.version}</version>
		</dependency>

Android design tips

I’ve recently find this slides, which is partially useful to design and Android application. It’s very basic, but enough clear…

Wimove (Turismo Roma)

I’ve recently published a new application on the Android Market. It is the project Wimove, an official guide to Rome.
The platform contains more than 10000 items, from events to museum, and it’s fully geolocated.

If you pass by Rome, this is something that can help you discover the city!

The idea that new code is better than old is patently absurd. Old code has been used. It has been tested. Lots of bugs have been found, and they’ve been fixed. There’s nothing wrong with it. It doesn’t acquire bugs just by sitting around on your hard drive. Au contraire, baby! Is software supposed to be like an old Dodge Dart, that rusts just sitting in the garage? Is software like a teddy bear that’s kind of gross if it’s not made out of all new material?
http://www.joelonsoftware.com/articles/fog0000000069.html
Lesson to learn: It’s worth to spend time to read and understand code!!

Best link of the month…

http://stackoverflow.com/questions/84556/whats-your-favorite-programmer-cartoon

In particular, the best short description of the “difficulties” in a project development

Recently, Google published the Android code  http://source.android.com/.

One of the thing annoying writing an Android project is the fact that it was impossible to have the source code attached to the android.jar, and so was actually hard to look properly at the core framework when coding.

To solve this problem is now possible  to add the Android source automatically to the project and so browsing the sources conveniently.
Here’s a basic list of steps to do:

  1. Create a directory “sources” on ANDROID_HOME directory
  2. Import into this folder the Java sources.
    Is known that Android uses Git as source control system. To import the project so type the following command

    git-clone git://git.source.android.com/platform/frameworks/base android-api

    Then copy the Java folders into the sources directory.
    If should see at the end of the process the following structures of the “sources” directory if you type the command
    ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
    |-android
    |---accounts
    |---annotation
    |---app
    |---bluetooth
    |---content
    |-----pm
    |-----res
    |---database
    |-----sqlite
    |---ddm
    |---debug
    |---gadget
    |---graphics
    |---hardware
    |---inputmethodservice
    |---net
    |-----http
    |---os
    |---pim
    |---preference
    |---provider
    |---security
    |---server
    |-----checkin
    |-----data
    |-----search
    |---speech
    |-----srec
    |---syncml
    |-----pim
    |-------vcalendar
    |-------vcard
    |---test
    |-----suitebuilder
    |-------annotation
    |---text
    |-----format
    |-----method
    |-----style
    |-----util
    |---util
    |---view
    |-----animation
    |-----inputmethod
    |---webkit
    |-----gears
    |---widget
    |-com
    |---android
    |-----internal
    |-------app
    |-------database
    |-------gadget
    |-------http
    |---------multipart
    |-------logging
    |-------os
    |-------policy
    |-------preference
    |-------util
    |-------view
    |---------menu
    |-------widget
    |-----layoutlib
    |-------bridge
    |-----server
    |---google
    |-----android
    |-------collect
    |-------gdata
    |---------client
    |-------maps
    |-------mms
    |---------pdu
    |---------util
    |-------net
    |-------util
  3. Restart eclipse and it’s done, you can CTRL+click on a class an do directly to the Android source Java

screenshot.png

    Browsing the web i found also a PYTHON script very useful to download the Android Java sources and package them into a zip file

    
    
    from __future__ import with_statement  # for Python < 2.6import os
    
    import re
    
    import zipfile
    
    # open a zip file
    
    DST_FILE = ‘android-sources.zip’
    
    if os.path.exists(DST_FILE):
    
    print DST_FILE, “already exists”
    
    exit(1)
    
    zip = zipfile.ZipFile(DST_FILE, ‘w’, zipfile.ZIP_DEFLATED)
    
    # some files are duplicated, copy them only once
    
    written = {}
    
    # iterate over all Java files
    
    for dir, subdirs, files in os.walk(’.'):
    
    for file in files:
    
    if file.endswith(’.java’):
    
    # search package name
    
    path = os.path.join(dir, file)
    
    with open(path) as f:
    
    for line in f:
    
    match = re.match(r’s*packages+([a-zA-Z0-9._]+);’, line)
    
    if match:
    
    # copy source into the zip file using the package as path
    
    zippath = match.group(1).replace(’.', ‘/’) + ‘/’ + file
    
    if zippath not in written:
    
    written[zippath] = 1
    
    zip.write(path, zippath)
    
    break;
    
    zip.close()

    The Big Question


    My friend Hubert posted on StackOverflow the Question:
    How do you ensure code quality?
    Well, not easy to answer and seems that there’s a lot of discussion here.

    My personal opinion here is pretty simple: “Code quality is a matter of continuous improvement and commitment”.

    Generally I would say it’s a matter of:

    • people

    • methodology

    • attitude

    • realism

    The team is the first step. A good team is made up of at least one very senior experienced guy capable of leading the enthusiasm of the youngers.

    Methodology.
    I like Agile approach, even if sometimes there’s a big mistake here. Agile doesn’t mean lack of documentation and architectural overview on the project!

    Attitude
    Man, motivation is for a developer is simply necessary. The more motivation you have, the more you’re capable of overwhelming the technical difficulties.

    Realism
    Don’t reinvent the wheel! Don’t loose the focus on your objectives. First get you code working and then take your time for a full re-factoring.

    New Blog, new Life

    Yes, I moved back to Italy, after a wonderful life and professional adventure in Amsterdam working for Tom Tom.

    At the moment I am living in Rome an I am working, mainly remotely, for Italian an English companies.

    Of course this blog is just for me and just to track my thoughts in the time.

    Main arguments will be of course related to technologies, but I could use it to express some ideas about the actual situation of the Italian society and politics, so hard to understand for a foreign eye (well, even for me sometimes).

    Why in English? I consider this one the natural language of Internet…so a natural language for a blog