Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Factory Classes

 
Sonali Sehgal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone give me tutorials in Java Factory classes in Java 1.6
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by these Factory classes ? Classes that follow the factory method pattern ? Is this related to SCJP ?
 
Sonali Sehgal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking for a tutorial that can help me find out everything about factory classes .As far as meaning is concerned it is Classes that follow the factory method pattern
Whether this topic can be coverered in SCJP or not I am not much sure about it?
As far as I am concerned I am preparing for SCJP 1.6
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The SCJP does not necessarily ask you about factory method pattern. There are no resources that outline these classes for the SCJP as well, as far as I know.
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's nothing like this in the SCJP exam so...

moving this to the OO / patterns forum...
 
P Das
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably, I can try from my experience with others.

Basically, you are trying to create (instantiate) an object (of product) without directly calling the (product) class constructor by the client. Hence you create some client-helper-type (which is why you may need an interface, the Factory) that would call another interface that represent the Product super-type.

The basic objective of factories, which might be abstract factory, factory method, ... is to decouple the client from constructing a product. This is achieved by the above approach. In many practical apps, you have two super-types as interfaces: the Factory and the Product. Then you add concrete types to both of them, with the Factory meant to create the Product. Finally, your code becomes less brittle and more maintainable.

Hope, I was able to respond to your philosophical query.
 
P Das
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I forgot to add my humble suggestion for you to take time to read the Design Patterns by the GoF, which can provide you all information that you might need.

Some people find the HFDP useful; however, personally, I find it difficult reading because it is too full of lengthy examples and funny pictures. Apart from some patterns missing, content-wise, HFDP covers the GoF patterns.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic