Unusual use of the static getInstance factory class definition interface

This question is prompted by a recent new to Java forum question asking about the differences between Interfaces and abstract classes. Of course, one of the standard things mentioned is that interfaces can't actually implement a method.

One of my former clients, the 500 group, using interfaces as class factories. The interface defines a static class of the pubis with a static method public, getInstance, who is called to generate instances of a class that implements the interface.

This architecture was very object oriented, made good use of polymorphism and worked very well. But I have not seen this used anywhere architecture elsewhere, and it seemed a bit convoluted.

Here's a version of 'Nick' of the model of the base interface and use
-- interface that defines public static factory class and getInstance method
public interface abc {
    public static class FactoryClass
    {
        public static abc getInstance ()
        {
            return (abc) FactoryGenerator(new abcImpl(), abc.class);
        }
    }
}

-- call of interface factory to create an instance
abc myABC = abc.Factory.getInstance();
1. each major functional area ('abc' in the above) has its own factory of interface
2. each major functional area has its own implementation of this interface class
3. There is a generator (FactoryGenerator) that uses the interface class ("abc.class") to determine the implementation to instantiate classes and return. The generator class can be configured at startup to control the actual class of return for a given interface.

I should mention that the people who designed this whole architecture were not novices. They wrote very sophisticated multi-threaded code that rarely had problems, was high performance and was easy to extend to add new features (interfaces and classes of application) - pretty much plug-n-play with little, if any, side effects affecting existing modules.

It is a process of best practices of factory design classes and methods? Please provide feedback about the use of an architecture like that.

The way he explained to me at the time is that the interface uses standard naming conventions and acts as a template to make it easy to clone new modules: just change 'abc' to 'def' in three places and write a new class of "defImpl" which extends the interface and the new interface and the class can simply 'plug in' to the framework.

There are in your pseudo code code in the interface to build a new abcImpl(). This deployment of a new plant means a change of this interface. If this is what is meant, it is poor. See java.util.ServiceLoader for an example of the right way to do it, with the implementation classes named in an external file.

The generator class might use the information, if provided, to provide a new version of the class which would extend this default class.

I hope so, but who is not exposed by your pseudocode.

I never saw any 'Java' pattern that looks like this or any model where a contained interface a class.

There are several examples in the JDK. Unfortunately I can't think of them right now. ;-)

It seemed really complicated for me

Me too.

and it looks like the "versioning" aspect could be accomplished in a much simpler way.

Indeed, he can see java.util.ServiceLoader.

Tags: Java

Similar Questions

  • Use of the static keyword in this context?

    Hi all

    I have an application that has a class I want that all the other classes to access them. I'm not sure is how implement it correctly or it even happen. For example, consider the following:

    Main class
    public class Main {
    
        public static void main(String[] args) {
            new Main();
        }
    
        static SecondClass secondClass = new SecondClass();
    
        public Main() {
            
        }
    
    }
    Second class
    public class SecondClass {
    
        public void method() {
            System.out.println("Method in Second Class");
        }
    }
    Third class
    public class ThirdClass {
    
        public void doSomething() {
            //is this appropriate?
            Main.secondClass.method();
        }
    }
    Now I know that I could just pass an instance of the second class to all classes that need to use the second class, but I thought it would be easier to declare the second static class instance so that I could do the following to access easily given that I only ever need one instance of the class :
    Main.secondClass.method();
    So my question is, this approach would be appropriate or it is badly perceived to access a class in this way?
    Thank you. :)

    I know that my problem would be solved if all of these classes were in a class

    No, your project is too important so a class... it has too many different types of objects.

    Neptune, I see that your project suffers from the poor class design. It seems obvious to me that you DON'T know what must do your application, you know what it should look like, you know that you listen to the clicks of a mouse, you know you need thumbnails etc etc. But none of this will work if the data is not organized properly - and that will not happen if you do not know how each each object fits.

    You develop this project to the rear. Start with data. It is. What are the data? How should be organized? What data should go to what class? etc. In addition, you must name your classes with intuitive names.

    Since your project is essentially a Photo Viewer, I sggest you name your main class just that...

    public class PhotoPreviewer
    {
      Album[] albums;
    }
    

    ... Notice the preview generator will now be able to access an array of objects from the Album. Now for the class from the Album...

    public class Album
    {
      String albumName;
      Photo albumPhoto;
      Photo[] photos;
    }
    

    ... see how each album has now a name and a single object of Photo to represent it in the previewer? It also contains an array of Photo objects, which we will see now.

    public class Photo
    {
      URL url;
      BufferedImage image;
      BufferedImage thumbnail;
    }
    

    See how each picture maintains the URL, an image, and it's own miniature?

    Now you can see what the data is and how the photos and Ablums of fit together to make the whole of the PhotoPreviewer project.

    But with all these classes separated I'm not sure how to communicate properly.

    Just add the combination of methods of accessor (GETTER and SETTER) as well as the methods of transmission as I described above.

    Neptune, you see that you need start your projects based on the data it processes? Do not start a project of the graphic aspect and Auditors, managers and the buttons of the things... Start your projects with the data, and how these data fit. Once you get the data goes, THEN add graphics, pretty icons and a graphical interface.

  • vSphere 5.5 kickstart to configure the static IP address

    Hello people,

    I spent some time trying an involuntary installation works correctly and adding features I want.

    Right now I'm trying to run a command after installation and reset to configure a static ip address for the host.

    I can say that the configuration file is the application, but does not have the IP address.  Value DHCP when you are finished.

    My KS.cfg file, can someone tell what I do wrong?

    Thank you, romatlo

    # Example scripted installation file

    #

    # Accept the VMWare end user license agreement

    vmaccepteula

    # Set the root for the mode DCUI and Technical Support password

    rootpw tet_password1

    # The installation media is in the CD drive

    install firstdisk - overwritevmfs

    # Define the DHCP network on the first network adapter

    network - bootproto = dhcp - device = vmnic0 - addvmportgroup = 0

    reset

    firstboot % - interpreter = busybox

    # Assign an IP address to the first VMkernel, used for the management

    esxcli ip network interface ipv4 set - name = vmk0-= ipv4 interface 192.168.32.15 - mask = 255.255.255.0 - Gateway = 192.168.32.1 - type static = subnet

    Memory, don't you must first create a VMkernel interface?

    -name of the interface:-i The name of the VMkernel network interface to the IPv4 settings. This name must be an interface in the interface list command.

    VSphere Documentation Centre

    Ensure that vmk0 is listed when you run

    list of network ip interface

    In addition, what happens if you install ESXi manually and run this?

    # Assign an IP address to the first VMkernel, used for the management

    esxcli ip network interface ipv4 set - name = vmk0-= ipv4 interface 192.168.32.15 - mask = 255.255.255.0 - Gateway = 192.168.32.1 - type static = subnet

    FYI in my KS.cfg I have this

    network - bootproto = - 192.168.250.21 = static ip - gateway = 192.168.250.1 - nameserver = 192.168.250.6 - subnet mask = 255.255.255.0 - hostname = esxi5---.lab.local head = vmnic0 - addvmportgroup = 0

    Instead of

    network - bootproto = dhcp - device = vmnic0 - addvmportgroup = 0

    and

    esxcli ip network interface ipv4 set - name = vmk0-= ipv4 interface 192.168.32.15 - mask = 255.255.255.0 - Gateway = 192.168.32.1 - type static = subnet

  • What's wrong with the dynamic region within the static region

    Hi all

    I use Jdeveloper 12 c

    I do app with a jsf page (man.jsf) contains the static region (xxx.jsff)

    the static region contains a dynamic region and I define the scope in the tent (adfc-config) (backingbean extended, scope of the request, see scope)

    the result is main.jsf is empty

    hand. JSF > > xxx.jsff (static region) > > bb.jsff (dynamic region)

    http://127.0.0.1:7101/face/hand? _afrLoop =

    What is the solution for this problem.

    Hello

    Actually the managed bean used by the static region should be extended to at least view. The managed bean should be defined in the configuration of the workflow of the static region.

    Frank

  • Why not use the static methods - example

    Hello world

    I would like to continue the below thread about "why not use static methods.
    Why not use the static methods
    with the concrete example.

    In my small application, I need to be able to send keystrokes. (java.awt.Robot class is used for this)
    I created the following class for these "operations" with static methods:
    public class KeyboardInput {
    
         private static Robot r;
         static {
              try {
                   r = new Robot();
              } catch (AWTException e) {
                   throw new RuntimeException(e + "Robot couldn't be initialized.");
              }
         }
         
         public static void wait(int millis){
              r.delay(millis);
         }
         
         public static void copy() {
              r.keyPress(KeyEvent.VK_CONTROL);
              r.keyPress(KeyEvent.VK_C);
              r.keyRelease(KeyEvent.VK_C);
              r.keyRelease(KeyEvent.VK_CONTROL);
         }
    
         public static void altTab() {
              r.keyPress(KeyEvent.VK_ALT);
              r.keyPress(KeyEvent.VK_TAB);
              r.keyRelease(KeyEvent.VK_TAB);
              r.keyRelease(KeyEvent.VK_ALT);
         }
    
                   // more methods like  paste(), tab(), shiftTab(), rightArrow()
    }
    You think it's a good solution? How could it be improved? I saw something Singleton vs somewhere of static methods. Wouldn't be better to use Singleton?

    Thanks for your comments in advance.
    lemonboston

    maheshguruswamy wrote:

    lemonboston wrote:

    maheshguruswamy wrote:
    I think a singleton might be a better approach for you. Just kill the public constructor, and provide a getInstance method to provide late initialization.

    Maheshguruswamy thanks for the tips on the steps create a singleton of this class.
    Perhaps you could say also why do you say that it would be preferable to use singleton? What is behind it? Thank you!

    In short, it seems to me that a single instance of your class will be able to coordinate actions across your entire application. If a singleton should be sufficient.

    But who doesn't answer why he expected prefer a singleton instead of a bunch of static methods. Functionally, the two are almost identical. In both cases, there is that a single 'thing' to call methods - either a single instance of the class or the class itself.

    To answer the question, the main reason to use a Singleton on a class of static methods is the same reason readers much of not static vs static decisions: polymorphism.

    If you use a Singleton (and and interface), you can do something like this:

    KeyboardInput kbi = get_some_instance_of_some_class_that_implements_KeyboardInput_somehow_maybe_from_a_factory();
    

    And then everything calling public methods of KBI has to know that there an implementor of this interface, without worrying about what concrete class is, and you can replace some implementation is appropriate in a given context. If you do not need to do, then the approach of the static method is probably enough.

    There are other reasons that may suggest a Singleton - serialization, persistence, use as a JavaBean pop to mind - but they are less frequent and less convincing in my experience.

    And finally, if this thing keeps updated a State between method calls, even if you can manage it with static member variables, it is more in line with the OO paradigm to make them non-static fields of an instance of this class.

  • to access the data of the children with the static accessor of parent class

    I'm new to LVOOP. I'm trying to create accessors of data in the parent (static) class and use them in the child's class. I don't need them to be dynamic becase the accessors are identical for child and parent. Is it possible to access the data of a class without creating an accessor for each class?

    It is the dynamic method that I created that finally works. Once I found the VI "call Parent Method.vi' everything has worked.

    So now I created all my data as static accessors and my methods are dynamic (assuming that they do).

    Thanks for all the help.

  • I recently bought a used iPhone 6, I was able to reset the phone to factory settings, but unfortunately, the iPhone is still under an other customers Apple ID, is it all the same way I can have this changed?

    I recently bought a used iPhone 6, I was able to reset the phone to factory settings, but unfortunately, the iPhone is still under an other customers Apple ID, is it all the same way I can have this changed?

    Turn off find my iPhone Activation Lock - Apple Support

    contact the person you bought the phone from and their info to remove the lock of the activation.

  • Question about the use of the custom component class define what declarative component

    12.1.3 jdev

    I'm trying to define a declarative component with my custom component class.

    This is the code for my component jsf declarative. I'm trying to use the label on selectManyListbox attribute to pass queryClass for my component class name. It does not work. I also try to use f: attribute to my component class. It does not work too. Question 1: how to move my declarative component attribute to my class of component?

    < af:panelLabelAndMessage label = "#{attrs.displayLabel}" id = "dc_plam1" > "

    < af:switcher id = "dc_s1" defaultFacet = "a lot" facetName = "#{attrs.single eq 'true'?' unique ': 'a lot'}" >

    < f: facet name = "a lot" >

    < af:selectManyListbox id = "namingp1" simple = "true" label = "#{attrs.queryClass}" "

    ' autoSubmit Binding = "#{dropListComp.selectManyListBox}" = "true" valueChangeListener = "#{dropListComp.selectManyValueChange}" >

    < f: attribute name = "queryClass" value = "#{attrs.queryClass}" / >

    < / af:selectManyListbox >

    < / f: facet >

    < f: facet "single" = name >

    < af:selectOneListbox id = "sl_2" simple = "true" label = "#{attrs.queryClass} '"

    autoSubmit Binding = "#{dropListComp.selectOneListBox}" = "true" valueChangeListener = "#{dropListComp.selectOneValueChange}" > "

    < / af:selectOneListbox >

    < / f: facet >

    < / af:switcher >

    < / af:panelLabelAndMessage >

    That's how I try to retrieve the label or f: attribute queryClass in my component class. I get null for both directions.

    {} public void setSelectManyListBox (RichSelectManyListbox selectManyListBox)
    this.selectManyListBox = selectManyListBox;
    If (this.selectManyListBox.getChildCount () == 0) {}
    queryClass = (String) this.selectManyListBox.getLabel ();
    System.out.println (".. queryClass of the label..." + queryClass);
    If (queryClass is nothing)
    {
    queryClass = (String) this.selectManyListBox.getAttributes () .get ("queryClass");
    System.out.println (".. queryClass of attr..." + queryClass);
    }
    If (queryClass is nothing)
    queryClass = "glog.server.query.powerdata.InvolvedPartyQualQuery";
    this.selectManyListBox.getChildren () .addAll (buildDropListSelectItems (queryClass));
    }
    }

    Thank you.

    Hello

    If your declarative component has a defined class of request attribute then #{attrs.name_of_attribute} called from Java should be able to solve

    Frank

  • Why not use the static methods

    Hello world

    I was informed in a previous thread to avoid using static methods it was possible.
    Why is it, could someone please tell me a little more about this? Are there best practices, concepts on this?

    Thanks in advance,
    lemonboston

    Hi Lemonbottom,

    The rule I used generally goes like this:

    If the method does something that I can use without the object containing it instantiate, then it can be made public static.

    In the previous examples, I had various foods. Apple might have a method called "getCaloricContent" that returns the number of calories in an Apple. I don't need an actual Apple to get this information, so I do static. However, if I want to Breathe() an Apple, then I need to build an Apple to do this, so static would not be appropriate.

    It is a loose guidance to help you get started. Try to avoid as much as possible of static methods. They add an extra dimension (often unwanted) to unit tests. It's not so say it is not a proper use of static methods.

    Once you've got your head around this concept, consider the model Singleton, who, in most cases, eliminates the need for static methods of learning.

    Kind regards
    Robb Salzmann

  • How to use an Image to customize the static button Widget

    Just find someone to help me find a way to use a picture to customize the static button widget, please?

    I tried to use different types of images, but none of them seem actually to change the appearance of the button.

    Thank you!

    Laura

    Captivate 5.5

    Sorry for my late reply, was too busy yesterday.

    I checked out, and when you choose a picture in the properties of the Widget, you must use the preview area to drag the image on the top of the key and finally to resize it so that it covers the default button. When posting, please remember to put the image in the same folder as the SWF file published. Here's an example: I point to an image and rescaled the area with the small image icon so that the original button is completely covered. Of course, be sure to not have transparency in your image.

    I forgot to say that you won't see the image after the publication, not in preview...

    Lilybiri

  • Is there a way to change the models used to generate the client proxy WSDL classes

    Hello
    I'm curious to know if we will be able to customize the generation of proxy WSDL in the FB3 WSDL Import tool. The reason is that it creates quite a mess of spaghetti at the moment and it would be nicer to have a structure to create it classes. something like:

    generated. WebServices.WebService1
    generated. WebServices.WebService1.VO
    generated. WebServices.WebService1.service

    etc...

    In addition, buy using namespaces we can import several webservices in a project that COULD have your bearing the same name.

    Now, it's probably fine for users who have just a few methods for import, but once you start bringing some Web services, each with 20 methods, the directory structure is quite messy.

    Thank you
    Todd

    Hi Todd,

    No, the models used to generate the wsdl files are not editable, and for your destination will not help that much either - it is set at the location code files and not models. In addition, a proposal like this has been taken into account, but it won't really use of the function in the mxml syntax. By having more than one folder, you need to define several namespace prefixes and use - for example for service, one for the vo

    Now you can import several services, even if they have similar class names, by setting the names of different package - the generated.webservices it is just the default that provide us with when you load the wsdl of a local computer document. You must use your own package name - for example com.service_name.

    Hope that helps,
    Cristian

  • Can I use the static gateway on an interface with assigned DSL gateway on the other interface on the same computer, windows 7?

    I have two NIC on a machine, one is connected to the ADSL line which is active DHCP, so it gets the gateway from DHCP and IP address information. Can I assign another static gateway on my second interface for internal communication?

    Hi Aditya,

    The question you posted would be better suited in the MSDN Forums. I would post the query in the link below.
    Hope this information helps you.
  • Variable static in a class bug?

    Hi guys. I try to keep a number of objects of a class with the static count variable.

    When I try to compile with 'public static int count' it gives the compiler errors "reference to undefined"Box::count"for the two cases where the number is incremented and decremented

    Strangely, it compiles perfectly if I use only "int count" without the keyword 'static'... but it's not useful to me.

    Here is my code... can someone tell me where I have gone wrong?

    #include
    using namespace std;

    Box class
    {
    public:
    public static int count;
    Box()
    {
    Count ++;
    } //compiler survey "refers to the undefined"Box::count"here
    ~ Box()
    {
    County;
    } //compiler survey "refers to the undefined"Box::count"here
    };

    int main (int argc, char * argv)
    {
    Area B1;
    fprintf (stderr, "Hello");
    return 0;
    }

    Welcome on the support forums.

    You must initialize the static variable
    you access the variable with Box::count

    See
    http://www.parashift.com/c++-FAQ-Lite/link-errs-static-data-MEMS.html

  • With the help of several classes and create an object of a class and calling its method in a different class.

    Creating a new class, I need to move my main method class SaveDate DynamicTest class. Below I've listed the code of both classes. The goal is to be able to run my class DynamicTest program. I need help to understand the process of moving my main method of a different class and creating an object of a class and calling its method.

    public class {SaveData

    private public static final map < String, Object > myCachedTreeMap = new TreeMap < String, Object > ();

    public static final List < String > getLines (final String resourceParam, final Charset charset) throws IOException {}

    System.out.println ("please:" + resourceParam);

    If {(myCachedTreeMap.containsKey (resourceParam))

    Use the file cached, to avoid a further reading.

    System.out.println ("found in memory:" + resourceParam);

    }

    else {}

    Load the file from the disk

    System.out.println ("found in memory:" + resourceParam);

    }

    Returns a null value.

    }

    Public Shared Sub main (String [] args) throws IOException {}

    String target_dir = "C:\\myfiles\\config\\en";

    Line = "C:\\myfiles\\config\\en\\output.txt";

    File dir = new File (target_dir);

    File files [] = dir.listFiles ();

    If (file == null: files.length < 1) {}

    System.out.println ("file list is empty...");

    return;

    }

    Open the Printwriter

    PrintWriter OutputStream = new PrintWriter (output);

    try {}

    for (textFile file: files) {}

    If (textFile.isFile () & & textFile.getName () .endsWith (".txt")) {}

    readFromDisk (textFile);

    }

    }

    }

    {Finally

    outputStream.close ();

    }

    String fileNameFromCache = "en_synonyms.txt";

    Sheet1 = myCachedTreeMap.get (fileNameFromCache) object;

    System.out.println (fileNameFromCache + ": \n" + "Sheet1");

    }

    @SuppressWarnings ("resource")

    private static Sub readFromDisk(File textFile) throws FileNotFoundException, IOException {}

    BufferedReader InputStream;

    inputStream = null;

    String content = "";

    try {}

    inputStream = new BufferedReader (new FileReader (textFile));

    content = readFile (textFile);

    System.out.println ("bytes read =" + content.length ());

    Save the content

    FileContentsObject Sheet1 = new FileContentsObject (System.currentTimeMillis (),

    textFile.lastModified (), content,

    textFile.getName (),

    getLines (null, null));

    Add to the map

    myCachedTreeMap.put (textFile.getName (), Sheet1);

    }

    {Finally

    If (inputStream! = null) {}

    inputStream.close ();

    }

    }

    }

    private static String readFile(File f) throws FileNotFoundException, IOException, UnsupportedEncodingException {}

    Text of StringBuilder = new StringBuilder (1024);

    read int, N = 1024 * 1024;

    char [] buffer = new char [N];

    BufferedReader br = null;

    try {}

    BR = new BufferedReader)

    (new) InputStreamReader

    (new FileInputStream (f), 'UTF8'));

    While (true) {}

    read = br.read (buffer, 0, N);

    If (read > 0)

    Text.Append (new String (buffer, 0, read));

    if(Read < N) {}

    break;

    }

    }

    }

    {Finally

    If (br! = null)

    Br. Close();

    }

    Return text.toString ();

    }

    private static final class FileContentsObject {}

    private long cachedTime; currentTime

    private long lastModifiedTimestamp;

    private string content

    List < String > lines;

    private String fileName;

    public FileContentsObject (long cachedTime, long lastModifiedTimestamp,

    Content string, String fileName, List < String > lines) {}

    this.cachedTime = cachedTime;

    this.lastModifiedTimestamp = lastModifiedTimestamp;

    This.contents = content;

    this.fileName = filename;

    This.Lines = lines;

    SimpleDateFormat sdf = new SimpleDateFormat ("MM/dd/yy hh: mm :"); ")

    System.out.println ("time & Date:" + sdf.format (cachedTime));

    System.out.println ("' last modification timestamp:" ")

    + sdf.format (lastModifiedTimestamp));

    }

    /**

    *

    * @return the lines of the file

    */

    List < String > getLines() {}

    Return this.lines;

    }

    public String toString() {}

    "return"Sheet1 {}"+" fileName =' ' + filename + '------"+", content = "" "

    + content + "\"+ ", lastModifiedTimestamp ="

    + lastModifiedTimestamp + ', CurrentTime & Date ='

    {+ cachedTime + '}';

    }

    }

    }

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    public class DynamicTest {}

    Public Shared Sub main (String [] args) {}

    Game characters charset = Charset.forName("UTF-8");

    try {}

    List < String > = CacheData.getLines lines ("en_synonyms", character set);

    If (rows! = null) {}

    System.out.println ("number of rows:" + lines.size ());

    for {(String ligne: lines)}

    System.out.println ("DynamicTest:" + line);

    }

    }

    } catch (IOException e) {}

    e.printStackTrace ();

    }

    try {}

    List < String > = CacheData.getLines lines ("en_stopwords", character set);

    If (rows! = null) {}

    System.out.println ("number of rows:" + lines.size ());

    for {(String ligne: lines)}

    System.out.println ("DynamicTest:" + line);

    }

    }

    } catch (IOException e) {}

    e.printStackTrace ();

    }

    }

    }

    I have read and watched videos about the creation of an object of a class and calling its method in a different class. I'm still confused on how to do it properly. By using the code below if someone can explain how to properly call the method of objects from my hand.

    Huh? You have NOT posted any 'hand' or any 'method of objects '.

    If you need help with the code, you need to view the code.

    The Java tutorials has dozens of trails "Classes and objects": what they are, how to create and how to use them.

    https://docs.Oracle.com/javase/tutorial/Java/javaOO/classes.html

    1. create an instance of a class

    2. call to one or more of the public methods of this class

    If the class has public static methods, you don't need to create an instance first.

    I suggest that you work your way through these tutorials. They include the WORKING example code.

  • How the static methods are mocked in any mocking framework JMockit?

    I've learned that we can mock static methods using Basic with PowerMock java library? Jmockit.Want to understand how it does in short in-house?

    I think I understand:-as we define the mock class in the test case itself (although there are different ways to create the mock class in each frame as using a syntax of waiting in Jmockit), these framework must define custom classes thru Chargers that they should be looking for this class definition in the unit test is. Its an assumption. Not sure if this is correct? But even if I'm right, preference of classloader hirerchy is boootstraploader then applicationclassloader than customerclassloader. So, how's that search for customerclassloader instead of applicationclassloader? is there a way that we can set the preference of the customer above on applicationclassloader class loader?

    You can tell your not custom class loaders to delegate to its parent.

    Or you can give the custom class loaders a different classpath from its parent and place classes to be loaded by the loader custom only on the way to his class, and on the parent.

Maybe you are looking for