ESSnet on SDMX

ESSnet on SDMX

WP3 Functional and Technical Specifications

WP: 3 – SDMX Data Express

WP Responsible: João Poças Date: 25/11/2009 File: WP3_Functional_and_Technical_Specifications.doc Annex: WP3_Functional_and_Technical_Specifications_AnnexI.doc

WP3 – Functional and Technical Specifications Pag. 1/14 ESSnet on SDMX

Revision history

Version Date Description Author 1.0 28/12/2009 Initial document João Poças 1.5 20/01/2009 Revised João Poças 2.0 25/11/2010 Revised João Poças

WP3 – Functional and Technical Specifications Pag. 2/14 ESSnet on SDMX

Table of Contents

1. INTRODUCTION ...... 4

1.1. PURPOSE ...... 4 1.2. PROJECT SCOPE ...... 4

2. OVERALL DESCRIPTION ...... 5

2.1. PRODUCT PERSPECTIVE ...... 5 2.2. PRODUCT FEATURES ...... 7 2.3. OPERATING ENVIRONMENT ...... 9 2.4. DESIGN AND IMPLEMENTATION CONSTRAINTS ...... 9 2.5. USER DOCUMENTATION ...... 10

3. SYSTEM INTERFACE ...... 11

3.1. WEB APPLICATION - SDMX.DX ...... 11 3.2. WEB SERVICE - SDMX.WS ...... 12 3.3. LIBRARY - SDMX.LIB ...... 12

4. REFERENCES ...... 13

5. ANNEX I – C# RULES AND NAMING CONVENTIONS ...... 14

WP3 – Functional and Technical Specifications Pag. 3/14 ESSnet on SDMX

1. INTRODUCTION

1.1. Purpose

This document provides the requirements and functional specifications and also some technical issues fundamental to the development of SDMX Data Express1.

SDMX Data Express corresponds to Work Package 3 (WP3), which is part of the project ESSnet on SDMX, and aims to develop a software application that can explore data files in SDMX format.

1.2. Project Scope

The main purpose of this WP is to deliver an application that allows the users to visualize SDMX data files under different perspectives and in a user-friendly way. These visualization perspectives includes tabular (html and CSV) and graphic (charts). The user may use any SDMX data file (local or remote) whereas the related DSD (local or remote) is also provided.

It will also provide a way to convert among different SDMX data messages formats (generic, cross sectional, compact) and provide an interface to help users to build a SDMX query (based on a given DSD file). Additionally it will be able to build a SDMX query message useful to retrieve data through an URL (invoking a web service, for instance).

1 Previous name “SDMX Data Express” was “SDMX Data Explorer”

WP3 – Functional and Technical Specifications Pag. 4/14 ESSnet on SDMX

2. OVERALL DESCRIPTION

2.1. Product Perspective

The produced application will be supported by a generic SDMX class library that can be reused in any future SDMX application. Using this generic library, programmers will be able to develop applications that operates SDMX-ML messages (create, read and write any SDMX file) in an easier way. The library will bind SDMX 2.0 standard schemas with .net classes representation, making it easy for .net developers to manipulate SDMX message files in any application (web or stand-alone).

This work package will produce the following software products: a) A web application that will allow end-users to explore SDMX data; b) A generic SDMX class library, useful for programmers; c) Some web-services that will allow SDMX messages manipulation (SDMX conversion and schema validation).

In the next diagram are represented the main components of the system, with user inputs and outputs expected, to help to understand the conceptual idea of SDMX Data Express. All these components will be discussed with more detail in this document.

WP3 – Functional and Technical Specifications Pag. 5/14 ESSnet on SDMX

Figure 2-1 – Context diagram for the SDMX Data Express

WP3 – Functional and Technical Specifications Pag. 6/14 ESSnet on SDMX

2.2. Product Features

SDMX Data Express provides a Graphic User Interface (SDMX.dx) to the common user with the following features:

• SDMX Data load User can load an SDMX data file either locally, when the SDMX document is located in his computer, or by using an external URL, if the SDMX data file is located in an internet address.

• Data Structure Definition (DSD) load In order to be able to manipulate the loaded SDMX data file, user must provide the corresponding DSD. To achieve this, the user may use a local DSD file, a remote DSD file (URL) or, if the Registry service is available, get the DSD from the Registry.

• Tabular view In Tabular view, user may consult the loaded data either in HTML format or Comma Separated Format (CSV), which can be easily read by any Text reader or Spreadsheet application.

• Chart view Using Chart view, the user is able to visualize data using a chart. The user can decide what kind of chart is the most convenient for the data (bars, columns or line chart).

• Converter The Converter is a function that is able to convert from a SDMX data message format to another.

WP3 – Functional and Technical Specifications Pag. 7/14 ESSnet on SDMX

• Query builder The Query builder helps user to build a SDMX query message, through a visual interface, using the previously loaded DSD.

• Validation After a data and structure files are loaded, user may confirm if the data file is valid. In a similar way, any SDMX query can also be validated.

Beside all the previous features, available to any user, SDMX Data Express also provides some extra resources to developers:

• SDMX library (SDMX.lib) The SDMX library is responsible for providing methods to manipulate any SDMX document. This library is able to represent, using .net classes, SDMX 2.0 standard schemas and, as a consequence, any SDMX data message file. The functions available to the user (using a graphic user interface) should be produced in this library.

• Web Service (SDMX.ws) The web service exposes operations responsible for validation and conversion, of SDMX documents, through http request.

WP3 – Functional and Technical Specifications Pag. 8/14 ESSnet on SDMX

2.3. Operating Environment

SDMX Data Express will be delivered, primarily, as a web application.

It should run on any 32-bits Microsoft Windows operating system but, considering it’s a web application, it’s necessary to have also installed the Internet Information Services (or Internet Information System) to be able to run.

The option of having SDMX Data Express delivered as a web application was adopted because it was considered a better way to have this kind of tool available to the user, through a browser, anywhere and anyplace. To achieve this, the SDMX Data Express will be available in a web server over the internet. It should be available in the ESSnet on SDMX web site.

In addition, a web service will also be produced and exposed in the same web site.

2.4. Design and implementation constraints

• Programming language The programming language adopted for the development of SDMX Data Express is C-Sharp (C#), which is part of Microsoft .Net framework 3.0. In order to assure that all participants will develop the software modules in a similar way, it is recommended to use some C# conventions and rules (see Annex I).

• Development Environment As the preferable Integrated Development Environment (IDE), it is proposed to be used the Visual Studio 2008, although Visual Web Developer 2008 Express

WP3 – Functional and Technical Specifications Pag. 9/14 ESSnet on SDMX

can also be used (this IDE is freely available at Microsoft web site, http://www.microsoft.com/express/vwd/).

• Software licence and support All software produced must be developed under European Union Public Licence (EUPL). Although all the software will be delivered as open source the development team will not guarantee to give support to developers or users after the conclusion of this project.

• Standards-based SDMX Data Express should comply with established industry standards, like XML, SDMX and HTML. The standards-compliance will not only apply to application development but also to design, platform/infrastructure and other parts of the SDMX Data Express. In terms of web service, cross-platform interoperability should be guaranteed according to the WS-I Basic Profile 1.1 (see http://www.ws-i.org/).

2.5. User documentation

Along with the software delivered some documentation will also be produced. This documentation includes user manual and installation guide, but additionally some basic developer guide will also be delivered.

WP3 – Functional and Technical Specifications Pag. 10/14 ESSnet on SDMX

3. SYSTEM INTERFACE

3.1. Web application - SDMX.dx

The interface of the SDMX Data Express (SDMX.dx) must reflect, in some way, the main functionalities previously described. So, the interface proposed for the application should be similar with the structure presented in the next diagram.

Home SDMX Data and DSD Load

Tabular view

Chart view

Conversion

Query builder

Help

Figure 3-1 – Structure diagram for the SDMX Data Express (SDMX.dx)

WP3 – Functional and Technical Specifications Pag. 11/14 ESSnet on SDMX

3.2. Web service - SDMX.ws

The web service SDMX.ws will expose some operations in order to be invoked and rapidly used by any application. Those operations are listed below.

Figure 3-2 – Web service Operations exposed in SDMX.ws

3.3. Library - SDMX.lib

The library will represent, in terms of .net classes, the SDMX 2.0 XML schemas and formats. If, during the project development, the SDMX 2.1 information model is approved it should also be considered to integrate it into this SDMX.lib.

This library will have built-in the main features delivered by SDMX Data Express application (SDMX.dx) and, additionally, other functionalities related with I/O file operations.

WP3 – Functional and Technical Specifications Pag. 12/14 ESSnet on SDMX

4. REFERENCES

• C# Coding Standards and Best Programming Practices, http://www.dotnetspider.com

• Eurostat Registry user guide (on the STNE/X-DIS library, http://circa.europa.eu/Public/irc/dsis/stne/library)

• ISO, Web Services Interoperability – WS-I Basic Profile version 1.1: (http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnum ber=45422)

• Microsoft Visual Studio Express Editions; version 2008; http://www.microsoft.com/exPress/

• SDMX Standards, Version 2, November 2005 - Registry Specifications: Logical interfaces; Implementer’s Guide for SDMX standards: http://sdmx.org/?page_id=10

• SDMX User Guide, release 2009.1 (http://sdmx.org/index.php?page_id=38)

• Web Services Interoperability Organization; WS-I Basic Profile 1.1: http://www.ws-i.org/

WP3 – Functional and Technical Specifications Pag. 13/14 ESSnet on SDMX

5. ANNEX I – C# RULES AND NAMING CONVENTIONS

WP3 – Functional and Technical Specifications Pag. 14/14

ESSnet on SDMX

WP3 Functional and Technical Specifications

Annex I C# Rules and Naming Conventions

Adapted from “C# Coding Standards and Best Programming Practices” by http://www.dotnetspider.com

Annex I - C# rules and naming conventions

Contents

1. License, Copyrights and Disclaimer ...... 3 2. Revision History ...... 3 3. Naming Conventions and Standards ...... 4 4. Indentation and Spacing ...... 6 5. Good Programming practices ...... 7 6. Architecture...... 11 7. ASP.NET ...... 12 8. Comments ...... 13 9. Exception Handling ...... 14

Annex I - C# rules and naming conventions

1. License, Copyrights and Disclaimer

This document was adapted from http://www.dotnetspider.com/tutorials/BestPractices.aspx.

You are permitted to use and distribute this document for any non commercial purpose as long as you retain this license & copyrights information.

This document is provided on “As-Is” basis. The author of this document will not be responsible for any kind of loss for you due to any inaccurate information provided in this document.

2. Revision History

If you are editing this document, you are required to fill the revision history with your name and time stamp so that anybody can easily distinguish your updates from the original author.

Sl# Date Changed By Description 1 2009.12.28 João Poças Adapt the document in order to be used in ESSnet on SDMX project

Annex I - C# rules and naming conventions

3. Naming Conventions and Standards

Note :

The terms Pascal Casing and Camel Casing are used throughout this document.

Pascal Casing - First character of all words are Upper Case and other characters are lower case.

Example: BackColor

Camel Casing - First character of all words, except the first word are Upper Case and other characters are lower case.

Example: backColor

1. Use Pascal casing for Class names

public class HelloWorld { ... }

2. Use Pascal casing for Method names

void SayHello(string name) { ... }

3. Use Camel casing for variables and method parameters

int totalCount = 0; void SayHello(string name) { string fullMessage = "Hello " + name; ... }

Annex I - C# rules and naming conventions

4. Use Meaningful, descriptive words to name variables. Do not use abbreviations.

Good: string address int salary

Not Good: string nam string addr int sal

5. Do not use single character variable names like i, n, s etc. Use names like index, temp

One exception in this case would be variables used for iterations in loops: for ( int i = 0; i < count; i++ ) { ... }

If the variable is used only as a counter for iteration and is not used anywhere else in the loop, many people still like to use a single char variable (i) instead of inventing a different suitable name.

6. Do not use underscores (_) for local variable names.

7. All member variables must be prefixed with underscore (_) so that they can be identified from other local variables.

8. Prefix boolean variables, properties and methods with “is” or similar prefixes.

Ex: private bool _isFinished

9. Namespace names should follow the standard pattern

...

In ESSnet project this is the proposed pattern: ....

10. Use appropriate prefix for the UI elements so that you can identify them from the rest of the variables.

Use a common prefix ( ui_ ) for all UI elements, (eg: Labels, TextBoxes, DataGrid, Button, …). This will help you group all of the UI elements together and easy to access all of them from the intellisense.

11. File name should match with class name (and should use Pascal Case for file names).

For example, for the class HelloWorld, the file name should be helloworld.cs (or, helloworld.vb)

Annex I - C# rules and naming conventions

4. Indentation and Spacing

1. Use TAB for indentation. Do not use SPACES. Define the Tab size as 4.

2. Comments should be in the same level as the code (use the same level of indentation).

Good:

// Format a message and display

string fullMessage = "Hello " + name; DateTime currentTime = DateTime.Now; string message = fullMessage + ", the time is : " + currentTime.ToShortTimeString(); MessageBox.Show ( message );

Not Good:

// Format a message and display string fullMessage = "Hello " + name; DateTime currentTime = DateTime.Now; string message = fullMessage + ", the time is : " + currentTime.ToShortTimeString(); MessageBox.Show ( message );

3. Use #region to group related pieces of code together. If you use proper grouping using #region, the page should like this when all definitions are collapsed.

4. Keep private member variables, properties and methods in the top of the file and public members in the bottom.

Annex I - C# rules and naming conventions

5. Good Programming practices

1. Avoid writing very long methods. A method should typically have 1~25 lines of code. If a method has more than 25 lines of code, you must consider re factoring into separate methods.

2. Method name should tell what it does. Do not use mis-leading names. If the method name is obvious, there is no need of documentation explaining what the method does.

Good: void SavePhoneNumber ( string phoneNumber ) { // Save the phone number. }

Not Good:

// This method will save the phone number. void SaveDetails ( string phoneNumber ) { // Save the phone number. }

3. A method should do only 'one job'. Do not combine more than one job in a single method, even if those jobs are very small.

Good: // Save the address. SaveAddress ( address );

// Send an email to the supervisor to inform that the address is updated. SendEmail ( address, email );

void SaveAddress ( string address ) { // Save the address. // ... }

void SendEmail ( string address, string email ) { // Send an email to inform the supervisor that the address is changed. // ... }

Not Good:

// Save address and send an email to the supervisor to inform that // the address is updated. SaveAddress ( address, email );

void SaveAddress ( string address, string email )

Annex I - C# rules and naming conventions { // Job 1. // Save the address. // ...

// Job 2. // Send an email to inform the supervisor that the address is changed. // ... }

4. Use the c# or VB.NET specific types (aliases), rather than the types defined in System namespace.

int age; (not Int16) string name; (not String) object contactInfo; (not Object)

5. Always watch for unexpected values. For example, if you are using a parameter with 2 possible values, never assume that if one is not matching then the only possibility is the other value.

Good:

If ( memberType == eMemberTypes.Registered ) { // Registered user… do something… } else if ( memberType == eMemberTypes.Guest ) { // Guest user... do something… } else { // Un expected user type. Throw an exception throw new Exception (“Un expected value “ + memberType.ToString() + “’.”)

// If we introduce a new user type in future, we can easily find // the problem here. }

6. Convert strings to lowercase or upper case before comparing. This will ensure the string will match even if the string being compared has a different case.

if ( name.ToLower() == “john” ) { //… }

Annex I - C# rules and naming conventions

7. Use String.Empty instead of “”

Good:

If ( name == String.Empty ) { // do something }

Not Good:

If ( name == “” ) { // do something }

8. Avoid using member variables. Declare local variables wherever necessary and pass it to other methods instead of sharing a member variable between methods. If you share a member variable between methods, it will be difficult to track which method changed the value and when.

9. Use enum wherever required. Do not use numbers or strings to indicate discrete values.

Good: enum MailType { Html, PlainText, Attachment }

void SendMail (string message, MailType mailType) { switch ( mailType ) { case MailType.Html: // Do something break; case MailType.PlainText: // Do something break; case MailType.Attachment: // Do something break; default: // Do something break; } }

Annex I - C# rules and naming conventions Not Good:

void SendMail (string message, string mailType) { switch ( mailType ) { case "Html": // Do something break; case "PlainText": // Do something break; case "Attachment": // Do something break; default: // Do something break; } }

10. Do not make the member variables public or protected. Keep them private and expose public/protected Properties.

11. Never hardcode a path or drive name in code. Get the application path programmatically and use relative path.

12. When displaying error messages, in addition to telling what is wrong, the message should also tell what should the user do to solve the problem. Instead of message like "Failed to update database.", suggest what should the user do: "Failed to update database. Please make sure the login id and password are correct."

13. Do not have more than one class in a single file.

14. Avoid public methods and properties, unless they really need to be accessed from outside the class. Use “internal” if they are accessed only within the same assembly.

15. Avoid passing too many parameters to a method. If you have more than 4~5 parameters, it is a good candidate to define a class or structure.

Annex I - C# rules and naming conventions

6. Architecture

1. Always use multi layer (N-Tier) architecture.

2. Never access database from the UI pages. Always have a data layer class which performs all the database related tasks. This will help you support or migrate to another database back end easily.

3. Use try-catch in your data layer to catch all database exceptions. This exception handler should record all exceptions from the database. The details recorded should include the name of the command being executed, stored proc name, parameters, connection string used etc. After recording the exception, it could be re thrown so that another layer in the application can catch it and take appropriate action.

4. Separate your application into multiple assemblies. Group all independent utility classes into a separate class library. All your database related files can be in another class library.

Annex I - C# rules and naming conventions

7. ASP.NET

1. Do not use session variables throughout the code. Use session variables only within the classes and expose methods to access the value stored in the session variables. A class can access the session using System.Web.HttpCOntext.Current.Session

2. Do not store large objects in session. Storing large objects in session may consume lot of server memory depending on the number of users.

3. Always use style sheet to control the look and feel of the pages. Never specify font name and font size in any of the pages. Use appropriate style class. This will help you to change the UI of your application easily in future. Also, if you like to support customizing the UI for each customer, it is just a matter of developing another style sheet for them

Annex I - C# rules and naming conventions

8. Comments

Good and meaningful comments make code more maintainable. However,

1. Do not write comments for every line of code and every variable declared.

2. Use // or /// for comments. Avoid using /* … */

3. Write comments wherever required. But good readable code will require very less comments. If all variables and method names are meaningful, that would make the code very readable and will not need many comments.

4. Do not write comments if the code is easily understandable without comment. The drawback of having lot of comments is, if you change the code and forget to change the comment, it will lead to more confusion.

5. Fewer lines of comments will make the code more elegant. But if the code is not clean/readable and there are less comments, that is worse.

6. If you have to use some complex or weird logic for any reason, document it very well with sufficient comments.

7. If you initialize a numeric variable to a special number other than 0, -1 etc, document the reason for choosing that value.

8. The bottom line is, write clean, readable code such a way that it doesn't need any comments to understand.

9. Perform spelling check on comments and also make sure proper grammar and punctuation is used.

Annex I - C# rules and naming conventions

9. Exception Handling

1. Never do a 'catch exception and do nothing'. If you hide an exception, you will never know if the exception happened or not. Lot of developers uses this handy method to ignore non significant errors. You should always try to avoid exceptions by checking all the error conditions programmatically. In any case, catching an exception and doing nothing is not allowed. In the worst case, you should log the exception and proceed.

2. In case of exceptions, give a friendly message to the user, but log the actual error with all possible details about the error, including the time it occurred, method and class name etc.

3. Always catch only the specific exception, not generic exception.

Good:

void ReadFromFile ( string fileName ) { try { // read from file. } catch (FileIOException ex) { // log error. // re-throw exception depending on your case. throw; } }

Not Good:

void ReadFromFile ( string fileName ) { try { // read from file. } catch (Exception ex) { // Catching general exception is bad... we will never know whether // it was a file error or some other error. // Here you are hiding an exception. // In this case no one will ever know that an exception happened.

return ""; } }

Annex I - C# rules and naming conventions

4. No need to catch the general exception in all your methods. Leave it open and let the application crash. This will help you find most of the errors during development cycle. You can have an application level (thread level) error handler where you can handle all general exceptions. In case of an 'unexpected general error', this error handler should catch the exception and should log the error in addition to giving a friendly message to the user before closing the application, or allowing the user to 'ignore and proceed'.

5. When you re throw an exception, use the throw statement without specifying the original exception. This way, the original call stack is preserved.

Good:

catch { // do whatever you want to handle the exception

throw; }

Not Good:

catch (Exception ex) { // do whatever you want to handle the exception

throw ex; }

6. Do not write try-catch in all your methods.

Use it only if there is a possibility that a specific exception may occur and it cannot be prevented by any other means. For example, if you want to insert a record if it does not already exists in database, you should try to select record using the key. Some developers try to insert a record without checking if it already exists. If an exception occurs, they will assume that the record already exists. This is strictly not allowed. You should always explicitly check for errors rather than waiting for exceptions to occur. On the other hand, you should always use exception handlers while you communicate with external systems like network, hardware devices etc. Such systems are subject to failure anytime and error checking is not usually reliable. In those cases, you should use exception handlers and try to recover from error.

7. Do not write very large try-catch blocks. If required, write separate try-catch for each task you perform and enclose only the specific piece of code inside the try-catch. This will help you find which piece of code generated the exception and you can give specific error message to the user.

8. Write your own custom exception classes if required in your application. Do not derive your custom exceptions from the base class SystemException. Instead, inherit from ApplicationException.

Annex I - C# rules and naming conventions