mardi 5 décembre 2017

Structural design patterns: (Private class data) Is there a difference between these two examples

The following is an example of this pattern from sourcemaking.com:

http://ift.tt/1IGgCU7

There are two examples, the crossed out main class and the main class that contains the data class.

My question is simply what is the difference between the following and the given correct implementation at the link:

public class MainClass {

    private final <Type> attribute1;
    private final <Type> attribute2;
    private final <Type> attribute3;

    public MainClass(<Type> attribute1, <Type> attribute2, <Type> attribute3 {
        this.attribute1 = attribute1;
        this.attribute2 = attribute2;
        this.attribute3 = attribute3;
    }
}

Cheers

Aucun commentaire:

Enregistrer un commentaire