Posts

Showing posts with the label Java

Abstract Factory Design Pattern

Factory of factories. To keep things simple you can understand it like, you have a set of ‘related’ factory method design pattern . Then you will put all those set of simple factories inside a factory pattern. So in turn you need not be aware of the final concrete class that will be instantiated. You can program for the interface using the top factory. There is also a view that abstract factory is ‘also’ implemented using prototype instead of factory methords pattern. Beginners for now please don’t yourself with that. Just go with factory methods pattern. As there is a word ‘abstract’ in the pattern name don’t mistake and confuse it with java ‘abstract’ keyword. It is not related to that. This abstract is from object oriented programming paradim. Sample abstract factory design pattern implementation in Java API XML API implements abstract factory. There is a class name SchemaFactory . This acts as a factory and supports implemenation of multiple schemas using abstract ...

Factory Method Design Pattern

Image
A factory method pattern is a creational pattern. It is used to instantiate an object from one among a set of classes based on a logic. Assume that you have a set of classes which extends a common super class or interface. Now you will create a concrete class with a method which accepts one or more arguments. This method is our factory method. What it does is, based on the arguments passed factory method does logical operations and decides on which sub class to instantiate. This factory method will have the super class as its return type. So that, you can program for the interface and not for the implementation. This is all about factory method design pattern. Sample factory method design pattern implementation in Java API For a reference of how the factory method design pattern is implemented in Java, you can have a look at SAXParserFactory. It is a factory class which can be used to intantiate SAX based parsers to pares XML. The method newInstance is the factory met...

Java Debugging with Eclipse

Image
1. Overview 1.1. What is debugging? Debugging allows you to run a program interactively while watching the source code and the variables during the execution. Via breakpoints in the source code you specify where the execution of the program should stop. To stop the execution only if a field is read or modified, you can specify watchpoints . Breakpoints and watchpoints can be summarized as stop points . ...