[Forum topic] OO problem! ! ! ! ! ! !

xiaoxiao2021-03-06  82

[Question:]

I looked at some OO books, some still didn't understand. I want you to say one or two. For example: a student's test score. If you use OO to analyze should have two objects, students and grades. Teachers can modify their achievements. The behavior of this modification should be who is a student, a teacher, or a score itself. Teacher. Modify (), student. Modify (), grade. Modify ()

[Reply] (part, so far)

Reply to: v0v () () Reputation: 100

The establishment of the object is not unique. If the specific situation and application should be determined, if the students' properties and behaviors are rare (can be understood), there is no future expansion Possibility, then the score is a attribute of the students and is also a kind of efficient program, but a student in the real system may have a lot of disciplines, and the students' feet are also very rich. In addition to the exam, there may be many other behaviors and attributes, then, in order to avoid the confusion of the model, this object should be created to manage their own behavior, and students can aggregate a grade.

Reply to: w_rose (w_rose) () Reputation: 94

The score was modified, but I don't know which teacher is modified, this is not allowed. Teachers have revised its achievements, but they can't find which achievements have been revised. This is also honest.

In fact, the modification is the operation of crossing two objects. It doesn't matter in which class is implemented, just write a parameter, but the nature is the same - the THIS object is also a default parameter.

Reply to: w_rose (w_rose) () Reputation: 94

OO is required to package an operational division module according to the type. The OOP programming style is not perfect. If we write a bunch of operations, then the system automatically copies a copy in various types of objects when it involves multiple objects for parameters and keeping them seem more intelligent.

Reply to: JeffYan77 (JeffYan77) () Reputation: 105

There are two principles here to consider it.

First, d.i.m. (Do IT Myself) is also what you said to manage yourself. The procedures for data and modification data must be packaged together to form an object.

Second, the design of granularity. Is the result of an independent object or as a property of the student, depending on how important it is in your system.

If your system is about performance management, then grades should be an important independent object. At this time, it should provide a modification method modify (), and all modifications must be made through this method, which reflects DIM.

But if your system is not so important, then grades are a attribute of the student, represented by a general data type (such as Double), then in order to reflect DIM, student objects must provide a way to modify your own grades. In fact, when using the double type, modify its value must also be called by calling the Double type. - The operation is actually a Double method. Therefore, the DOM's DIM is now manifested by the OO language itself.

Teachers modify their achievements, which is part of business logic. In order to reflect this business logic, the modify () method of the performance object should have the parameter of the teacher object, indicating who is approved this modification. Teacher object itself can also have a modifyscore () method, by calling this method, teachers can modify a score. However, this method is just a call of call, and the real modification must be made by a grade object (if there is no special grade object, it is the student object) itself. In any case, the teacher should not be the object that finally modifies the performance. Otherwise, you will regard the grade as the meat on the board, passively, or designed a program object, modify another object, ie data object. In essence, the procedures and data are separated, equal to canceling the object. Reply to: JeffYan77 (JeffYan77) () Reputation: 105

In some special situations, the operation and data segmentation is designed, such as Visitor mode, take advantage of this.

This is like playing, the master takes into account a certain level, but it seems like a lot of hands. The low hand is not what level, and it is a popular hand. Now you don't have to consider Visitor mode.

Reply to: w_rose (w_rose) () Reputation: 94

Typically, we first design interfaces in classes that involve the underlying operation, that is, results. Modify (teacher), then add corresponding interfaces to each other (that is, teacher) at any time (that is, teacher): Teacher. Amendment (performance) In order to make people use it easily. For example: Microsoft's programming framework system is usually relatively friendly and natural.

Reply to: ADSL314 (DD) () Reputation: 100

Thank you first, thank you for your enthusiasm. --------------- I have read many people's reply, I also understand a lot. Here, I said: First, just as Yujia120 (in Jia) said: Can't make it easy to understand: the ability to modify yourself, who is the object of operational data, it will not be confused, will not have active and passive Misunderstanding Because some behavior can't be active or passive, the object should be seen as the operator of the data is JeffYan77 (JeffYan77), W_ROSE (W_ROSE) said DIM as (teacher) issues request information. This is what I can do in business logic. That is, what kind of behavior is this object (teacher). -------- If you are not right, please refer to it. . .

Reply to: w_rose (w_rose) () Reputation: 94

"Responsibilities" has many meanings. In the "computer domain", then Record is responsible for dealing with the permanent storage system. In the "business domain", then this operation is actually unique to Record, and there must be TargetRecord, which means that three parameters are supported together to support this operation.

Reply to: w_rose (w_rose) () Reputation: 94

You can take a look at the definitions in the Record class above, and then combine business definitions, programmers are likely to debate: Record is lost before saving! Therefore, in the face of other programmers as this two types of users, this should only start from "compliance, natural". At this time, the debate can distinguish between "business design", "storage design" two levels.

Reply to: ozzzzzz (Hope Agile) () Reputation: 161

In fact, the above discussion is almost completely worthless, because these discussions have basically not considered the situation in the actual project, which is simple ideas, theory, theory. Let's take a look at how the situation in the actual project is. First we must understand that the analysis model and design model are not the same, and we discuss the problem of design models now. In fact, the results are definitely not a simple score, but a comprehensive evaluation of a student, including scores, subjective judgment, and construction of practice. The modifications of grades are almost destined to occur in a stage, and the identification of a grade can also be considered a special revision. At the same time, the modification and identification of results is also a lot of business logic, such as the calculation of the results of the test (everyone can understand the complexity of the certification process of GRE and other foreign exams), the translation of the test results and the final results (the senior high school entrance examination will be in the semester The conversion method in the grade, the semester score in the conversion method in the completion results). The modified logic is also very complicated. For example, the revision of this record and the achievements of the school year will be different; the business process of the revised achievement may also have different practices in different subjects; the records you have done when the results are modified. Different environments have different environments. These logic may change frequently, and even if it does not change its own complexity, it is impossible to just a simple method can be solved. The so-called teacher. Modify () or grades. Modify () almost all impossible thoughts.

Reply to: ozzzzzz (Hope Agile) () Reputation: 161

Darren_zhu_nz (Rural also uses .NET -_-) to simulate a practical situation, it is necessary, "Do you think that you simulate it before me? Any method you discussed in the actual situation is very ridiculous. Not available, there is no reference value when the actual implementation is, this so-called idea is to synergy, it is very nice, you can't smile. This makes me a worry. We usually give a question Always Examples of typical can't be typical, simple, unable to say, explain what we want to explain. This is a misunderstanding for people who study these methods. It is said that the world seems to be like this, which is simple, and ignores the actual world. The complexity. I don't think there is no practical experience for this scene, but only everyone has ignored the complexity of the world. For example, you use teachers. Modify () and actually ignore 1. Not every teacher has a modification The right, 2 is not every teacher has the right to modify each grade, 3, not every modification is made by teachers, there will be a scene of scoring standards (for example, 140 points, now 100 points; It is not equal to weight, now weighted; it does not consider the construction time, now you have to consider the construction time) You use grades. Amended () also has a lot of defects, you can imagine what defects can be imagined.

In fact, it is always necessary to make an actual idea of ​​simplification when there is a study, and it is contemplated when practicing. The discussion here is a typical simplified situation.

Reply to: w_rose (w_rose) () Reputation: 94

Nothing is not "simplified".

In fact, you can put a monkey for a long time before the keyboard, it will write all the posts on this forum, and don't need our people to reply hard!

That is to say, if anything can be, rudely, instead, you can call the "perfect, advanced" scorpion. The hardest thing to do is something truth from facts, just right, not doing things that are not your duties (refer to object design). The so-called "modified authority", if you ask for the first time, you will be designed, then you will do it according to the requirements. If you ask it to be an extension of the basic function, you will do it in the inherited child object, which is also part of the "Do IT Self" mentioned above.

Reply to: ozzzzzz (Hope Agile) () Reputation: 161

I explain a few words. In fact, both can be, as long as you are just in a simple environment of an illusion, there is no problem with the wrong problem, the good difference is also very small, this is the old man has already understood. The key is to put these things in a specific environment, you will think that both are very awkward and difficult to grasp. If you are just to complete a job, you can use it casually. However, software projects are not serving academic research, but we have served our specific work. Doing your homework, you should ask your teacher, and his answer is more auctions. And here should not do not necessarily to do alternatives for these teachers. For example, if you say that students can't change his own score, but in fact, many scores can be made from this point from the modification of the students. For example, he thinks his own question is not his complete, this time he demands the revision of the revision of the amendments from the teacher is different, this kind of student requirements are almost you in all the environment. Need to consider. For another product, the modification of many achievements is not from the students, such as the school to encourage social practice to increase the number of fractals. Such things are often in the school, I don't believe which students don't know. Just do you have a problem in accordance with the actual situation, not just a matter of consideration of the topic.

[Original post]:

Http://community.9cbs.net/expert/topic/3285/3285957.xml

转载请注明原文地址:https://www.9cbs.com/read-121840.html

New Post(0)