March 24, 2008

The Cathedral and the Bazaar

The Cathedral and the Bazaar is a very good dissertation about two completely different ways in which people write software: the open-source approach (with Linux as the main example) and the closed-source approach.

The entire text can be read freely at http://catb.org/~esr/writings/cathedral-bazaar/cathedral-bazaar/

Going into the details that the book covers would be superfluous. Like reinventing the wheel. I'll just say that it's a good reading for any software engineer, software architect or programmer.

February 23, 2008

Model-view-controller (MVC) pattern

MVC is well known architectural design pattern in the Enterprise Java world. The pattern creates a multitier architecture suitable for large scale computer application that handle large amounts of data and have a complex user interface.

The problem that the Model view controller pattern solves is the decoupling of data access and business logic from data presentation and user interaction. This way, changing the way data is handled and stored does not affect the presentation component, nor the way data is displayed affects the model.

The pattern makes a clear separation of objects in three categories:

  1. Model - contains the data handling logic as well as internal data representation
  2. View - data presentation, user interface
  3. Controller - event handling that affect the model and/or view(s)

In the case of Web applications, the View is actually the HTML page that the user sees. The controller is the code portion that interprets and dispatches the user requests to the model which may modify in return the internal data.

The MVC pattern is support in most languages designed for web applications via 3rd party frameworks: ASP .NET 3.5, PureMVC for ActionScript, Mach-II for ColdFusion, Struts for Java, Catalyst for Perl, a myriad of options of PHP, Python and Ruby

Java JSTL and JSP tags

JSTL - or the Java Standard Tag Library - provides the core functionality common to many Web applications. JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags. It also provides a framework for integrating existing custom tags with JSTL tags.

But what exactly is a tag? A tag is a JSP construct used to invoke some built-in code. It's similar to a function or a language construct (like include) in other languages.

A simple example is the jsp:include tag:

<jsp:include page="footer.jsp" >
      <jsp:param name="extrainfo" value="myinfo" />
</jsp:include>

The meaning is simple and analogous to the C/C++ #include directive. While this is not a JSTL tag, it's similar in every way to one. JSTL tags are placed in 5 categories:

  • JSTL core (c:if, c:when, c:catch etc.)
  • JSTL formatting (fmt:message, fmt:parseDate, fmt:parseNumber etc.)
  • JSTL SQL (sql:query, sql:update, sql:transaction)
  • JSTL XML (xml:parse, xml:transform, xml:forEach etc.)
  • JSTL functions (fn:substring, fn:indexOf, fn:join etc.)

The full list of tags and their arguments can be seen on the official Java JSTL page.

It should be noted that any programmer can create his own custom tag library by writing a Java class. The two requirements are that this class implements one of the Tag interfaces and that the programmer provides a tag library XML description file that specifies the tags and the java classes that implement the tags.

October 24, 2006

Brain teaser

A tricky little problem. I recently encountered it (again) at an interview. Although not complex and very easy to express, I found few people that solved it.

It goes like this: you're given a single-linked list (its head). In O(1) (constant) space complexity you have to determine if the list is circular or not. This constraint basically says that you can't use a variable for each list element (to remember if you've been there before for example).

NOTE: a circular list is also one of the type 1->2->3->4->2 - a portion of the list being outside the loop.

September 14, 2006

Automatic refactoring

To be continued...

February 14, 2006

A question of semantics: parameters vs arguments

The question I'm asking is simple: is there any difference between `parameters` and `arguments` when talking about the values a function expects?

Is it `argument list` or `parameter list`? Is it `function arguments` or `function parameters`? Is it `calling a function with these arguments` or `calling a function with these parameters`?

The answer is very simple: it's only a point of view problem. If you look from the caller's point of view, they're arguments. If you look from the callee's point of view, they're parameters.

So, which is correct for each of the above 3 pairs?

February 13, 2006

Mountain bikes - the hobby

Totally off topic, my latest hobby is biking. Mountain biking. Therefore I made a small blog about this topic - my own mountain biking blog. I'll add impressions from rides, trips and hopefully other adventures. If it's of interest to you, make a bookmark.

February 10, 2006

Is Ruby better?

Ruby, the Ruby on Rails framework. Comparison with other web frameworks

January 11, 2006

Software metrics

We measure distance in meters, mass in kilograms, time in seconds..why couldn't we measure software in some units? This is the question that made room for software metrics as a way to asses the complexity of a given software system.

However, things are not that simple. What would you say a good metric is be for software? Number of lines of code? Man hours? Number of lines of client specifications? Function point analysis?

You can easily see there's no silver bullet for this and all of the above can easily be cheated to give a bigger (or smaller) metric value so finding the perfect metric is still an open problem. There are other problems too: consider that a manager assigns his best programmer to the hardest part of the problem which means it may take the longest time to finish the task and may produce the most defects due to the difficulty of the task. Comparing programmers only from the point of a metric is therefore irrelevant.