1、面向对象中外文翻译学院(部): 计算机科学与工程学院 专业班级: 计算机09-2班 学生姓名: 指导教师: 2013年 5 月 29 日Object-oriented analysis and design The basic concept of object-oriented technology and the basic method1.1 software development method Computer after birth, computer technology has been developing in high speed condition, the devel
2、opment of computer science and technology by original only depends on the development of hardware to relying more on software development. In fact, the development of software technology has experienced more than generation process. First generation (50 to 60 s of the 20th century), in programming l
3、anguages such as FORTRAN and ALGOL technology marked by algorithm Generation to generation. At that time, the program design on people all creative talents, all rely on tips and tricks. Software productivity is very low, based on the algorithm procedure is very difficult to understand, programmers w
4、rite their own program over a period of time even after oneself also look not to understand, this to the software modifications, maintenance bring great difficulties. So at the end of the 60 s in the software crisis. Second generation (in the late 1970 s to 80 s prevailing), such as PASCAL, and COBO
5、L programming language and relational database management system for a structured system analysis and design techniques. In order to overcome the software crisis, people made efforts to mainly from the following two directions: Methods from the Angle of the management to improve the software develop
6、ment, software engineering method is proposed, and greatly improve the quality and maintainability of the software. Second is to focus on the analysis in the software development process and design method of research and improvement. Important achievements in this field is developed in the 70 s the
7、rage of structured development method of structured system analysis and design techniques. Third generation (in the 80 s is still prevalent) represented by Smalltalk, c + + object-oriented software development methods. Question 1: what is on the development dynamics of object-oriented software devel
8、opment methods? Traditional structured programming algorithm as the core, the original is closely related to the data and separate to the operation of the data, it is difficult to maintain the consistency of data and operation, its software development method also does not conform to the natural thi
9、nking habits, the designed software system solution space and the problem space, the expanded, difficult to understand, modify, and lead to problems in terms of program complexity and software crisis. In order to transcend program complexity barrier, overcome the software crisis, object-oriented sof
10、tware development methods are put forward. Question 2: what are the advantages of the object-oriented software development method? Object-oriented development method to change the past traditional on the basis of function analysis and function decomposition of process oriented structural analysis an
11、d design method of object-oriented development method to simulate the way people understand and deal with the objective world to analyze the problem, the system as a series of collections of objects, its object-oriented design and analysis of results is mapped to a structure of object-oriented imple
12、mentation tool, has a more direct correspondence to mapping process, the analysts, designers, and programmers can use the same concept, so that the object oriented software development can simulate more naturally to the activities of the objective world, making the problem space and solution space o
13、n the structure as soon as possible. Therefore, adopting the object-oriented method can more effectively developing large software systems. Object-oriented method of encapsulation, inheritance and polymorphism mechanism not only to support software reuse, and the software maintenance, reliable and e
14、fficient software system which can realize flexible manufacturing, better to overcome the software crisis. Therefore, it has become a mature method widely used in software development. By the end of the 20th century, object oriented software engineering development gradually mature, especially the f
15、ormation of the unified modeling language (UML) standard and widely used, the object-oriented software development methods have become the mainstream of the software development technology. 1.2 the basic concept of object-oriented Object: (1) abstract representations of the objects is an objective e
16、ntity attributes of the object is described by the data and the data for the operation of the behavior of two parts. (2) class: class is a collection of objects with the same properties and behavior of abstract description; Internal including attributes and behavior of two main parts. (3) example: c
17、lasses is to have the same properties and behavior of a set of abstract descriptions of objects. Therefore, classes can be used as a user-defined type and create the object model, and according to the model created by the actual example of a specific object is a class, often referred to as examples.
18、 (4) the message: the message is to request an object it contains a processing operation on the instruction information. Essence is to the operation of the object of a class function call, the call to a method. For example, student S1; S1. The display () is a message. A news generally consists of th
19、ree parts: receiving a message object name, the parameters of the function name, function, operation. (5) the three basic characteristics of object-oriented technology: encapsulation, inheritance, and polymorphism (6) encapsulation: the so-called encapsulation is the objects properties and behavior
20、combined into a single unit, to the outside world cannot directly access or modify the data and code, the outside world only through object provides the interface function to change the attributes of the object or obtaining data, it is realized the message is hidden. (7) inheritance: if in a defined
21、 on the class, add some special attribute or operation, can form a new class, this class is not only inherited the former all characteristics of a class, and with new features, so as a special case of the class before, is in front of a class to inherit. A class known as the parent class, before the
22、new class is called a subclass. Through inheritance relationship can form a type hierarchy, called inheritance structure. Polymorphism (8) : in different classes, the same function name to realize functions of different functions available. Polymorphisms of the advantages: high-level code (algorithm
23、) write it only once and the lower can be reused for many times, can improve the programming flexibility and efficiency. Object-oriented programming 1.three major mechanisms of object oriented technology (characteristics) : (1) encapsulation mechanism and the design of the class: the so-called encap
24、sulated object attribute data and operation method is allowed to be combined into a single unit, to the outside world cannot directly access or modify the data and code, the outside world only through object provides the interface function to change the attributes of the object or obtaining data, it
25、 implements the message hidden; In c + +, class is to support the data encapsulation tool, allowing design class descriptions to abstract a set with the same properties and behavior of the object, namely can encapsulate a set of objects in the class of common properties and methods. Thus, class is t
26、he tool to realize data encapsulation, object is the realization of data encapsulation. No package, no object-oriented technology. Class members to access the principle is: (1) define a class, the data members and member functions is the default access private members. (2) a member function can be d
27、irect access to the members of the same variables and calls to members of the same function, need not add object name before the function name. (3) members of the private or protected member is limited to the scope of the class that the body and the class member functions; Nonmember functions should
28、 be defined as a class of friends to access the private members of a class member function. (4) members of the public scope not only includes the class body, also includes the use of the object which it belongs. Can access to public members outside class, but must be before the member name plus the
29、object name. (2) the inheritance mechanism and derived class definition: the so-called inheritance is allowed on an existing class, add some special attributes or operations, to derive a new class. Not only can the derived class inherits a base class member, and can define new member, so can be as s
30、pecial class of a class before. A class known as the parent class, before the new class is called a subclass. Through inheritance relationship can form a type hierarchy, called inheritance structure. Inheritance is one of the Shared properties between classes and service mechanism. class person /The
31、 base class protected: char name11; char sex; int age; public: person() cout“person”endl; person() cout“delete person”endl; int Getage() return 20; class Student:public person private: char id9; float score; public: student() cout“student”endl; student() cout“delete student”Getage();void main() pers
32、on *p; student s; p=&s; F(p); / p- Getage(); The results :personstudent20delete studentdelete person2.The definition of mechanism of polymorphism and virtual functions: Polymorphism refers to the class hierarchy in the same class or different classes, can use the same function name different operating functionality, which you can use the same call way to invoke these functions with the same name with different function