My first project harvest

xiaoxiao2021-03-06  58

Confucius said: "If you don't think about it, you don't think about it." I am deeply sighing the wisdom of the ancients from the experience of the project.

One project when I graduated in my graduation design was a graduation design management system. 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 demand has a problem that needs to be a problem, so I immediately design the web interface with my classmates, and the purpose is very simple. Because the user's needs are implemented through the interface, 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. When I now know Structs, MVC Model2, my previous confusion is solved. It feels very comfortable again.

The above is some of my newcomer's first project. It is done in a very close-up environment. Internet access is called card dialing. It has not been exposed to mainstream technology, but it is the countless confusion that is accumulated in this environment. When I encountered EJB, Hibernate, Structs, such as drinking, quickly absorb their nutrients. Otherwise, I want to learn that these technologies are undoubtedly a very time, because there is no more technology to resonate, I don't know what they want to do, and I have a resonance, they have these frames, it is Heart doubtful lock. If I returned to the beginning of Confucius, in fact, I have been in the project, I have been "thinking" according to my own thinking, so I often feel tired and there is no income, "殆". But if you don't act on your hand, the optical J2EE will inevitably confuse, that is, "罔". I feel that there is a confusion first, and it is a very effective and consolidated approach to the technology, and it is very creative, and it is a way of thinking. So I encountered the problem, first, I need to think about how to solve it according to the constant, and I will find how others solve it, so my own increase is very rapid.

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

New Post(0)