Interactive platform development note 2005-3-15

xiaoxiao2021-03-06  14

I officially start writing the code of the interactive platform. I want the CD to be responsible for a Flex interface, and write all the background programs yourself. This is a TDD development in the XP principle.

I have earned the earlier arrangement of the CD to write BBS demand reports, and he listed a variety of features that he seeped in the demand report. Although this report can still spend a lot of time before the development of my development, I can still gradually extract the material from this report to achieve TDD. I prefer the functionality of the user's operation, organize more than 20 US US as the task of the first tie.

At the beginning of development, it is obvious that I don't very proficiency for TDD practices. But I think XP should be available from any original point (currently proven this). Therefore, I have a first US: user registration.

First of all, I realized that it apparently requires a User class, and then there is a register method. I quickly finished a test that may be incorrect and further, in order to test this class and corresponding method. Ju turned green. The next refactoring, let me consider ten minutes. I think this register method should be an empty shell. Because US is not asked to deal with user input, there is no storage of users, but did not say which exceptions should be processed and how to deal with. In a BO method, or it is based on the data related to the business rules, or it is to perform the level of the task to his level (such as a persistent service layer), or it is handling the accident. I really can't think of any operations can appear in a BO method.

However, I can't convince yourself TDD coming out an empty register. I think this register should bring something. Consider a metaphor, if the BO method actually exists, the REIGETER's function is probably verified by the data in the BO object in accordance with the Register's business requirements, and then feeds the service layer to persistence, and finally handle the accident, or when there is no accident Returns control according to requirements. Therefore, when making the REGISTER's party, we can really look at the fields (data) in this BO should be in and the face. I will continue metaphor. So the requirements of which specific fields composed of user data are found in the demand. So I put down User.Register. A Pojo-Userbean quickly established quickly.

This Userbean is a pure Pojo compliant with the JavaBeans standard. I put it in a new package, in the next minute, I started to convince myself to build a framework. That is, BO-related data is extracted in the new package of DataTransferObject as the data transport layer. The relationship between the BO layer and the transport layer is the DTO class in the BO class practical DTO in the Bo. For example, User This BO class uses UserBean.

Why can I put it in the idea of ​​the architecture, it is very simple for two reasons: 1, I think it needs, 2, I think it can be very simple. So I did this.

After this DTO, I found unexpected gains. When I returned to the User reconstruction, I naturally created a Userbean in Setup and Teardown, and set UserBean to User. The original Testregister () is not moving, the User's Register method is still empty. But everything is fine, just waiting for those USER that requires persistence of User and requesting the registration interface.

Now I continue TDD on a new architecture. I tried to understand a problem before going on. Since it is TDD, why do you have anything that does not have a test? My last answer is: Who wants to test a setter / getter POJO? Of course, there is no TDD, but it is obvious, and it is completely in the case of US-based requirements (there is not a big step), there is no need to do this. In the evening, I exchanged the things you did during the day. Q For my register () there is two questions: First, why is the User class will have a register method, why is it not register (userData).

For the first question, my answer is that the data of the Register is located in the user, so the responsibility of the register is temporarily allocated. Of course, the User's Register may not be the initiator of the user registration function in the system, or it is impossible to be a specific persistent executor, and it is definitely a commissioned chain intermediate link. In any case, according to that US I can only make such an abstraction and such responsibilities.

For the second question, I look like this. (NEW USER (UserData)). Register (); gives a feeling that the user actually exists, but there is currently no confirmation of the system confirmation, now let him register (). And (new user ()). Register (userData) gives people a feeling that the user only does not have a soul, calling register (userdata) as if I am saying, I only have the elimination, there is no soul, if I have blood, I have a meat, So let my relief to register my soul.

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

New Post(0)