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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Need help with design patterns

  • 27-11-2005 10:10pm
    #1
    Registered Users, Registered Users 2 Posts: 1,559 ✭✭✭


    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, Registered Users 2 Posts: 1,559 ✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


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


Advertisement