Java will come all the way

xiaoxiao2021-03-06  45

The summary of the first engineering of the novice (the first time writing articles, please advise) napoleonn http://www.jdon.com Oct 1, 2004 3:42 PM Reply Confucius said: "Learn, do not think, I don't think about it. "I am deeply sighing from the experience of the project, I am deeply sighing the ancients. I have a project when I graduated as a graduation design management system last year. At that time, the teacher gave us a request to achieve JSP and JavaBean. I am mainly responsible for project modeling and javabean section, and later responsible for database students cannot return to school by SARS, so the database section is also completed by me. At that time, the knowledge of Java was very poor, only a simple grammatical foundation, even JSP, JavaBean was heard for the first time. I don't know where to start, so I've been a very simple demo project given by the teacher. First, JavaBean is a relatively simple thing, so I start analyzing user needs. How do you describe it? Due to the limitations of school education, plus themselves for a long time, politics, English (what to do with everyone), causing the serious lack of knowledge. I will establish a list of their needs with the graduation designers. But such a demand description is very side, almost all static needs, and it is difficult to design a few user interaction processes, and changes in certain states. And whether this requirement really meets the need to be a problem, so I immediately design the web interface with my classmates, and the purpose is simple, because the user's needs are implemented through the interface, and the design of the interface can cover the function of the ultimate submission user, and You can also explore a lot of non-user needs. This will be available when I have these functions. After a year, I took careful experience analysis. After UML, I feel like I won the treasure. The knot is all open. How to build it? I really didn't have a concept, although I know UML, but I only know fur. So I am very simple from the perspective of the object, first find the personnel involved in the graduation design management system, this is obviously found, involving students, teachers, administrators, further extracting project objects, each person Message object, graduation design document object, etc. Next, the database table is designed. Because the school teaches the database, only the transformation of the ER map to the relational mode is not explained, and the ODL to the relational mode is not transformed (now, ODL should be better, understanding O / R mapping More help.) So you draw the ER map, build a variety of tables, set the primary key, foreign key, and so on. The primary issue I have encountered is how students, teachers, and administrators should do. Every object built a table, it seems that there is no problem. But there is a problem when establishing a message object, because the news is to be transferred at the students, teachers, and administrators. When I built a message, it is designed: one message content, message transmission People, the recipient of the message (the message content and sender a table, in order to solve the redundant receiver alone, this news is very flexible, the message sender can be the casual one between three characters In addition, such a message can be a message generated by a system, and the recipient can be casually. However, the problem that brings to the message is: Who should the recipient should refer to? Obviously fill a sender, the receiver's ID is not enough, and must even fill in the role of the sender. The second method, each role has a list of received messages, allowing it to refer to a single message table ID, which can also solve the problem.

The third method, combining students, teachers, administrators into a user table, then sending people, the recipient will refer to a universal user ID as long as it is a simple reference. This method of consolidated subclasses causes teachers and administrators to have some NULL values, but considering that teachers and administrators are far less than the number of students, such redundancy is ignored. Finally, I still chose the last way. But I still think that the object model is a compromise to the relationship model. Then I started designing Javabean, accessing the database is a simple JDBC. Because I don't know which attributes I have to access an object on the front interface, I don't know. So I can only take out a complete object from the database, let him decide which attributes are to access. And the modification of the object is also the case, the front desk modifies the properties of the new object, I will make more database synchronization. So my Javabean has a method of log: LOAD (), store (), update (), delete (), synchronized method, and database table synchronization. This seems to be a year later, in fact, I have already made an O / R mapping work. At that time, I did this, which is a quite painful thing, and the method is also the most coarse, that is, the entire object is more database synchronization, even if there is no modified attribute synchronization, so if you want to sync, you must first take the object first The database is taken out, and then write it back. Moreover, all attributes must be NULLABLE's Non-Primitive Type. The second question, how does the foreign key in the table react to bean? For example, each student has a counseling teacher, it is obvious that the student watch needs a foreign key to refer to the teacher ID, but is a Teacher object, or the teacher ID value, it should be a TEACHER Object, but I think this is how hevy is! Think about the teacher's situation, a teacher has a collection of Student objects to "heavy"! Means Load a teacher to take all students. So the method I adopted is: or objects, such as Teacher's student properties, or a Collection Student object, and provide a loadstudents () method, the Load Teacher object is not load student properties, only beans users explicitly When you call LoadStudents (), a set of Student objects will be loaded. This seems that I don't consciously realize lazy loading? The javabean prepared at the time is now examined, the biggest and largest mistakes are to mix Data Access Object and Business Workflow together. For example, all the functions to be called by the teacher in the teacher object, and some functions are sometimes involved in several beans. It's a horrible design, although I was confused at the time, but I didn't have a brainstorm to solve it. I now look at the session bean's idea, I feel so comfortable, nature. At that time, there was a process about JSP. JSP is only responsible for display, but why is a JSP submitted data to handle another JSP? This is very uncomfortable, so I have the initial servlet to do the idea of ​​the controller, but I can't study so much, and I have not finally realized. After all, the front desk is not I am responsible.

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

New Post(0)