Could someone explain the Factory Method Design Pattern

Hi Experts.
Could someone please explain for me the Factory Method Design Pattern. I read it a little and I understand that it is used in JDBC drivers but i'm not clear on it.
Could someone explain.
Thanks in advance
stephen

Basically, you have one class that's sole purpose is to create instances of a set of other classes.
What will usually happen is you have a set of related classes that inherit from some base class. We'll say for example that you have a base class CAR and it has sub-classes FORD, GM, HONDA (sorry Crylser). Instead of having the user call the constructors for FORD, GM, and HONDA, you can give the user a Factory Class that will give him a copy. We'll call our factory class Dealership. Inside dealership, you can have a static function :
public static Car makeCar(String type)
if(type.equals("FORD")
return new FORD();
else if(type.equals("GM")
return new GM();
else if(type.equals("HONDA")
return new HONDA();
So when the user needs a car, they will just call
Dealership.makeCar("FORD").
This is a good way to hide the implementation of your classes from the user, or if you require complex initialization of your objects.
Another good example of this is in the Swing library. To get a border around a component, you call static methods on BorderFactory.
Hope this helped.
Ed

Similar Messages

  • HT4436 I don't see the point of having to create another email account - could someone explain the thinking behind this please?

    For iCloud syncing there are a few items that require a new iCoud email address to be created (eg. Notes and email), whilst the majority of other options do not require this.
    My question is simply why do these items need yet another email address to be created?  I would have though the Apple Id would have been sufficient to hang everything together...
    If someone could explain the thinking behind this please I will hopefully be more comfortable with it and probably more likely to start using these features!
    Thanks in advance!
    Stuart

    If TCP port 25 isn't open, then SMTP services won't work.  That's the port that all SMTP servers use to communicate amongst themselves.    (Sure, you can change the port your SMTP server is listening on, but you'd also have to change the port processing on all of the other SMTP servers around — and if you did manage to implement that change everywhere, the local network folks would likely just block the new port for the same reasons they blocked the old port.)
    If you have a public static IP address and have correct forward and reverse translations — host domain to IP address, and IP address to host domain name — then you don't need and very likely don't want to run your own DNS server. 
    More to help you learn how these pieces fit together and not something I'd expect you would need given you have a public static IP and public DNS here is a detailed DNS server configuration article for OS X Server; enable Show All Records and it applies to Server.app on 10.7 and later.  If you have questions after reading that, I can certainly answer them and also update the article to try to reduce the confusion or answer the question.
    Your host didn't have valid reverse DNS, so you'll want to get that cleared up, and you'll want to get the port blocks cleared, or work with the local network folks to set up a relay through one of the existing mail servers.

  • Could someone explain the select comparison

    I am supposed to compare inputs on 2 numeric controls and if they are equal they will turn on an LED. I figured out how to do it with the = sign but I am supposed to use the select comparison. Could someone please help me?
    Solved!
    Go to Solution.

    No, you would not have to have another front panel Boolean to use the Select function. You could directly wire the results of anything that returns a True/False. You can also use block diagram constants.
    Message Edited by Dennis Knutson on 01-20-2010 09:47 PM

  • Could someone explain the following applications?

    I am using AppQLaunch and the following applications puzzle me.. None of them open up when I click on them (not standalone exe files?) but they must fill some meaningful purpose I am sure?
    -MsgUrlHandler
    -NOT
    -SMS (brings up System error -2 , why?)
    -SysApp
    -akncapserver
    -aknnfysrv
    -essysapp
    -lmsrvapp
    -psdk_lmsrvapp
    If someone could explain those, I would be thankful!

    Probably they're all mostly operating system background services or "engines" (or application supplied, if you have installed additional software yourself). Few are documented in any user or developer documentation.
    Some of them might be documented in, e.g, Symbian OS internals documentation or books like this one:
    http://developer.symbian.com/main/learning/press/books/os_internals/index.jsp
    For example, "akn" refers to "Avkon", which is the Nokia S60 user interface/middleware/runtime/application layer on top of the Symbian base operating system.

  • Could someone explain the purpose of "webscan" feature , I don't get it

    What does "webscan" do ?
    This question was solved.
    View Solution.

    Hi satwar,
    Webscan is a feature which is available in the EWS - Embedded Web Server. You can use it to scan a document, and then save it to your computer. Just another method of scanning a document.
    I am an HP employee.
    Say Thanks by clicking the Kudos Star in the post that helped you.
    Please mark the post that solves your problem as "Accepted Solution"

  • Can someone explain the best method of mac server network rollout?

    Hi there,
    Currently I have a client who started with 4 computers and a mac mini server for their file sharing.
    They've now expanded and have just over 20 computers, I'm consious of the fact that security is becoming an issue, and I'd like to tighten it up a bit - is there a common practice roll out that is performed?
    I'm torn between the idea of having some sort of centralised log in, with all settings managed by the server, and giving users home directories so all computers are just being used as terminals. Are there any drawbacks to this? What do most companies of this size do? They also have a couple of laptops that travel a lot - I guess these would need to be set up differently?
    Email and calendaring et.c is currently handle by gmail, but all their files are in-house.
    Any information would be most appreciated,
    Thanks

    There is no single scheme, as most every customer I've dealt with here has different requirements and constraints.
    For more than a handful of systems, Open Directory (once set up) (usually) makes distributed operations easier.
    Open Directory with local or served or portable home directories, gigabit wired for the core links (or better, depending on the traffic), 802.11n access points for wireless (preferably non-overlapping 5 GHz), external VPN-capable firewall with additional features as required, and get DNS services stable and working on a registered domain or subdomain of a registered domain (wonky DNS causes all manner of weirdness with network security and with various other services).
    Depending on local security requirements and the local network topology, you may want or need to add additional subnets.  In general, get out of the 192.168.0.0/24 and 192.168.1.0/24 subnets and preferably entirely out of the 192.168.0.0/16 block to avoid all the "fun" those (common) subnets will cause for remote VPNs.   Get to DHCP where you can.  (It's easier to change subnets when the network is small, and usually gets uglier as you get bigger, and as you acquire more fixed-address devices.)
    And you likely will be adding VPN connections for yourself and then specific folks at the customer site, even if the client doesn't think they will want those for more general access.  All protestations to the contrary, many customers will generally make some analog of an "oooh, cool" noise sooner or later, once they see how the VPNs work.
    Network security is a whole series of trade-offs and guesses around its value and its costs, and how big a target is painted on your customer from outside, from inside and from the occasional disgruntled associate.
    My preference is for the external firewall/gateway/router, and particularly a server-grade device.  If your customer has an external presence (web, mail, etc), then consider a DMZ for the remote-accessible services.  (Again, the local requirements here vary, and different customers can and usually will have sensitivities to data and data loss, and different values as attack targets, and differing budgets.)
    It's easiest to do a wipe-and-install on the clients, to bring those into the Open Directory network.  (It's possible to promote existing standalone clients, but that can sometimes get a little weird.)  The biggest issue here (in any case) tends to be with getting the file ownerships correct for the new user entries used in the Open Directory environment, as these have different ids and GUIDs.
    Apple's Client Management Whitepaper is a reasonable starting point for a condensed list of terms for your future Google searches and for the general concepts you'll be using, and then start reading the Mac OS X Server documentation for Open Directory and networking, and for the security manual.  Also have a look at the archives of the Mac Enterprise mailing list.

  • Could someone explain the cause of the recent print problem (in lay terms)?

    I am more curious than anything. It affected me on a R1800. Seems to be back to normal now.
    Thanks in advance.

    If you have installed Security Update 2008-002 you need to install the fixed version of it (v1.1) to get the "Printer Settings" functionality back in Aperture.
    The adjustment tools in 2.0.1 are the same as the 2.0 version, yes. The new and improved tools are part of the brand new 2.1 release of Aperture.
    chaos pilot

  • Could someone explain the differences between the 3 iPod Video versions?

    What are the differences between
    iPod Video / 5th Generation iPod,
    iPod Video 2nd Generation, and
    iPod Classic 6th Generation?
    If I understand correctly, the only thing that changed between the first two was the size of the hard drives. If that's true, all I'd like to know is what's new in the 6th Generation.

    iPod 5.5G has a brighter screen and new search features and 30GB & 80GB models.
    classic has better battery life, coverflow, more games, ability to watch rented movies, better battery life and 80GB and 160GB models.

  • Can someone explain the "colors" channel of the histogram?

    I'm using CS4 on a Mac
    Could someone explain the "colors" channel of the histogram? Does it simply analyze the image in terms of the % of pixels that are
    *blue
    *cyan
    *green
    *yellow
    *red
    *magenta
    *grey

    Good day!
    It represents which number of pixels have which values in the respective Channel, the refreshed total ("Pixels") is the total number of pixels (image or Selection).
    Regards,
    Pfaffenbichler

  • I know this isn't really the right place to ask, but could someone explain why when I open Portal 2, that I got off steam and spent a whole day downloading, keeps crashing when I click the Campaign/Single Player mode. It Freezes and then crashes. Help!

    I know this isn't really the right place to ask, but could someone explain why when I open Portal 2, that I got off steam and spent a whole day downloading, keeps crashing when I click the Campaign/Single Player mode. It Freezes and then crashes. Help!

    I know this isn't really the right place to ask...
    Uhm, why don't you go to the right place, then? There are several Steam/Portal forums out there...

  • Can Someone Explain the order of things Using Swingworker?

    Hi:
    Can someone explain very clearly the order of things using Swingworker? Please do not refer the SUN tutorials. I am totally dead in the water with a very large application and the order of things is not sensible. Also, if the worker thread is too long, the GUI gets updated, but my progress bar (killed right after in the finished method) remains running in some instances only.
    Can someone explain any debugging methods for thread work?
    I am a veteran programmer of 19 years and this one's got me. The event dispatch thread returns immediate, the GUI responds well, but the progress bar setVisible(false); ... just after in the finished() method (on Event Dispatch thread) does not go away, continues running, only on very long (large query) work. I'm truly stumped. I have successful applications of the Swingworker use, the progress bar, and everything works fine. Not this one.
    Debugging threads is what I need. Or some tool that visually shows threads as the program runs.
    Thanks for any help,
    PiratePete

    Thanks. I guess I should count my blessings when using free stuff. But I have been impressed with what the J2SDK has to offer. I have been writing a complicated application that I am going to market and most of my problems have been "design" in nature.
    Thanks again,
    PiratePete

  • Could someone explain what is Object?

    Could someone explain what is Object? I have a little
    idea what is it, but not sure. Please give me some
    concret example. Thanks.

    An object is an Instance of a class. A class describes a uniwue entity with behaviors and attributes. For example you can consider your arm.
    public class Arm {
      /** How many hairs on the arm. */
      private int hairCount;  // <== This is an attribute
      /** This is a method to set the hairCount Variable.
       * We dont let the outside user set it directly because that would
       * create problems if we wanted to change its implementation to
       * use a float. In addition we might have logic in this setter to
       * prevent bad data.
      public void setHairCount(final int hairCount) {
        // this is a good example of logic in the set method that we dont
        // want the user to bypass.
        if (hairCount < 0) {
          throw new IllegalArgumentException();
        this.hairCount = hairCount; // <-- Note how we have to use this. to
                                    //     access the instance variable
                                    //     insead of the parameter.
      /** This is a method to move the arm.
       * This is behavior of the class. ONLY behavior pertaining to an arm
       * belongs in the arm class. For example, the method "sneeze" would
       * not belong here but be in the Nose class instead. You can see then
       * that each class describes an entity.
      public void move() {
        // code to move the arm.
    }We have only ONE class per type but we can have many objects. For example the description of an arm does not change no matter who'se arm it is. The data in the class changes but not the actual essence of the arm. So we instantiate two arms for every person (assuming they arent disabled). To instantiate is to create a new object like so.
    Arm myarm = new Arm(): This creates a new object that we can work with.
    So consider the old inteview question of, "What is the difference between a class and an object?" The answer is, "A class is a map or desription of an object; whereas an object is a descrite instance of a class."

  • Can someone explain the use of a hashtable in java?

    can someone explain the use of a hashtable in java?

    Hashtable allows us to store values along with keys.
    One other advantage is, it provides Synchronised methods.
    Hope you got it.

  • Can someone explain the following to me

    Could someone explain what the below means (in layman's terms)?
    FAQ
    <script type="text/javascript"></script> Test1 comprises of Best Effort Test: -provides background information.
    Download  Speed
    113 Kbps
    0 Kbps
    250 Kbps
    Max Achievable Speed
     Download speedachieved during the test was - 113 Kbps
     For your connection, the acceptable range of speeds is 50-250 Kbps.
     Additional Information:
     Your DSL Connection Rate :1024 Kbps(DOWN-STREAM), 448 Kbps(UP-STREAM)
     IP Profile for your line is - 135 Kbps

    btspeedtester shows you are connected at 1024 but probably due to resets/disconnections your profile is rock bottom 135 instaed of 750
    you are on adslmax up to 8mb
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • Could someone explain to me why Flash virtual tours don't work after update to Flash Player 10.1?

    Hello there,
    Could someone explain to me why Flash virtual tours don't work after update to Flash Player 10.1?
    Thanks!

    www.privium.nl
    klick the icon image 'virtual tour' upper right corner.
    This works on my other pc, on which I did not update to 10.1 ...
    (I produced this virtual tour; it is stored on the FTP server of the service provider I use for this)
    Awaiting your reply,
    Regards,

Maybe you are looking for

  • How do I get my ipod to stop making me log into my account?

    My new ipod has been asking me to log in to my apple account. When I do, using the correct passwrod, as it tells me when my password is incorrect, the ipod immediately asks me to do it again. I can't do anything on the thing. Why is it doing this and

  • Material master account view1 Standard price by currency type

    Hi We have an issue in material master. When we create new material (Material Ledger activated) accounting view1 we are not getting fields for group currecny fields. How to get these fields. Regards Padma

  • Cancellation charge for upgrading ?

    Hello, I recently got a rather unplesant surprise with my latest bill when I recieved a £76.51 charge for upgrading my broadband from option 1 to the option 3. Now having read the terms I was under the belief that the only actions chargeable were dow

  • Hungapp When I Try to Play a CD

    I've tried removing and reinstalling iTunes, I've tried running a diagnostic (which caused the same problem), and I've tried multiple CDs. HELP!!! At thisa point I'll try antything short of buying a new computer or throwing this one off a cliff. Sinc

  • Type of Users and Explanation..

    Dear Gurus, This is the Basic question,i would like to know type of users in SAP their responsibility, like End user power user super power user core team member Other than these anything pls explain me.... Thanks a lot in advance Regards