The Blog

The pain with Liferay themes

published December 23, 2009

During this year, I have seen development of 5 Liferay themes and I do not like what I see. This stuff takes way more time than it should. Usually in our projects, a HTML layout is created by a UI designer working “outside of a project” and that layout is afterwards converted into a Liferay theme by a developer or UI specialist working “inside our project”. Immediate problems can arise if the HTML layout is designed wrong way.

The most basic error is to completely ignore how a portal framework creates portlets and the HTML it produces. You should know how HTML divs and other Liferay elements are created. Ignoring this will create a nasty mismatch when the layout is converted into a Liferay theme.

If you manage to get a good HTML layout, theme conversion is much easier but still takes a lot of time.  It is common to see 90% of theme ready quite quickly and use another 90% of time to fix remaining 10 percents. Common problems include:

  • Cross-browser functionality, to get all browsers to render perfectly.
  • Fixing broken Liferay controls, i.e. portlet controls, drag and drop, etc.
  • Fixing broken themes during a Liferay upgrade. This is a major one.

You will need a specialist who can handle these things and who knows what she is doing. Without her, it will cost you, a lot. I would like to see solutions on how to easily create a theme without a hassle.

Samuli @ 17:41 (No Comments)

tags: ,

Trackback URL

Character encoding, character set, and more

published December 21, 2009

These things come up in every project I work in and I have to admit that I have never fully understood every detail about character sets and encodings. So now, I finally had to find out. In this article I will answer at least following questions:

  • What is character encoding?
  • What is a character set?
  • What is the difference between character set and character encoding?
  • What is a Unicode and how does that relate to UTF-8, UTF-16, and UTF-32?
  • What is the difference between HTTP Content-Type header and HTML meta tag content-type, and why do we need both?
  • What about MySQL connection string parameters, database character set and collation?

Let’s get started!

The basics

We all use characters to form words. In the magic world of computers we are going to need a system that converts characters into bits.  Sure, it would be nice to have only one set of rules that could handle each and every case, but as we know, it is not that simple. While there are very old encodings, we will start at ASCII standard which was introduced back in the 1960s. It defines 128 code-character pairs, which together form a coded character set that uses 7 bits to represent each character on a media. Each of these code representations are called code points. So, ASCII standard defines a character repertoire of 128 characters in which the first 32 code points are reserved for control characters.

What are character set and character encoding?

Character set defines characters available in a set and their code points, whereas character encoding defines how code points are represented on a media. In practice they are used interchangeably. Historically they were synonyms because a same standard used to define the characters available as well as the actual encoding rules. Now things have changed and character set can be encoded with different encoding system.

All ASCII, ISO-8859-1, and Unicode character sets use value 65 for a character “A”. However, ASCII uses 7 bits for character encoding whereas ISO-8859-1 uses 8 bits.

Unicode, UTF-8, UTF-16 and UTF-32

Unicode is a character set. It defines 17 planes, in which each can containing up to 65 536 characters. This enables encoding of 1 114 112 characters. Similar characters are collected on same planes and most of the characters in a languages spoken today are collected in the first one, called Basic Multilingual Plane. Each of the characters in the Unicode character set can be represented using UTF-8/16/32 character encoding.

UTF-8 encodes characters using 1-4 bytes. The Length of the stream depends on the character encoded. It is backwards compatible with ASCII often making it the choice today.

UTF-16 is also a variable-length encoding. It uses 2-4 bytes to represent a character.

UTF-32 is the most straight forward encoding scheme, which always uses 4 bytes to represent a character.

What is the difference between HTTP Content-Type header and HTML meta tag content-type, and why do we need both?

When HTML content is transferred over network, both a server and a client will need to know how to encode and decode a stream. In an initial HTTP request, the client sends the request with an “Accept-Charset” header, which tells the server how it will want a results encoded. In the response, the server should include “Content-Type” HTTP header as well as a content-type meta tag inside HTML and they both should declare same encoding.

There is a nice article you can read. Basically both have precedence rules which will tell the client which one to use. In the case of a XHTML response, precedence is

1) HTTP header
2) Meta tag

    In the case where the HTTP header is present, browser will use it. But afterwards when content is saved on a disk either by a user or a proxy, the Content-Type HTTP response header is lost. In this case, used character encoding can be read from the meta tag from the saved file. That is why you need both.

    In a Java world, the HTTP response content type can be set using ServletResponse.setCharacterEncoding() if default ISO-8859-1 is not suitable. If you have Apache, you can use AddCharset directive.

    How the MySQL database character set and collation work in this picture?

    All text in a database is encoded in some format. The MySQL will encode characters into database using character set defined for it. Collation is a set of rules how characters are compared inside character set. Collation tells sorting engine whether a character “A” come before or after a character “B”.

    MySQL connection string encodings

    You can define many properties for MySQL jdbc connection. For example, you can use property “characterEncoding” to tell JDBC driver to encode queries using given character encoding. You can alter a result set encoding by using “characterSetResults” property.

    Gimme some pictures!

    In a picture below you can see character encoding working:

    character-encoding

    Samuli @ 22:03 (No Comments)

    tags:

    Trackback URL

    Passing a Scrum master role forward

    published December 18, 2009

    My coaching week is almost over. During this week I have been working as a developer while mentoring our temporary Scrum Master. We decided to change roles as it was OK with a customer and team member had interest in working as a Scrum Master. Week has been a success and I have learned lot about my assets:

    • I still have skills to work as a developer :)
    • I have ability to work as a coach.
    • I am pretty good at grasping big pictures.
    • I have an intuition about upcoming problems.

    Also by watching Scrum Master to work, I clearly see a lot of value in keeping daily scrums short, focusing on impediments, and keeping the team on a sprint track. If you have not tried changing roles, I recommend you try it.

    Samuli @ 21:52 (One Comment)

    tags: , ,

    Trackback URL

    Hash the passwords!

    published December 15, 2009

    Great, my washing machine broke down after only 9 months of usage. I rembered that it should still have a valid guarantee. Since I bought it online, I figured the receipt was probably still available. So, I tried to log in to a online shop where the purchase was made, but could not remember my password for this site. “Lukily” site had a “forgot your password” -feature. After providing my email address, the password was sent to me in plain text. This means that everybody’s passwords are stored in database in plain text without a one way hash. Now, if you are working with any user data, please hash passwords and use salt. This is so basic stuff that it makes me angry even to write about it. The “forgot your password” -feature must be implemented as a “reset your password”. Goddammit.

    Samuli @ 21:57 (No Comments)

    tags:

    Trackback URL

    A question to ask in a sprint retrospective

    published

    “What should we do differently during the next sprint?”. That was the way I opened our retrospective on Friday. No one answered. Hmm, everything is as good as it gets, case closed, Right? Wrong, you should dig deeper.  “Ok, name one thing that you will not want to do during our next sprint”. This one sunk in.  Answers and corresponding actions were:

    • Team member 1: “I do not want to do software development” (this was a joke, but we decided to take action) = Ok, you will be working as a temporary Scrum Master for the first week of the next sprint.
    • Team member 2: “I do not want to fix so many selenium tests at the end of the sprint” = Great, we will fix all tests first thing every morning.
    • Team member 3: “I do not want to do as much bug fixing, testing and deployment as I did in this sprint” = We will have to find a way for you to make more new features.
    • Team member 4: “I do not want to code javascript in the next sprint, but if I have to then I guess I must” = Sometimes you just have to :)

    And now during first week I will be doing development and first task is building of a Liferay community  POC, sweet.

    Samuli @ 21:52 (No Comments)

    tags: ,

    Trackback URL

    The co-worker effect

    published December 8, 2009

    How many of you study on your free time? I do, but you only have so many hours in a day. This is where your active work environment and skilled co-workers come into play. If you are working for an employer that does not employ the best of the best you are not pushed to your limits. Adding the fact that equally skilled people tend to cluster, you are not growing as fast as you could if your co-workers are below average.

    This brings us to an inner circle. Especially when leading, you need an excellent inner circle. Purpose of the inner circle is to bring the best out of you and to compensate on your weaknesses. In a return you help your inner circle members to fully reach their potential. Since an working inner circle is not built by accident and all good things are done together, you need to focus on building it.

    That is why you should always aim to work with the best.

    Samuli @ 21:00 (No Comments)

    tags: ,

    Trackback URL

    How to create products customers love

    published December 3, 2009

    Yesterday I finished reading book by Marty Cagan “How to create products customers love” and I recommend it for team leaders and for everyone working in product owner or project manager roles. Book is about product management and Mr. Cagan is stating that custom software (consulting) is running by somewhat different rules. Still, there are much to learn from the product business that directly applies to consulting.

    I discovered product management through Poppendiecks’ book “Implementing Lean Software Development: From Concept to Cash“. Their message is that custom software world should learn from how great software products are built. I totally agree.  In the product world, customers’ problems and product vision must be very well understood and communicated by a product manager. In my experience, the custom software world is doing these two things often poorly.  A Lot of custom development in corporate settings is done for internal applications and I think that the concept of customer is somewhat vague.  In my opinion, the ultimate customers for the internal applications are end users and I do not see them very often involved in the building of those applications.  Good product managers are hard to find and in corporate settings customer project manager is often working as product manager and “proxy end user”. In reality these are all different roles and they require different skill set. If you throw in the fact that customers in general do not know exactly what they want, you find yourself in “regular” consulting project.

    Agile methods attack this issue by delivering value incrementally so that results are seen after every sprint and correct solution is built. However, I feel this very thing is working as a excuse for not having a clear vision for a solution, which is absolutely a must in product world. This is something that a good product managers understands. In the end, successful consulting projects need competent people from both customer and integrator.

    http://www.amazon.com/Inspired-Create-Products-Customers-Love/dp/0981690408/ref=sr_1_1?ie=UTF8&s=books&qid=1259818085&sr=8-1

    Samuli @ 19:17 (No Comments)

    tags: ,

    Trackback URL

    Subscribe to RSS feed

    The Tag Cloud
    The Blog Archive

    February 2012 (1)

    January 2012 (1)

    November 2011 (1)

    June 2011 (2)

    May 2011 (1)

    April 2011 (2)

    March 2011 (2)

    February 2011 (1)

    January 2011 (1)

    December 2010 (1)

    November 2010 (1)

    October 2010 (3)

    September 2010 (3)

    August 2010 (5)

    July 2010 (2)

    June 2010 (3)

    May 2010 (4)

    April 2010 (2)

    March 2010 (6)

    February 2010 (7)

    January 2010 (3)

    December 2009 (7)

    November 2009 (6)