View RSS Feed

All Blog Entries

  1. Integrity Rules

    by , 03-09-2012 at 08:26 PM
    It shall be ensured by the relational tables that data is always accessible and accurate. To do this, implementation of the integrity rules is required. These rules shall be followed.
    • There shall be uniqueness in a tableís rows.
    • Correct results are not found easily and accessing data might result into certain issues. This happens when duplicate rows are present.

    Rules can be applied by user in most DBMS that duplicated rows are not permitted. In those cases, the insertion ...
  2. What Can SQL do?

    by , 03-09-2012 at 08:25 PM
    • Against a database, queries can be executed by SQL.
    • From a database, data can be retrieved by SQL.
    • In a database, records can be inserted by SQL.
    • In a database, records can be updated by SQL.
    • From a database, records can be deleted by SQL.
    • New databases are created by SQL.
    • In a database, new tables are created by SQL.
    • In a database, stored procedures can be created by SQL.
    • In a database, views are created by SQL.
    • SQL can set permissions at procedures, views and tables.
  3. Sql

    by , 03-09-2012 at 08:21 PM
    Databases are accessed by usage of a standard language SQL. It is used for the manipulation and also to access the data, in following.
    • MySQL
    • DB2
    • Access
    • Oracle
    • SQL Server
    • Sybase

    The SQL language consist of these language elements:

    • Clauses: Clauses are considered to be the constituent components of queries and statements.
    • Expressions: They can produce tabular data or scalar values which comprises of columns & rows.
    • Predicates: conditions
    Tags: sql Add / Edit Tags
  4. Builder Pattern - Specific problems and implementation

    by , 03-09-2012 at 08:16 PM
    Builder & the Abstract Factory

    Builder design pattern and the abstract Factory pattern have a lot of similar things. This is the reason why it is necessary to come up with certain different condition b/w situations, when we use one of them. For abstract factory, factory methods are used by the client so that to make its own objects. In case of builder, the builder class gets instructions regarding the way to create object. However in which way the class will be put together depends ...
  5. Builder Pattern - Applicability & Examples

    by , 03-09-2012 at 08:15 PM
    Builder pattern could be used when:
    • Creation algorithms of complexed objects are not dependent upon parts that compose the objects.
    • System allows the representation of many different objects.

    Vehicle Manufacturer

    Consider an example of vehicle manufacture that creates bicycle, a car, a scooter and a motorcycle. In such case, builder would be the Vehicle Builder. Interface is being specified to build any kind of vehicle in the above list by using similar ...
  6. Builder Pattern - Implementation

    by , 03-09-2012 at 08:13 PM
    Factory builder pattern is used by the builder design patter so that to make a decision which concrete class for initiation to build the desired object type.

    In this pattern, the participant classes are:
    • An abstract interface is specified by the builder class to create the product object parts.
    • ConcreteBuilder creates and puts the product parts together by doing the implementation of the builder interface. It also keeps the proper representation track that has been created
  7. Builder Pattern

    by , 03-09-2012 at 08:12 PM
    Complexity of the objects as well as classes increases along with the complexity of an application. Complex objects basically are manufactured of those parts that are produced by the various other objects which require special attention while building. A proper mechanism is needed by the application to build the complex objects, independent of those that build object. If you are also facing the same problems then try to use the Builder design pattern.

    Such patterns permit the client ...
    Builder Pattern
  8. Class Registration - using reflection

    by , 03-09-2012 at 08:11 PM
    Registration of the new product class could be done to the factory in case you use reflection (e.g in .NET languages or Java), without making any change in factory itself.Without being aware of the object type for creation of the objects in factory class, a map is kept b/w class type and productID. In this particular case, when new product gets added to the application then it shall be made registered to factory. No change is required in factory class code for this kind of operation.
  9. Factory Pattern Applicability & Examples

    by , 03-09-2012 at 08:09 PM
    Factory pattern is most widely used pattern.

    E.g, graphical applications do their work along with shapes. In implementations, shapes are products and drawing frameworks are the clients. An abstract shape is responsible for the derivation of the shapes. Shape class defines the move operations and draw that shall be implemented by concrete shapes. Now let us assume that a particular command has been selected from menu so that to make a new circle. Shape type is being received by the ...
  10. Factory Pattern

    by , 03-09-2012 at 08:07 PM
    Most widely used design pattern is the Factory design pattern in modern programming languages, for example C# and Java. It comes in many different implementations and variants. If you are seeking them you will probably find out certain references regarding GoF patterns: Abstract Factory & Factory Method.
    Commonly used factory patterns are defined here and also you might check out the similar original factory method patterns.
    • Without exposure of the instantiation logic, objects
    Factory Pattern
  11. Serialization

    by , 03-09-2012 at 07:50 PM
    If the interface is being implemented by the Singleton class ( when serialization and deserialization of singleton takes place more than one time) then number of Singleton instances will be created. For avoiding this, implement the readResolve method.
    Java Code:
    	public class Singleton implements Serializable {
    		// This method is called immediately after an object of this class is deserialized.
    		// This method returns the singleton instance.
    Singleton Pattern
  12. Protected constructor

    by , 03-09-2012 at 07:49 PM
    For allowing the singletonís sub-classing, there is a possibility to use the protected constructor. Such technique consists of two main drawbacks which makes the inheritance of a singleton impractical.

    • If constructor is protected then instantiation of the class can be done by calling the constructor from some other class present in the similar package. Creation of the singletonís separate package can avoid it.
    • For using the derived class, change all getInstance calls present
  13. Early instantiation using implementation with static field

    by , 03-09-2012 at 07:48 PM
    The singleton object gets instantiated in case the class gets loaded & is not when it is used first, in the given implementation. This happens because the instance member has been declared static. Thatís why there is no need of synchronization of any part of the code, in such cases. Class gets loaded once when the uniquity of the object is guaranteed.
    Java Code:
    //Early instantiation using implementation with static field.
    class Singleton
    	private static Singleton
  14. Lazy instantiation using double locking mechanism

    by , 03-09-2012 at 07:45 PM
    The standard implementation is a thread-safe implementation. However, it is not the best implementation as when you talk about performance, the synchronization is quite expensive.When the object gets initialized, there is no need to check the synchronized method getInstance for synchronization. When singleton object has already been created, just return it without making use of synchronized block.

    When for the first time getInstance() method is called, singleton instance is created. ...
  15. Singleton Pattern Applicability & Examples

    by , 03-09-2012 at 07:43 PM
    Singleton Pattern according to its definition shall be only used if there is exact one instance of class and also when its accessibility is given from a global access point to the clients.Few real situations are given here where singleton is used:

    Logger Classes

    In design of the logger class the singleton pattern is used. Such classes are basically implemented as singletons so that to provide a global access point for all the components of application. For this purpose ...
  16. Singleton Pattern Implementation

    by , 03-09-2012 at 07:39 PM
    A static member is involved in Singleton class, a static public method and a private constructor while doing implementation. This makes a reference to be returned to the static member.

    A getInstance operation is being defined by the Singleton pattern which gives exposure to the unique instance. This unique instance is accessible by the clients. Responsibility of the getInstance() is to create class unique instance if it is not built uptill now and also to return the instance.
  17. Singleton Pattern

    by , 03-09-2012 at 07:38 PM
    Singleton pattern is considered to be a design pattern in software engineering which is used for the implementation of the mathematical singletonís concepts. It is done by making restrictions at the instantiation of one class to 1 object. It is more beneficial in those cases when just 1 object is required to make the coordination of the actions, across the system. This concept is basically generalized to all those systems which are operating efficiently when 1 object is peresnt, or when instantiation ...
  18. A recursive method for searching an array of integers...

    by , 03-08-2012 at 09:49 PM
    Java Code:
    public class ArrayLister {
    	private static int arraySearcher(int[] arrayToSort,int numberToFind,int left,int right){
    		int middle = (left + right) / 2 ;
    			if(arrayToSort[middle] == numberToFind) {
    				return middle;
    				return -1;
    		if(arrayToSort[middle] == numberToFind) {
  19. Printing Support in Swing Components

    by , 03-07-2012 at 06:53 PM
    Contents out of view or which are invisible because of scrolling in a scrollable window would not be present in a printout. At printer, they will be placing a dumb effect. This specified problem is usually present with larger components printing like a swing table or text components.

    Multiple lines of text are present in many components that are entirely not visible at the screen. Contents shall be printed in a way that is consistent along with the screen display.

    For ...
  20. Print Service Discovery

    by , 03-07-2012 at 06:51 PM
    Abstract class PrintServiceLookup static methods are invoked by the application so that to locate the print services that possess certain abilities to makes the print requests of an application satisfied. E.g, to print out 2 copies of double sided document first thing that shall be searched by the application is the printers that hold the ability of double sided capability.
    Java Code:
    DocFlavor doc_flavor = DocFlavor.INPUT_STREAM.PDF;
    PrintRequestAttributeSet attr_set =
  21. Attribute Definitions

    by , 03-07-2012 at 06:50 PM
    The javax.print.attribute.standard & javax.print.attribute packages details those attributes of prints that show the print serviceís capabilities, requirement of print job or the progress of print job.

    E.g, for using A4 paper format to print 3 copies, you shall construct following attributes set implementing
    the PrintRequestAttributeSet interface:
    Java Code:
    PrintRequestAttributeSet attr_set =
        new HashPrintRequestAttributeSet();
  22. Document Type Specification

    by , 03-07-2012 at 06:41 PM
    Format of the print data is presented by DocFlavor, like PostScript or JPEG. There are 2 main parts of the DocFlavor: A representation class name or a MIME type. MIME shows that what is the format and a document representation class name show the way documents are delivered to output stream/ printer. An attribute set and DocFlavor is used by an application to find printers with certain capabilities that have been specified by attribute set. Such sample code shows the way an array of StreamPrintServiceFactory ...
  23. Working with Print Services and Attributes

    by , 03-07-2012 at 06:39 PM
    The Javaô Print Service (JPS) API makes the extension of the current features of Java 2D printing so that to offer these functionalities:
    • Printers which cater to the needs of application by querying the capabilities of printers are discovered.
    • Attributes are extended by the application included with the JPS API.
    • With service provider Interface, 3rd parties might put their print services which print varying formats, including PDF, SVG and Postscript.

    The Java Print Service ...
  24. Printing a Multiple Page Document

    by , 03-07-2012 at 06:11 PM
    To print number of graphic images, page index is used so that to iterate via pages & print just 1 at every page. E.g, many images are presented in this array:
    Java Code:
    BufferedImage[] images = new BufferedImage[10];
    Then, use the print() method as in the following code fragment:
    public int print(Graphics graphics,
               PageFormat pageFormat, int pageIndex)
               throws PrinterException {
        if (pageIndex < images.length) {
  25. Using Print Setup Dialogs

    by , 03-07-2012 at 06:09 PM
    Typically a user wishes to see the print dialog box and page setup. One can select a printer from the print dialog, pages to be printed may be specified and also number of copies could be set.

    Name:  1.JPG
Views: 730
Size:  26.7 KB
    Print Setup Dialog

    A Print dialog is displayed by an application when a button of print command is pressed by user or he selects an item from print menu. In order to display this dialog

    Call the printdialog method of the PrinterJob ...
  26. Basic Printing Program

    by , 03-07-2012 at 06:07 PM
    Printing consists of following two parts:

    Job Control: Following are part of job control.
    • Creating a print job
    • Associate it with printer
    • Specify no of copies
    • User print dialog interaction

    Page Imaging: It includes drawing content to a page.
    The java.awt.print package includes the classes to create a printer job and most other related classes are part of this package.
    Java Code:
    import java.awt.print.*;
    PrinterJob job = PrinterJob.getPrinterJob();
  27. Writing/Saving an Image

    by , 03-07-2012 at 06:04 PM
    It has been explained to use the javax.imageio package so that to load image to Java 2Dô's internalBufferedImage format from an external image format. Also, the usage of Graphics.drawImage() has been explained to draw images with an optional filtering.

    To an external image format, the BufferedImage object is saved. This image might be the one that was loaded originally by Image I/O class, from external image format. It might also be the one which was constructed by Java 2D or was ...
  28. Creating and Drawing to an Image

    by , 03-07-2012 at 06:03 PM
    The process of loading an image is already known, which is created as well as stored on any network or your system. However, you would also want to make a new pixel data buffered image.

    BufferedImage object can be created manually by making use of 3 constructors of class:
    • new BufferedImage(width, height, type) - creates a BufferedImage for one of the predefined type of image.
    • new BufferedImage(width, type,height, colorModel) - creates a BufferedImage of the predefined
  29. Filtering Images

    by , 03-07-2012 at 06:02 PM
    In addition to copying and scaling images, the Java 2D API also filter an image. Filtering is drawing or producing a new image by applying an algorithm to the pixels of the source image. Image filters can be applied by using the following method:

    Java 2D API filters images along with copy or scaling the images. Filtering means producing a new images by applying algorithm to the source image pixels.
    Java Code:
    void Graphics2D.drawImage(BufferedImage img,
  30. Drawing an Image

    by , 03-07-2012 at 06:00 PM
    Graphics.drawImage method is used to draw the images at a specific location:
    Java Code:
    boolean Graphics.drawImage(Image img,
                               int x, int y,
                               ImageObserver observer);
    Top left position of an image is specified by x,y location. Observer parameters are usually null as they are not used frequently or directly & is also not required for BufferedImage.

    This method is used just when there is a need ...
Page 16 of 48 FirstFirst ... 6141516171826 ... LastLast