2 Replies Latest reply: May 17, 2010 10:30 AM by 843853 RSS

    Factory pattern guidance on a project

    843853
      Hello, on a school assignment that I was given one of the requirements was to use a pattern studied at school. I only found out that later after the assignment is in it's finishing stage. Upon researching I found out that the Factory method pattern would be easiest to implement without major changes. The context of the project:
      I manage a tower Control from an airport that manages the flight of planes( which track to land on , to ascend from, if a plane is spotted on their radar he should be able to obtain information about that plane , generate an updated situation of the flights ). The initial data of tracks and the planes and flights is given by a database. The updated situation on the flights is given through a PDF file using the iText API. I was thinking of using the factory method pattern to write a class for opening connections on different database servers or to write a class for generating different PDF documents(of different forms ) for different uses ( a log file, updated flight plan, plane status for those who have docked in the airport). The whole tower control system is managed by a Manger class. Which of the two should I use and which would be easiser to implement? If I'm wrong about this(the way to use the factory pattern) please guide me in the good direction.
        • 1. Re: Factory pattern guidance on a project
          jschellSomeoneStoleMyAlias
          I presume that the point is just to stuff a pattern in somewhere without regard to how real sensical it is.
          using the factory method pattern to write a class for opening connections on different database servers
          That would normally be an abstract factory. The abstract factory create a factory for a specific database. Then the factor is used to create connections to a single database.

          Doing both should not be that difficult.
          generating different PDF documents(of different forms ) for different uses ( a log file, updated flight plan, plane status for those who have docked in the airport).
          So all of that code already exists? And right now there is an 'if' somewhere that creates a different instance based on some value? If so then you could replace that if with a factory. Again not to hard. If that code doesn't exist then go with the database.
          • 2. Re: Factory pattern guidance on a project
            843853
            jschell wrote:
            I presume that the point is just to stuff a pattern in somewhere without regard to how real sensical it is.
            Yes.

            >
            generating different PDF documents(of different forms ) for different uses ( a log file, updated flight plan, plane status for those who have docked in the airport).
            So all of that code already exists? And right now there is an 'if' somewhere that creates a different instance based on some value? If so then you could replace that if with a factory. Again not to hard. If that code doesn't exist then go with the database.
            Yes, the code exists along with the output data that must be written. Then I will go along with the document factory. Thanks for the guidance.