OO (Java) programming the first phase of work summary

Foreword

      The first record by writing blog to learning, this blog mainly for a summary of three major operations since learning Java, as well as record some of their own feelings and experiences to learn Java for OO (Java) design.

Operations summarize the process

      1: Summary of three jobsThe relationship between knowledge iteration

            The first job of the most simple cycle selection with the C language statement basically the same Java program for learning C language is nothing more difficult for me. The main job is to make me realize that the structural framework of Java programs, and at the same time learn how to enter the name of the Java class statements above must be in the PTA Main, for the second big operation basis.

Import java.util.Scanner;
 public  class the Main 
{ 
    public  static  void main (String [] args) 
    { 

        Scanner SC = new new Scanner (the System.in); // sentence input by the
         Double A = sc.nextDouble (); 
        SC. Close (); 
    } 

}

            The introduction of a second operation method in Java, C language function is similar, each method implements part of the functions defined by the new operator can call an object method. The first job the relative increase in the use of the class, made me realize even further relative to the different process-oriented C language, Java programs to focus more on object-oriented design.

public static void main(String[] args);//主方法;
public static boolean isLeapYear(int year) ;
public static int numOfDays(int year,int month ,int day) ;
public static String getWhatDay(int days) ; 

            The third job is highlighted using the Java programming classes, Java programs can have a plurality of classes, and can call each other by the new operator between classes. But note that a Java program can have only one public class, or an error. Finished third job for Java also have a preliminary understanding of the object in a Java program is particularly important, and class methods are invoked through the object is achieved, although not particularly understand the building and call the class of Java programs, but know Java is a fully object-oriented programming language, it is necessary to be familiar with object-oriented will be able to write Java programs.

public class Main{
}
class DateUtil{
public DateUtil(int year, int month, int day) {}
    public int getDaysofDates(DateUtil toDate) {}
    public DateUtil getPreviousNDays(int n) {}
    public DateUtil getNextNDays(int m2) {}
    public  String  showDate() {}
    public int getDay() {}
    public int getMonth() {}
    public int getYear() {}
    public boolean checkInputValidity() {}
}

      2: How a gradual transition from object-oriented to process-oriented work by

            Three difficulty of the job is again increasing, the first topic is carried out primarily through the problem-solving process-oriented, content is simple and does not involve too much of Java's unique characteristics. The second job is related to a method in Java, C language functions similar to, greater emphasis encapsulation procedures, has gradually move closer to the object-oriented. The third is related to the Java class properties unique, object-oriented properties have been gradually clear. It is through the work of three difficulty rising, but also makes the transition from the program to process-oriented object-oriented

      3: homework problems encountered and solutions

            Question 1: how to write code in PTA above and how to enter. Workaround: Submit by Baidu learned on the PTA code needs to class class name to Main, secondly on the need to PTA Import java.util.Scanner and Scanner sc = new new Scanner (System.in) to input test data.

            Question 2: I do not know how to call and other types of input data for other classes. Solution: The object is to define a new class of operator, by calling the object class. Followed by the establishment of this

private variables.
class DateUtil{

    private int year;
    private int month;
    private int day;

    public DateUtil(int year, int month, int day) {
        this.year=year;
        this.month=month;
        this.day=day;
    }
}

      4: The proportion of time spent on each job

            Time ratio is about: First job: second job: job third = 1: 3: 9

      5: Lessons for understanding and rigor of the programming process

            The rigor of the programming process can not only speed up the completion speed of the program, but the most important thing is to make your program have organized structure. This is very important, especially when the results of homework on the PTA, often not submit the correct answer, but partially correct, which means that the program has Bug need you to put him out. If your program is not coherent, it is necessary to find the Bug from the beginning to find the tail is very tedious, but if you write code that, when a number of rigorous find Bug, they also can roughly determine where errors can save a lot of time.

            Lessons: Bug on the PTA to find time to write the code is not precise enough because the code is too messy, resulting Bug find time to write code even more than time.

OO Design experience

      1: Comparison of process-oriented and object-oriented

            Process-oriented process-oriented, need to think through the problem-solving process-oriented problem solving steps, one by one through a step towards a function, that is, to solve the problem by calling one function.

            Object focus on object-oriented, object-oriented need to solve the problem by separating out one object, and then give the properties and methods of these objects they should have, to solve the problem is to allow these objects to execute their methods.

      2: basic principles of object-oriented design appreciated

            The most important one principle: single responsibility principle that each object should only have one single function. The purpose of this principle is to change a requirement at the time, there is a change to modify functional objects corresponding demand can, without changing much code.

      3: understanding of OO programming thinking

            Object-oriented programming is developed from process-oriented, object-oriented thinking in solving some of the problems can be cumbersome things simple, individual objects carry out their duties, faster and better able to propose solutions.

Understanding and practice tests

      1: The importance of testing for encoding quality

            Testing is like inside the factory inspector, it checks the program eligibility. Not tested code must be a Bug, and no one can create a flawless one-time procedure. Only through continuous testing, code can continue to become more perfect.

      2: If you make test cases, how would you do

            First Test Example something wrong with (boundary value), followed by testing some special cases (e.g. leap year February 29 or the input data is 0), the last normal input test data for testing.

Course harvest

            Beginner Java, first learned about object-oriented design. At first it was still staying process-oriented design code in C language, although it is possible to write a program, but it should begin to change their thinking to write programs. Learn four weeks also learned a lot about Java, and very happy and learn a new programming language.

Recommended course

            Learning program should be more training, otherwise progress very slowly. The teacher recommended a lot of work on adding some class assignments and PTA. Second, teachers can often recommend some good resources to learn, after all these courses on Java classes may not be able to learn a lot more that student extracurricular self-conscious to go.

            

 

            

            

Guess you like

Origin www.cnblogs.com/lx2001/p/12632475.html