Programming exercises for language knowledge testing in a comparison of web frameworks

{1 Comment}

This article is part of a comparison of web frameworks which tries to measure the ease of learning and development for several web frameworks with a practical test. In this article, a set of programming exercises which tries to test language knowledge is defined.

Due to the limits of the project time, a deep research has not been able to be carried out. Therefore, the expert, Juan Carlos Rodríguez del Pino, a language programming professor at the ULPGC and the author of Virtual Programming Lab, has helped in the language programming exercises definition.


A subset of the exercises used at the Computer Science School in ULPGC has been chosen. Figure 1 shows which features of the programming language the subject has to practice in each exercise.

The first exercise demonstrates knowledge of files operations, strings and regular expressions. The second exercise demonstrates basic knowledge about classes, types and structures in the language. The third exercise is the composite pattern, it demonstrates inheritance and polymorphism knowledge. The third and last exercise is the composite pattern because, despite being important in programming language knowledge, it is not considered to be important for developing the website.

Basic components such as variables, constants, data types, control structures, data structure and functions are the most used because they seem to be more important for programming with a web framework.

Language exercises learning table
Figure 1. Language exercises learning table

The Strings, Files and Regular Expressions exercise

Given a text in a file and a dictionary in another file, the output has to be a file with every word included in the text that is not inside the dictionary surrounded by square brackets and emails have to be surrounded by braces. Words which are parts of emails are not tested if they are in the dictionary.


  • Text:
Welcome to a great comparison framework. Contact me on
  • Dictionary:
  • Output:
[Welcome] to a great comparison [framework]. Contact me on {}

The Numbers Set exercise

A class NumbersSet which contains a set of numbers and has the following operations:

  • Empty constructor: A default constructor which creates empty sets.
  • Vector constructor: An optional constructor which allows to initialize the set with numbers without repeating them through a vector. If repeated, it throws an exception.
  • size: Number of numbers in the set
  • isEmpty: It gives an answer if the set is empty or has at least one number
  • add: It adds a number if it does not exist, if it exists, it throws an exception.
  • belong: It tests if a number is inside the set
  • equal: Given a set, it tests if it is equal. Two sets are equal if they have the same numbers.
  • subset: Given a set, it test if the set is a subset of the instance.
  • vector: Given a vector, it returns all the elements of the set in the vector.
  • union: Given a set, it creates the union between the set and the instance.

Example of use:

array v1={1,3,4,7,-10};
array v2={3,5,-2,1,4,8};
array v3;
NumbersSet A(v1);
NumbersSet B(v2);
NumbersSet D;
for(i=0; i<;D.size();i++){
   print v3[i];
   print " ";
print "\n";

The Composite Pattern exercise

Some documents have to be represented. A document is made up by components. A component can be some text, a number, a date or a composite component. A composite component is a collection of one or more components. Every component offers the operation:

  • toString: String representing it

The composite component has the following operations too:

  • add: It adds a component to the collection
  • size: It returns the numbers of elements in the collection
  • modify: Given a component and an index, it substitutes the element indicated by the index for the component in the input.

Define the classes Component, TextComponent,  NumberComponent, DateComponent and CompositeComponent.

Example of use:

p= new CompositeComponent;
p.add(TextComponent("String. Number"));
p.add(TextComponent("Date: "));
d= new CompositeComponent;
d.add(TextComponent("Testing composite"));
delete p;
d.add(TextComponent("End testing composite"));
print d.toString();
print "\n";
d.modify(0,TextComponent("Beginning modified"));
print d.toString();
print "\n";

I think these exercises are adequate for testing programming language knowledge in order to get ready for the web framework learning process. Is there anything else you miss?? Would you propose a different design? Which one?

Thanks for reading. Comments, criticism and sharing will be appreciated.