Software engineering methodologies

 
 
Article 
 
SOFTWARE ENGINEERING METHODOLOGIES.

CREATION OF THE DISTRIBUTED APPLICATIONS USING HIBERNATE TECHNOLOGY

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2009

 

CONTENTS 

 

ACRONYMS 
 

    AMDD – Agile Model Driven Development

    API – Application Programming Interface

    DAO – Data Access Objects

    DTO – Data Transfer Object

    EJB – Enterprise Java Beans

    J2EE, JEE – Java Platform, Enterprise Edition

    JME – Java Platform, Micro Edition

    JSF – Java Server Faces

    JSP – Java Server Pages

    JVM – Java Virtual Machine

    MSF – Microsoft Solutions Framework

    RUP – Rational Unified Process

    SVN – Subversion (free system of version control)

    UML – Unified Modeling Languages

    WAD – Web Application Development

    XML – Extensible Markup Language

    XP – Extreme Programming

    DBMS – Database Management System

 

INTRODUCTION

    Today more and more developers wish to create distributed transactional corporate applications and use advantages in speed, security and reliability, provided by server technologies.

    The experts working in the field of IT, know, that in modern, fast varying and putting forward all new requirements world of electronic commerce and information technologies, corporate applications should be projected, formed and should take root for smaller sums of money, with greater speed and smaller expenses of resources, than it was early.

    For decreasing of the cost and increasing in speed of design and development of the corporate application platform J2EE offers the component approach to designing, development, assembly and implantation of corporate applications.

    Platform J2EE offers the model of the multilevel distributed application, possibility of reuse of the components, the integrated data exchange on the basis of the XML, the unified model of safety and floppy control of transactions.

    Using J2EE, it is possible to release on the market the innovative solution for users faster, than earlier, and also the platform-independent J2EE-decisions grounded on components are not anchored any more to products and on API of any releaser.

    Releasers and users possess freedom of a choice of products and components which most completely satisfy their business and technology requirements.

    In the given article engineering processes of the software, possibilities and the functions accessible in J2EE are examined.

    The given examples contain the useful and accessible information which can be used in development of real corporate solutions.

 

ENGINEERING ENVIRONMENT FOR CREATION OF THE DISTRIBUTED APPLICATIONS AND SOFTWARE ENGINEERING METHODOLOGY

    1. Software engineering methodologies
      1. Extreme Programming.

    XP is a software engineering methodology and a form of agile software development (AMDD). The authors of this model are Kent Beck, Ward Cunningham, Martin Fowler and others. Extreme Programming has been described as having twelve practices, grouped into four areas:

  • fine scale feedback:
    • test driven development;
    • planning game;
    • whole team, onsite customer;
    • pair programming;
  • continuous process:
    • continuous integration;
    • design improvement, refactoring;
    • small releases;
  • shared understanding:
    • simple design;
    • system metaphor;
    • collective code ownership or сollective patterns ownership;
    • coding standard or coding conventions;
  • programmer welfare:
    • sustainable pace, forty hour week.

    Pair programming means that all code is produced by two people programming on one task on one workstation. One programmer has control over the workstation and is thinking mostly about the coding in detail. The other programmer is more focused on the big picture, and is continually reviewing the code that is being produced by the first programmer. Programmers trade roles regularly. The pairs are not fixed: it's recommended that programmers try to mix as much as possible, so that everyone knows what everyone is doing, and everybody can become familiar with the whole system. This way, pair programming also can enhance team-wide communication. (This also goes hand-in-hand with the concept of Collective Ownership).

    Collective code ownership means that everyone is responsible for all the code; this, in turn, means that everybody is allowed to change any part of the code. Pair programming contributes to this practice: by working in different pairs, all the programmers get to see all the parts of the code. A major advantage claimed for collective ownership is that it speeds up the development process, because if an error occurs in the code any programmer may fix it.

    By giving every programmer the right to change the code, there is risk of errors being introduced by programmers who think they know what they are doing, but do not foresee certain dependencies. Sufficiently well defined unit tests address this problem: if unforeseen dependencies create errors, then when unit tests are run, they will show failures.

    "Customer" in XP is not the person who pays bills, and the person who actually uses system. The Principle of XP approves, that the customer should be on-line all the time and be ready to questions.

      1. Rational Unified Process.

    RUP – a software development methodology created by The Rational Software company. In the basis of RUP following main principles lay:

  • early identification and continuous (before the ending of the project) elimination of the main risk factors;
  • concentration on execution of requirements of customers to an executable program (the analysis and construction of model of precedents);
  • waiting for changes in requirements, design solutions and implementations during development;
  • the component architecture sold and tested at early stages of the project;
  • constant support of quality at all development cycles of the project (product);
  • work on the project in the rallied team, a key role in which belongs to architects.

    RUP uses iterated model of development. In the end of each iteration (in an ideal proceeding from 2 till 6 weeks) the design team should reach the purposes planned on given iteration to create or finish design artefacts and receive intermediate, but the functional version of a final product. Iterated development allows to react fast to varying requirements, to find out and eliminate risk factors at early stages of the project, and also effectively inspect quality of a created product.

Complete life cycle of development of a product (it is presented in a picture 1.1.2.1) consists of four phases, each of which includes one or several iterations.

    At the initial stage:

  • vision and boundary of the project are formed;
  • economic substantiation (business case)is created;
  • basic version of model of precedents is created;
  • risk factors are estimated.

    Having finished an initial stage a mark of the purposes of life cycle (English Lifecycle Objective Milestone) which assumes the agreement of the interested sides on continuation of the project is estimated.

 

    Picture 1.1.2.1 – Visual overview of a software engineering process by RUP

    At a design stage the analysis of a data domain and construction of the executed architecture is made. It includes:

  • documenting requirements (including the detailed description for the majority of precedents - scripts of usage);
  • designed, realized and tested the executing architecture;
  • the updated economic substantiation and more exact estimations of periods of cost;
  • the lowered main risk factors.

    Successful execution of a phase of designing means reaching a mark of the purposes of life cycle. (English Lifecycle Objective Milestone).

    During the phase of construction there is an implementation of a bigger part of software product. The phase is completed by the first external release of system and a mark of Initial Operational Capability.

    During the phase of implantation there is a final version of a product and it is transferred from the developer to the customer. It includes the program of beta testing, manual for users, and also definition of quality of a product. In case the quality mismatches the waitings of users or the criteria placed in a phase of the beginning, the phase of implantation repeats again. Execution of all purposes means reaching a mark of availability of a product (Product Release) and completion of full design cycle.

    1. Distributed applications and multi-tier architecture

    The program application of a level of firm (the corporate application) is the set of cooperating program units intended for problem solving, linked with rise of efficiency of activity of a firm.

    Modern corporate program applications of dynamically developing firm are intended for efficient control firm, its resources, maintenance of a production cycle, interaction with suppliers and customers, implementations of made production, etc. The ultimate goal is to receive a profit in condition of acute competitive struggle against other firms of the given profile.

    Possibility of fast obtaining and information processing in the Internet, presence of the automated control systems by production and sales, possibility of storage and maintenance of great volumes of data are the mortgage of successful activity of a firm in the market.

    At implementation of corporate applications the creation of the programs providing convenient user interface, interaction of many users supporting the web-applications, the distributed calculations and usage of databases, and also needed protection of the information is necessary.

    Technologies J2EE originally developed as a resource of effective problem solving of electronic commerce and electronic business. Application of these technologies has been subordinate to solution of a problem of fast obtaining of the information in conditions of modern dynamical market economy.

      1. Multi-tier applications.

    Multi-tier applications represent the applications divided into parts by the number of levels, and, these parts can be placed on various computers. The number of levels, basically, is not limited, however usually there are no more than five.

    Multilevel systems, as a rule, simultaneously are also multi-user as intend for collective usage. However for an essence of their architecture their multilevel character is much more important.

    The multilevel architecture arranges the application between the client and server side as follows:

  • The informational part of application (database) is placed on a server;
  • The user interface allocates on the side of the client;
  • Business-logic can be or on the client side (the thick client), or on the server side (the thin client), or partially on client and partially on server part.

    The multilevel architecture dividing the program system on three levels (representations, business-logic and a level of data access), is much more technologically, than the usual architecture "Client/server":

  • The client part is separated from any changes in other parts of the application;
  • Greater flexibility of the application is achieved, as it is built from building blocks, is formed of rather small units.
      1. Distributed systems.

    Unlike multilevel applications where linear style of interaction between the client and a server is saved, in the distributed system all application is represented as a set of equal in rights cooperating objects which fulfils the certain functionality.

    Each object gives some set of tools and itself can use the tools given by other objects of system.

    Thus, roles of objects rigidly are not certain, and each object of system can simultaneously appear both as a server, and as the client.

    The protocol of interaction between two objects of the distributed program system is defined by the interface. In this case possible changes, modifications and refinements of components are carried out at a level of implementation, not mentioning interfaces and consequently appear imperceptible for the user.

    The component is an object of the distributed system with appropriate interfaces. Implementation of a component is separated from the interface that allows the designer to change separate components, not changing other parts of system. For this purpose it is necessary to save only constant interfaces of all components of the distributed system.

    1. J2EE platform

    Java 2 Platform, Enterprise Edition is a complex of the cooperating Java-technologies which are based specifications, developed by Sun Microsystems corporation, representing the standard of development of server-based applications of a level of firm.

      1. The Choice of Java technology.

    As base technology for development of corporate applications Java technology is selected. The Principal cause of this choice is that Java - a multiplatform portable object-oriented programming environment.

    Object-oriented Java environment includes:

  • Programming language Java giving a set of classes and interfaces on the basis of which the program application can be developed;
  • Java-compiler, translating initial Java-code, not depending on a concrete platform;
  • Java Virtual Machine (JVM) which executes Java-byte-code.

    Virtual Java-machine dynamically compiles or interprets platform independent Java-byte-code, translating it in platform independent instructions.

      1. Contents of J2EE technology.

    J2EE technology consists of the next four main components:

    • J2EE Platform Specification;
    • J2EE Reference Implementation;
    • J2EE Blueprints;
    • J2EE Compatibility Test Suite.
      1. Technologies of J2EE platform.

    Each concrete implementation of platform J2EE satisfying specifications J2EE of version 1.3, should give enumerated below technologies and appropriate program interfaces to the user.

    • Java Remote Method Invocation (RMI) and RMI/IIOP;
    • Java Naming and Directory Interface (JNDI);
    • Java Messaging Service (JMS);
    • Java Servlets;
    • Java Server Pages (JSP);
    • Java Database Connectivity (JDBC);
    • Java Transaction API (JTA) and Java Transaction Service (JTS);
    • Enterprise Java Beans (EJB);
    • Java Interface Definition Language;
    • Java Mail and Java Beans Activation Framework;
    • J2EE Connector Architecture;
    • Java API for XML Parsing;
    • Java Authentication and Authorization Service (JAAS).
      1. EJB.

    It is the most important technology which, purely, defines the main properties and assignment of platform J2EE. Version 1.3 of platform J2EE includes the support of specification EJB 2.0 which gives the description of standard components of a server-based application and ways of their implementation (properties of components, a technique of writing of their program code, principles of usage of components in multilevel applications and so forth). The standard agreements linking EJB components and servers of applications also are presented to specifications EJB 2.0 (application servers), controlling by components. Technology EJB bases on other technologies J2EE.

    Base model EJB consists of following main components:

  • EJB server;
  • EJB containers, functioning on a server of applications;
  • remote EJB objects;
  • local EJB objects;
  • local home objects;
  • The auxiliary systems supporting operation of the container (JMS, JDBC, etc.);
  • EJB clients.
      1. J2EE and multi-tier architecture.

    The simplified scheme presented in a picture 1.4.5.1, shows how platform J2EE realizes the multilevel architecture of the corporate application.

Picture 1.4.5.1 – Multi-tier architecture in J2EE

    1. Development of real application

    Certainly, development of a real application includes enough difficult stages. Within the limits of the report will be examined the stage of preparation for development of the application and the process of work with special technology "Hibernate".

      1. Tools overview and environment setup.

    Platfotm Eclipse is a cross-platform implementation with the open initial code and expanded built in IDE, using Java language. In essence, platform Eclipse is the environment giving a set of services which other additions can use. Each addition is developed for the same platform which unites them in a set of highly integrated tools. Eclipse extends free of charge and does not demand installation - it is enough to copy files of Eclipse on a hard disk of a computer.

    Apache Ant – java-utility stands for automation of process of assembly of software product. Ant is completely independent from a platform if on applied system, at least, is installed Java working environment – JRE. Handle happens by means of the XML-script also named a build-file. First of all this file contains definition of the project consisting of the separate purposes (targets). The purposes could be compared with procedures in programming languages also contain calls of commands-tasks (tasks). Task is an indivisible, atomic command. The script is made in format XML, accordingly, signs of line feed and the blanks applied in various platforms do not influence execution of operations. Besides Ant has precisely certain interfaces for creation of own tasks in the form of Java-programs.

    JUnit environment represents the test environment of execution Java with the open initial code, standard for check of code modules Java. It can be downloaded from a web-site junit.org; this site gives not only the instruction for installation, but also articles on check of units and set of advices on development of pre-checks.

    Besides,many other software products  and technologies  also participate in development of the application (Spring, Struts, JSF, Apache Tomcat, JBoss, DBMS MySQL, etc.) on which we will not stop in detail.

      1. Using Hibernate.

    Hibernate has recently won popularity in the world of development of applications of Java databases. Though such products as Toplink and others, are on the market for many years, Hibernate has implementation with the open source and, therefore, it is free-of-charge. It is stable, mature, well proved and concerning a simple product for learning: some of the reasons of its popularity. Hibernate has been released several years ago, but recently has been gained by JBoss group. The fault-tolerant environment of execution Hibernate can work with relational databases, using Java. It is so also for usage JDBC or Entity Beans.

    During usage of Hibernate we will need to make additional operations on binding, but it is covinient because our code becomes more reliable and easier, but also, necessity for objects of data access (DAO) which are usually used for purely saving will pass. Data transfer objects (DTO) which are used for an encapsulation business-data and their movings between layers of the application also will not be necessary to us.

    Hibernate has supported following databases: DB2, HSQLDB, Microsoft SQL Server, MySQL, Oracle, PostgreSQL, SAP DB, Sybase, TimesTen. Support of databases in Hibernate is carried out with classes of dialect SQL, such as org.hibernate.dialect.HSQLDialect, org.hibernate.dialect.OracleDialect, org.hibernate.dialect.MySQLDialect, etc.

    To show concepts and terminology of Hibernate, we shall create three types of files: configuration file Hibernate, appropriate Java classes, and also files of tables of binding. It is a recommended practice, in documentation of Hibernate and examples. For files of binding the following agreement about naming is usually used: to Java class name  the suffix .hbm.xml, for example Timesheet.hbm.xml is added.

    First we shall create a file under the name hibernate.cfg.xml. This file will contain definition of application (SessionFactory) and the link to our first file of binding, Department.hbm.xml. We shall examine some of the most interesting lines of this file.

    Following lines show the customization linked with HSQLDB:

    <property name=”connection.driver_class”>

          org.hsqldb.jdbcDriver

    </property>

    <property name=”connection.url”>

          jdbc:hsqldb:hsql://localhost:9005/timex

    </property>

    <property name=”connection.username”>

          sa

    </property>

    Brought below line of a file hibernate.cfg.xml show links to files of binding:

    <mapping resource=”Department.hbm.xml” />

    <mapping resource=”Employee.hbm.xml” />

    <mapping resource=”Timesheet.hbm.xml” />

    Using the completed file hibernate.cfg.xml, we can create Hibernate SessionFactory.

    Let's examine our first file of binding Department.hbm.xml  in detail.

    The following line of a code will link our Java class to the table of databases:

    <class name=”com.visualpatterns.timex.model.Department” table=”Department”>

    The following line of a code will place the identifier{ID} departmentCode as an object identifier and as a primary key of a database, and also will link them together:

    <id name=”departmentCode” column=”departmentCode”>

    Value generator class=”assigned”, shown below, notifies Hibernate that we shall carry out installation of value of this object in Java class and Hibernate should not undertake any special operations similar to obtaining of following value of sequence from a column auto-increment (as, for example, for data type HSQLDB identity):

    <generator class=”assigned" />

    These lines link other fields of table Department, i.e. a column name to property name in a file of class Department.java:

    <property name=”name” column=”name” />

    File Department.java contains simple class JavaBean, which gives methods for reading (get or getter) and records (set or setter) for value of two following variables:

    String departmentCode;

    String name;

    Now we shall write some simple code, carrying out two tasks: check of installation of Hibernate, and also showing example of usage of Hibernate. We shall place this code in file HibernateTest.java.

    Some first lines of a code show, as we receive class Hibernate SessionFactory and we extract one record from table Department about value "IT" from a column departmentCode:

SessionFactory sessionFactory = new Configuration()

      .configure().buildSessionFactory();

Session session = sessionFactory.getCurrentSession();

Transaction tx = session.beginTransaction();

Department department;

Department = (Department) session.get(Department.class, “IT”);

System.out.printl(“Name for IT = ” + department

      .getName());

    Following lines show how to receive and handle java.util. List object of table Department.

List departmentList = session

      .createQuery(“from Department”).list();

for (int i = 0; i < departmentList.size(); i++)

{

    department = (Department) departmentList.get(i);

    System.out.println(“Row ” + (i + 1) + “> ” + department.getName() + “ (”

          + department.getDepartmentCode() + “)”);

}

    The last examined line closes class SessionFactory.

    SessionFactory.close();

    It is necessary to pay attention that file HibernateTest.java represents a simple example of usage of Hibernate when all code concentrates in one (main) method. There are also better ways of creation of class SessionFactory and the subsequent obtaining of its Session object. However the code containing in this class quite can be used in development of the real application with usage of Hibernate.

    Hibernate is possible to find at <http: // www.hibernate.org>. Following the instruction given on this site, it is possible to load and install Hibernate. After installation it is required to copy all libraries recommended by documentation of Hibernate (for example, hibernate3.jar and antlr.jar) in the appropriate directory of the application.

    To other additional possibilities of Hibernate which has been not described here, but capable to be useful, concern the following:

  • The expanded binding (for example, bidirectional communications, the ternary links, sorted collections, component binding, inheriting of links, etc.);
  • Expanded HQL;
  • Summaries (and XDoclet);
  • Filters;
  • Utility Hibernate SchemaExport;
  • Inheriting links;
  • Interceptors;
  • Objects of locking;
  • Strategies of rising of productivity (for example, the strategy of sampling, the L2 cache);
  • Scrolled iteration and paginating;
  • Control of transactions (the expanded possibilities);
  • Other areas, such as usage of containig procedures, base SQL, etc.

 

SUMMARY

    During the creation of this article the structure, the organization of technological process, and also the normative documentation used during development of applications have been studied. Base knowledge of syntax of programming Java language, received during studying on 1-5 courses have been fixed, expanded and profound. Have been studied modern methodology of engineering process of the software; special technologies (Spring, Struts, Java Server Faces, Java Server Pages, Hibernate), widely applied now in a combination to language of highest level Java; the main way of creation of the program system; technology of designing and development of the distributed applications with multilevel architecture (J2EE).

    During the creation of the article the experience, which was received independently during the development of the real project, which result was the finite distributed application created about usage of special technologies, patterns of designing and programming Java language was actively used.

    In the article have been examined engineering processes of the software, and also possibility and the functions given by program platform J2EE, the examples containing the initial code which can be used by development of real corporate solutions are brought.

 

BIBLIOGRAPHY

  1. Auer, Ken; Miller, Roy (2001). Extreme Programming Applied: Playing To Win, Addison-Wesley, pp. 384.
  2. Beck, Kent (2000). Extreme Programming Explained: Embrace Change, Addison-Wesley, pp. 224.
  3. Beck, Kent; Fowler, Martin (2000). Planning Extreme Programming, Addison-Wesley, pp. 160.
  4. Kroll, Per (2003). Rational Unified Process Made Easy: A Practitioner's Guide to the RUP, Addison-Wesley, pp. 464.
  5. Kroll, Per; MacIsaac, Bruce (2006). Agility and Discipline Made Easy: Practices from OpenUP and RUP, Addison-Wesley, pp. 448.
  6. Kruchten, Philippe (1998). The Rational Unified Process: An Introduction, Addison-Wesley, pp. 272.
  7. Perrone, Paul J.; Chaganti, Krishna (2003). J2EE Developer's Handbook, Sam's Publishing, pp. 1536.
  8. Bodoff, Stephanie (2004). The J2EE Tutorial, Addison-Wesley, pp. 528.
  9. King, Gavin; Christian, Bauer (2006), Java Persistence with Hibernate (Second ed.), Manning Publications, pp. 880.
  10. King, Gavin; Christian, Bauer (2004), Hibernate In Action (Second ed.), Manning Publications, pp. 400.
  11. Fowler, Martin (2002); Patterns of Enterprise Application Architecture. Addison-Wesley, pp. 512.
Software engineering methodologies