1
public class AddFormConcreteBuilder extends FormBuilder
{
    private JDateChooser dateChooser;
    private InsertProducer producer;
    private DataObject dataObject;
    private JTextField AssetName;   
    private JTextField Financial;   
    private JTextField Location;
    private JComboBox Custodian;
    private JComboBox Type;
    private JComboBox RetentionPeriod;
    private JComboBox MaintenanceSched;
    private JComboBox Confidentiality;
    private JComboBox Integrity;
    private JComboBox Availability;
    private JComboBox Classification;
    private JButton btnConfirm;
    private JButton btnBack; 
    private ArrayList<DataSet> insertList = new ArrayList<DataSet>();
    private int AssetID = generateNewAssetID();


    private PanelManager PanelHolder;
    /**
     * @wbp.parser.entryPoint
     */
    @Override
    public void buildComponents()
    {
        PanelHolder = new PanelManager();
        ComboBoxManager comboModelCreator= new ComboBoxManager();
        myForm.setSize(1200,644);
        myForm.setLayout(null);

        Custodian = new JComboBox(comboModelCreator.CustodianData());
        Custodian.setBounds(135, 130, 144, 20);
        myForm.add(Custodian);

        Type = new JComboBox(comboModelCreator.TypeData());
        Type.setBounds(135, 163, 144, 20);
        myForm.add(Type);

        RetentionPeriod = new JComboBox(comboModelCreator.RetentionPeriodData());
        RetentionPeriod.setBounds(161, 230, 118, 20);
        myForm.add(RetentionPeriod);

        MaintenanceSched = new JComboBox(comboModelCreator.MaintenanceSchedData());
        MaintenanceSched.setBounds(161, 274, 118, 20);
        myForm.add(MaintenanceSched);

        Confidentiality = new JComboBox(comboModelCreator.ConfidentialityData());
        Confidentiality.setBounds(161, 354, 118, 20);
        myForm.add(Confidentiality);

        Integrity = new JComboBox(comboModelCreator.IntegrityData());
        Integrity.setBounds(161, 393, 118, 20);
        myForm.add(Integrity);

        Availability = new JComboBox(comboModelCreator.AvailabilityData());
        Availability.setBounds(161, 429, 118, 20);
        myForm.add(Availability);

        Classification = new JComboBox(comboModelCreator.ClassificationData());
        Classification.setBounds(161, 467, 118, 20);
        myForm.add(Classification);

        JLabel lblAssetName = new JLabel("Asset Name : ");
        lblAssetName.setBounds(24, 92, 101, 24);
        myForm.add(lblAssetName);

        AssetName = new JTextField();       
        AssetName.setBounds(135, 94, 144, 20);      
        myForm.add(AssetName);
        AssetName.setColumns(10);

        JLabel lblCustodian = new JLabel("Custodian :");
        lblCustodian.setBounds(24, 128, 75, 24);
        myForm.add(lblCustodian);

        JLabel lblType = new JLabel("Type :");
        lblType.setBounds(24, 166, 60, 14);
        myForm.add(lblType);

        JLabel DateAcquired = new JLabel("Date Acquired :");
        DateAcquired.setBounds(24, 191, 101, 24);
        myForm.add(DateAcquired);

        JLabel lblRetentionPeriod = new JLabel("Retention Period :");
        lblRetentionPeriod.setBounds(24, 236, 118, 14);
        myForm.add(lblRetentionPeriod);

        JLabel MaintenanceSchedlbl = new JLabel("Maintenance Schedule : ");
        MaintenanceSchedlbl.setBounds(24, 275, 153, 24);
        myForm.add(MaintenanceSchedlbl);

        JLabel lblFinancial = new JLabel("Financial : ");
        lblFinancial.setBounds(24, 310, 90, 24);
        myForm.add(lblFinancial);

        Financial = new JTextField();
        Financial.setBounds(135, 309, 144, 20);     
        myForm.add(Financial);
        Financial.setColumns(10);

        JLabel Confidential = new JLabel("Confidentiality: ");
        Confidential.setBounds(24, 355, 127, 24);
        myForm.add(Confidential);

        JLabel lblIntegrity = new JLabel("Integrity :");
        lblIntegrity.setBounds(24, 399, 75, 14);
        myForm.add(lblIntegrity);

        JLabel lblAvailability = new JLabel("Availability : ");
        lblAvailability.setBounds(22, 435, 103, 14);
        myForm.add(lblAvailability);

        JLabel lblClassification = new JLabel("Classification :");
        lblClassification.setBounds(24, 473, 118, 14);
        myForm.add(lblClassification);

        JLabel lblStorageLocation = new JLabel("Storage Location :");
        lblStorageLocation.setBounds(24, 507, 127, 14);
        myForm.add(lblStorageLocation);

        Location = new JTextField();                
        Location.setBounds(161, 501, 118, 20);

        myForm.add(Location);
        Location.setColumns(10);

        btnConfirm = new JButton("Confirm");        
        btnConfirm.setBounds(403, 524, 179, 49);
        btnConfirm.setFont(new Font("Dialog", Font.BOLD, 22));
        myForm.add(btnConfirm);

        btnBack = new JButton("Back");              
        btnBack.setBounds(629, 524, 180, 49);
        btnBack.setFont(new Font("Dialog", Font.BOLD, 22));
        myForm.add(btnBack);

        dateChooser = new JDateChooser();
        dateChooser.setBounds(143, 191, 136, 20);
        myForm.add(dateChooser);
    }

これは、ビューとして使用されるコンクリート ビルダー パターンのサンプルです。ビューではなくビルダーなので、本当に適切ですか?私はまだデザインパターンに関して初心者です。そのために残念。とにかくありがとう!

4

1 に答える 1

1

Builder は、ビューの役割で使用するのに完全に適したものだと思います。

ただし、自分自身に尋ねるのは本当に良い質問ではありません。設計パターンは、特定の問題の解決策を見つけたり、共通の語彙を使用して他のユーザーと話し合ったりするのに役立ちます。コードが一貫性​​や一貫性などの適切な OOP 原則に従っており、理解しやすく保守しやすい場合、コードが特定の名前付きデザイン パターンの定義を厳密に満たしているかどうかは問題ではありません。

于 2013-08-23T15:34:21.140 に答える