Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Need help with design patterns

Options
  • 27-11-2005 11:10pm
    #1
    Registered Users Posts: 1,551 ✭✭✭


    Ok Ive got a project due in tomorrow and I need to know if the below code is in the form of a facade design pattern ?
    It calls one big method in the project 4 class which creates instances of the student and supervisor classes and its own class.


    Is this a facade?

    public class TableFacade
    {
    TableFacade()
    {
    System.out.println("This is the table of projects");
    }

    public Project4 makeTheTable()
    {


    Supervisor5 sup = new Supervisor5();
    Project4 project =new Project4();
    project.readRelevantProjectsFromFile(sup);


    return project;
    }
    }


Comments

  • Registered Users Posts: 1,551 ✭✭✭quinnd6


    Im trying to adapt from my project4 class
    is this in the adaptor pattern?



    class AdaptProject
    {
    Project4 project;
    Supervisor5 supervisor;

    void readProjectDetails()
    {

    project.readProjectDetails();


    }

    void readRelevantProjectsFromFile(Supervisor5 v)
    {
    project.readRelevantProjectsFromFile(supervisor);

    }

    String projName()
    {
    return project.projName;
    }
    String projSubject()
    {
    return project.projSubject;
    }
    }


  • Registered Users Posts: 4,188 ✭✭✭pH


    As these are patterns they are open to interpretation but:

    In general the Facade pattern wraps an existing class, and simplifies it. So for something to be a facade pattern it should really wrap only one other class and provide a simpler way of accessing (its over-complex methods)

    The simplest way to think of an Adaptor pattern (at least in java terms) is a new class that wraps another one so that it now implements an interface.

    - There should be an existing interface (that code already uses)
    - There should be an existing class that doesn't implement that interface.
    - The Adaptor class implements both wraps the existing class *AND* implements the interface.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I would say a facade could wrap one or more classes.


Advertisement