Support

Forums

Contact Me

Posts Tagged 'java'

Java

Java () is an island of Indonesia. With a population of 135 million (excluding the 3.6 million on the island of Madura which is administered as part of the provinces of Java), Java is the world's most populous island, and one of the most densely-populated places on the globe. [http://en.wikipedia.org/wiki/Java]

Mediator

Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.




Source code

/**
 * Each colleague knows its Mediator object. Communicates with its mediator
 * whenever it would have otherwise communicated with another colleague.
 * 
 * @role __Colleague
 */
public abstract class Colleague {
        /** my mediator */
        private Mediator mediator;        /** Create colleague which knows about supplied mediator */
        protected Colleague(Mediator mediator) {
                this.mediator = mediator;        }

        /** @return mediator this colleague knows about */
        public Mediator getMediator() {
                return mediator;        }

}

/** Concrete Colleague */
public class ConcreteColleagueA extends Colleague {
        public ConcreteColleagueA(Mediator mediator) {
                super(mediator);        }

        public void sampleOperation() {
                // some state changes occur,
                // notify mediator about them
                getMediator().changed(this);        }

}

/** Concrete Colleague */
public class ConcreteColleagueB extends Colleague {
        public ConcreteColleagueB(Mediator mediator) {
                super(mediator);        }

        public void sampleOperation() {
                // some state changes occur,
                // notify mediator about them
                getMediator().changed(this);        }

}

/**
 * Implements cooperative behavior by coordinating Colleague objects. Knows and
 * maintains its colleagues.
 */
public class ConcreteMediator implements Mediator {
        /** reference to concrete colleague */
        private ConcreteColleagueA aConcreteColleagueA;        /** reference to concrete colleague */
        private ConcreteColleagueB aConcreteColleagueB;        public void changed(Colleague colleague) {
                // handle changes of particular colleague
        }

        public void setConcreteColleagueA(ConcreteColleagueA colleague) {
                aConcreteColleagueA = colleague;        }

        public void setConcreteColleagueB(ConcreteColleagueB colleague) {
                aConcreteColleagueB = colleague;        }

}

/**
 * Defines an interface for communicating with Colleague objects.
 * 
 * @role __Mediator
 */
public interface Mediator {
        /** Colleagues calls this method to notify Mediator that something changed */
        void changed(Colleague colleague);}

Articles tagged

Why it is not possible to develop any software ...

Bug Tracking Tool
Work in progress

or Why it is not possible to manage any software development without a bug tracking tool

A bug tracking system is basically a database linked to  a frontend:
  • The frontend can be a FAT client, understand a windows or application running on your pc and that need to be install by each developer/client, or may be
  • Adhering to a light client server model: HTML frontend which submit queries to a server.

Provide

Tracability

When was the bug open, and closed, what is its status now. Who has reported it (login is required and all system support profile (user, tester, manager, developer, administrator) and/or isolation of project). Did It already existed in a previous version (regression in code), etc...

Responsability

 Easily dispatch responsability or find quickly who was reponsible for solving it, how  much time was needed to close this bug, some system may send email automatically to developer to inform them... etc...

Effort

How difficult will it be to solve this issues, (can be a bugnote add by other developer). Most of the time, technical leader decide of the value of this field together with developers.

Priorities

How many bugs are still open at a date "t", how do I determine the order in which I will solve them...etc

Standardisation of records

By forcing tester/customer to enter some mandatory fields in a graphical forms. It may avoid You to hear some ridiculous statement like: "the application is not printing, working". It force the user talking a language You have decide together, having agreed on a "bug category" list is a very good and common example.

Customization

All modern bug tracking tool let You define and customize some part of the system according to your need.

Addition of information

A screenshot is better than thousand word, a file create by the application, a memory dump, anything that will help developer to reproduce the bug.

Statistics/Reporting

A lot of very powerful queries can be executed. It is always interesting to know, how many improvement were done in the next/past releases, or if a team has use more power to develop new functionnalities (also changes request which interest the customer the most) or loose time tracking some low level bug priority.
In case of reporting, Bugzilla support the following:
  • Tabular reports - tables of bug counts in 1, 2 or 3 dimensions, as HTML or CSV.
  • Graphical reports - line graphs, bar and pie charts.

Al of the above will have a positive result on:
  • communication among the team of developers and customers,
  • It will improve the product quality by several magnitude,
  • Developer will be more productive as the will know what to concentrate on or what is worth to do.
AND Your customers will be happier!!

Golden rules

  1. A bug that can be reproduce can be analysed/corrected.
  2. Correcting a bug is not always trivial, a correction may introduce new bugs.
  3. The intrinseque quality of a software is always improved with a tracking tool over time

Some open source software:


Bugzilla (http://www.bugzilla.org/) is the more famous, use in a lot of open source application (Mozilla, Apache, and even eclipse) version 2.19.2 (MySQL+PHP, Solaris, Linux, Win32, MacOS X, BSD) 370 companies are currently using it. (Nasa, IBM, Mozilla and others)- Wikipedia has a very brief article on it, Features are listed here

Mantis. (http://mantisbt.sourceforge.net/) A very simple bug tracking tool with limited search functionnality compared to bugzilla, a strong community but not so much stable release as expected.

Buggit (http://www.matpie.drw.net/PBSystems/products/buggit/Buggit.html) no new release since 2000 and bounded to MS access, aka running only unde windows. Listed Here because I use to play with it in 2001.




 

Read more: Why it is not possible to develop any software ...

Dynamic polymorphic abstract factory

This package contains a dynamic polymorphic factory...

  •  New class can be add dynamically to the factory... even during runtime (dynamic)
  • Factory methods are in a separate class as virtual functions. (polymorphism)
  • Different types of factories can be subclassed from the basic factory.. (abstract)
  • Useful iin case of licence problem, since Concrete classes are created at runtime, and only need to reside in classpath (If they are not present the code still compile). Below, the example show multiple authorization and autorisation scheme, that can be switche on/off very fast.
  • Factory can be driven with an external condition (properties, registry ....)
 
Notice also that the specific concrete classes are dynamically loaded on demand...(class.forname())


Source Code

/**
 * Creation date: (7/19/2002 2:50:45 PM)
 * 
 * @author: Cedric Walter
 */
public interface AuthentificationIF {

        public boolean Authentificate(HttpServletRequest req,                        HttpServletResponse resp);        public boolean hasAutorisation(HttpServletRequest req,                        HttpServletResponse resp);}

public abstract class AuthentificationA implements AuthentificationIF {
/**
  * AuthentificationA constructor comment.
  */
        public AuthentificationA() {
                super();        }

        
/**
  * Authentificate method comment.
  */
        
public abstract boolean Authentificate(                        
javax.servlet.http.HttpServletRequest req,                        
javax.servlet.http.HttpServletResponse resp);
}

abstract class AuthentificationFactoryA {

        private static java.util.Map factories = new java.util.HashMap();        
/**
  * ComputeFactory constructor comment.
  */
        public AuthentificationFactoryA() {
                super();        }

        public static void addFactory(String id, AuthentificationFactoryA f) {
                factories.put(id, f);        }

        public static final AuthentificationIF createAuthentification(String id)                        
throws FactoryCreationException { if (!factories.containsKey(id)) { try { // Load dynamically Class.forName(id);
}
catch (ClassNotFoundException e) { throw new FactoryCreationException(id);
} // verify that it has been stored if (!factories.containsKey(id))
throw new FactoryCreationException(id);
} return ((AuthentificationFactoryA) factories.get(id)).getAuthentification();
} protected abstract AuthentificationIF getAuthentification();} /** * concrete class of the abstract factory */ public class MyAuthentificationFactory extends AuthentificationFactoryA { public MyAuthentificationFactory() { super(); } /** * not use since it is subclass */ protected AuthentificationIF getAuthentification() { return null; } } /** * @author: Cedric Walter */ public class NimiusAuthentification extends AuthentificationA implements AuthentificationIF { private static class Factory extends AuthentificationFactoryA { protected AuthentificationIF getAuthentification() { return new NimiusAuthentification(); } } static { AuthentificationFactoryA.addFactory("com.waltercedric.gof.pattern.factory.NimiusAuthentification", new NimiusAuthentification.Factory()); }
/**
  * Local constructor comment.
  */
        public NimiusAuthentification() {
                super();        }

        
/**
  * Authenficate method comment.
  */
        public boolean Authentificate(javax.servlet.http.HttpServletRequest req, 
javax.servlet.http.HttpServletResponse resp)
{ //do some stuff return true; } public boolean hasAutorisation(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
{ //do some stuff return true; } } /** * @author: Cedric Walter */ public class NoAuthentification extends AuthentificationA implements AuthentificationIF { private static class Factory extends AuthentificationFactoryA { protected AuthentificationIF getAuthentification() { return new NoAuthentification(); } } static { AuthentificationFactoryA.addFactory( "com.waltercedric.gof.pattern.factory.NoAuthentification", new NoAuthentification.Factory()); } /** * Local constructor comment. */ public NoAuthentification() { super(); } /** * Authenficate method comment. */ public boolean Authentificate(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp) { return true; } /** * hasAutorisation method comment. */ public boolean hasAutorisation(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp) { return true; } } /** * @author: Cedric Walter */ public class ObtreeAuthentification extends AuthentificationA implements AuthentificationIF { private static class Factory extends AuthentificationFactoryA { protected AuthentificationIF getAuthentification() { return new ObtreeAuthentification(); } } static { AuthentificationFactoryA.addFactory( "com.waltercedric.gof.pattern.factory.ObtreeAuthentification", new ObtreeAuthentification.Factory()); } /** * Local constructor comment. */ public ObtreeAuthentification() { super(); } /** * Authenficate method comment. */ public boolean Authentificate(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp) { return true; } /** * hasAutorisation method comment. */ public boolean hasAutorisation(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp) { return true; } }

Sun Plans To Make Java Enterprise System Open-Source

YES!!!!! but wait there are not using a FSF, OpenBSD  licence, so is it really open sourcing java??? :-(
Sun announced Monday that it has distributed more than a million registered licenses for the Solaris 10 operating system since Jan. 31, when the software became available for free on Sun's Web site. Now it plans to follow up that move by making Java Enterprise System available as an open-source product as well. "That will define us as a company truly committed to open source," Jonathan Schwartz, president and chief operating officer of Sun, told InformationWeek.

Articles tagged

Refactore your code

  • Refactore your code as soon as it is working, http://www.refactoring.com 
  • Refactore your code if you have too many comments or do not understand ithem
Articles tagged

Playing with Axis C++ and Apache 1.3.1

Here is a How to since it take me a very long time to install something which should have been trivial....
For the benefit of the community, I am publishing it here on my free time :-) ... Enjoy...

Apache Axis and Apache Axis C++ are implementation of the SOAP ("Simple Object Access Protocol") submission to W3C. From the W3C draft specification:

SOAP is a lightweight protocol for exchanging structured information in a decentralized, distributed environment. It is an XML based protocol that consists of three parts: an envelope that defines a framework for describing what is in a message and how to process it, a set of encoding rules for expressing instances of application-defined datatypes, and a convention for representing remote procedure calls and responses.

Axis C/C++ (Axis CPP) is a non-Java implementation of Axis. At its core Axis CPP has a C++ runtime engine. The provided tooling allows you to create C++ client-side stubs and server-side skeletons. The server skeletons can be deployed to either a full Apache web server using the supplied apache module or a "simple_axis_server" - which is a simple HTTP listener (designed to help you test your services).

Read more: Playing with Axis C++ and Apache 1.3.1

Apache M2Eclipse: Get rid of Duplicate resources when opening resources and types

In this small post, I’ll show you how to remove duplicated resources in the Open Resource view of Eclipse

Eclipse – M2Eclipse – Subversive

Read more: Apache M2Eclipse: Get rid of Duplicate resources when opening resources and types

ITP - Powerful web application tester

Open-source ITP - Powerful web application tester

ITP is a deceptively simple, yet powerful web testing harness. It is a stand-alone Java application that can test your website from a user's perspective. It is amazingly simple and lightweight, yet can be used for powerful test-scripting by using building blocks to create large test runs.
ITP is the fastest test harness software to learn. A test script is simply made up out of a few lines of XML. There is no programming involved! You will be testing your application in seconds.

Decorator

Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.



Source Code

/**
 * Defines the interface for objects that can have responsibilities added to the
 * dynamically.
 * 
 * @role __Component
 */
public abstract class Component {
	/**
	 * Sample operation.
	 */
	public abstract void doSomeStuff();
}

/**
 * Defines an object to which additional responsibilities can be attached.
 */

public class ConcreteComponent extends Component {
	/** @see patterns.gof.decorator.Component#doSomeStuff() */
	public void doSomeStuff() {
		// provide implementation here
	}
}

/**
 * Adds responsibilities to the component.
 */

public class ConcreteDecorator extends Decorator {
	public ConcreteDecorator(Component decorateMe) {
		super(decorateMe);
	}

	/**
	 * Behavior added by decorator.
	 */
	private void addedBehavior() {
		// some extra functionality goes here
	}

	public void doSomeStuff() {
		super.doSomeStuff();
		addedBehavior();
	}
}

/**
 * Maintains the reference to a Component object and defines an interface that
 * conforms to Component's interface
 * 
 * @role __Decorator
 */

public abstract class Decorator extends Component {
	/** reference to the decorated component */
	protected Component component;

	/**
	 * @param decorateMe
	 *            component to decorate
	 */
	public Decorator(Component decorateMe) {
		this.component = decorateMe;
	}

	public void doSomeStuff() {
		component.doSomeStuff();
	}
}

Abstract factory

Provide an interface for creating families of related or dependent objects without specifying their concrete classes.



Source Code

/**
 * Abstract factory declares an interface for operations that create abstract
 * product objects.
 * 
 * @role __Factory
 */
public interface AbstractFactory {
        /**
  * Creates abstract product
  */
        ProductA createProductA();        /**
  * Creates abstract product
  */
        ProductB createProductB();}

/**
 * Abstract factory declares an interface for operations that create abstract
 * product objects.
 * 
 * @role __Factory
 */
public interface AbstractFactory {
        /**
  * Creates abstract product
  */
        ProductA createProductA();        /**
  * Creates abstract product
  */
        ProductB createProductB();}

/**
 * Abstract product - an interface for a type of Product object.
 * 
 * @role __Product
 * @see AbstractFactory
 */
public interface ProductA {

        /*
  * add product method declarations here
  */
}

/**
 * Concrete Factory implements operations of AbstractFactory to create Concrete
 * product objects.
 */
public class MyFactory implements AbstractFactory {

        /**
  * Creates concrete product ConcreteProduct1
  */
        public ProductA createProductA() {
                return new ConcreteProduct1();        }

        /**
  * Creates concrete product ConcreteProduct2
  */
        public ProductB createProductB() {
                return new ConcreteProduct2();        }

}

/**
 * Concrete product defines a product object to be created by the corresponding
 * concrete factory.
 * 
 * @see MyFactory
 */
public class ConcreteProduct1 implements ProductA {

}

/**
 * Concrete product defines a product object to be created by the corresponding
 * concrete factory.
 * 
 * @see MyFactory
 */
public class ConcreteProduct2 implements ProductB {

}

Donations

Thank You for supporting my work