Friday, July 30, 2010

"verification and validation" (V&V) check on domain model

1) Verify each attribute in the model.  Does this attribute belong in the class you have put it in?  In other words (IOW), can you answer the question: What purpose does this attribute serve in this class?  And: Does it match the requirements?  If the attribute does *not* serve a purpose then remove it from the model.  If the attribute belongs to a different class, then move the attriubte to that class. If there is an attribute mentioned in the requirements that does *not* yet exist in the model, the find the appropriate class and add it.

  2) Verify each relationship in the model.  What purpose does this relationship serve in the model?  Does that purpose match a requirement?  If the relationship does *not* serve a purpose then remove that relationship.  If the requirements define a relationship that does not exist in the model, then add that relationship to the model.

  3) Verify each relationship multiplicity in the model.  What purpose does this multiplicity serve in the model?  Does that purpose match a requirement?  If the multiplicity does *not* serve a purpose, then remove it.  Is the multiplicity the correct value as defined in the requirements?  Does the multiplicity value use the simplest form?  (for example, "N..N" should be just "N" and use standard notation so instead of "1..n" use "1..*")  If the requirements define a multiplicity that does not exist in the model, the add that multiplicity.

Thursday, July 29, 2010

Factory Method Patterns (Implementation )

1-Factory Method is base on the Creations Pattern .
2-This Pattern is used to monitoring the type of instance of the class at the run time .
3-Calender Class is based on the factory Method
4-getInstance() static method is create different Class  Object at run Time.
Example :
In this example i try to explain  the Factory pattern .
Report  class  is responsible  to create type of reportObject  on the runtime .
Type Of Report
1-PDFReport
2-HTMLReport
3-ExcelReport
4-TEXTReport
5-XMLReport

//Report Class
-------------------------------------------------------------------------------------------------------------

package model;

import static  model.FactoryPattern.whichObjectCreate;

public class Report {
  
    public static void main(String[] args) {
      int pdfReport=1;
      int htmlReport=2;
      int excelReport=3;
      int xmlReport=4;
      int textReport=5;
      whichObjectCreate(pdfReport).reportType();
      whichObjectCreate(htmlReport).reportType();
      whichObjectCreate(excelReport).reportType();
      whichObjectCreate(xmlReport).reportType();
      whichObjectCreate(textReport).reportType();
    
    }
  
}
-------------------------------------------------------------------------------------------------------------
//FactoryPattern  Class
-------------------------------------------------------------------------------------------------------------
package model;

public abstract  class FactoryPattern {
   
   public static FactoryPattern whichObjectCreate(int reportType){
     switch(reportType){
      /*Case One  for HTML Report*/
       case 1: return new HTMLReport();
      /*Case Two  for PDF Report*/
       case 2: return new PDFReport();
      /*Case Three  for Excle Report*/
       case 3: return new ExcelRepot();
      /*Case Four  for XML Report*/
       case 4: return new XMLReport();
     }
     /*Default   for Text Report*/
     return new TextReport();
   }
   /*abstract method impelement by extends class */
   public abstract void  reportType();
 }
------------------------------------------------------------------------------------------------------------
//TextReport class
------------------------------------------------------------------------------------------------------------
package model;

public class TextReport extends FactoryPattern{
    public void reportType(){
      System.out.println("This Method is Generator TextReport");
    }
}
------------------------------------------------------------------------------------------------------------
//ExcelRepot class
------------------------------------------------------------------------------------------------------------
package model;

public class ExcelRepot extends FactoryPattern{
  public void  reportType(){
    System.out.println("This Method is Generator ExcleRepot");
  }
}

------------------------------------------------------------------------------------------------------------
//HTMLReport class
------------------------------------------------------------------------------------------------------------
package model;

public class HTMLReport extends FactoryPattern {
    
  public void  reportType(){
    System.out.println("This Method is Generator HTMLReport");
  }
    
}
------------------------------------------------------------------------------------------------------------
//PDFReport class
------------------------------------------------------------------------------------------------------------
package model;

public class PDFReport extends FactoryPattern{
  public void  reportType(){
    System.out.println("This Method is Generator PDFReport");
  }
    
}
------------------------------------------------------------------------------------------------------------
//XMLReport class
------------------------------------------------------------------------------------------------------------
package model;

public class XMLReport extends FactoryPattern {
    
  public void  reportType(){
    System.out.println("This Method is Generator XMLReport");
  }
}

Thursday, July 22, 2010

classNotFoundException vs NoClassDefFoundError

classNotFoundException
1-Thrown when an application tries to load in a class through its string name using -
1-The forName method in class Class
2-The findSystemclass method in class ClassLoader
3-The loadClass method in class ClassLoader
2-ClassNotFoundException indicates that a class needed for compilation cannot be found on the classpath
3-This is Compiler Time Exception.
4-ClassNotFoundException Extending the Exception Class
5-ClassNotFoundException is a checked exception.
6-Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

NoClassDefFoundError

1-NoClassDefFoundError indicates that the matching class that was found at compile time cannot be found at runtime.
2-NoClassDefFoundError is error not the exception.
3-This run time Error .
4-The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.