D
D
Dima Zherebko2016-02-05 18:22:30
Java
Dima Zherebko, 2016-02-05 18:22:30

Is this piece of code considered normal?

public class Test {
    StudentBase studBase;

    Test() {
        studBase = new StudentBase();
    }

    public static void main(String[] args) {
        new Test().start();
    }

    private void start() {
        studBase.initStudBase();
        studBase.showAllStudentsInfo();
        studBase.showAllStudAtletter();
    }
}

let's say you need to write your own tester, not unit tests.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
razer89, 2016-02-05
@razer89

Access modifiers are not superfluous, except if you want to make fields\methods package-private

public class Test {
        private StudentBase studBase;

        private Test() {
            studBase = new StudentBase();
        }

        public static void main(String[] args) {
            new Test().start();
        }

        private void start() {
            studBase.initStudBase();
            studBase.showAllStudentsInfo();
            studBase.showAllStudAtletter();
        }
    }

A
angry_cellophane, 2016-02-06
@angry_cellophane

JUnit to help you

V
VZVZ, 2016-02-06
@VZVZ

It's better to have main in a separate file, and therefore in a separate class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question