When I first designed the software using OO technology, I made all the mistakes a designer could make. It is a foreign outsourcing project, the foreign responsible for functional design, our company is responsible for programming, coding and testing.
The first important mistake was that I didn't seriously read the design instructions. Functional point design does have some problems, according to their design, an important process is not achievable. So I changed the design without having to communicate with the investors, and changed a module that was originally developed on Linux to the Windows system. The results are actually implemented, but unfortunately they do not meet their needs at all, much worse than the original design. After asking about the design intent of the process, I know that. The other side of the engineer admitted the mistake, but the question is: "Why did not say Ah, we have told the leadership of the product structure, but also to ensure the delivery time, now how to say ah?" ”。 They designed an apple, and I made an orange. Finally, the results of the negotiations with the engineers are: first change the orange to the design book Apple, on time delivery, and then quietly changed to the banana they really need. At this time of delivery is less than three days, so I work overtime every day to the morning, the code line by row, with GCC compile debugging. The good news is that most of them are physically active, and there is no technical content, even in the middle of the night when the brain is half dormant.
Another mistake that appears in the project is that my estimate of the workload is very inaccurate. In the first phase, according to a process in the functional design specification, I made an example of using all the technology that the investor has stipulated. When I open the browser, I see the "Tom,jerry" in the database on the page, Wang Xiao Shuai, happy to go to the corridor to breathe a mouthful of fresh air, and then optimistic that: the design book has been written, the example has been made, the rest of the things must be like chopping melon cut vegetables. Not just get everyone together and talk about the design books, look at the examples, then jump up and start, and then do it. The amount of coding I allocate for each screen is three working days. The result is that their design is not perfect, my understanding is not correct, and everyone's thinking is not consistent. So I call the meeting every day, the changing, constantly rework. In the end, it actually takes more than 10 working days to finish a picture. The code takes up too much time, testing in haste, quality ... Can cover up the problem will have to cover up, the performance is too busy to take into account.
There is another aspect of the problem is the technical, this is my article to say the focus. According to the investor's plan, the main part of the system needs to use the Java EE Framework, the selected middleware is free JBoss. Plus Tomcat as a Web server, struts serves as the framework for the presentation layer. They have a clear purpose for the use of these things, but I do not know these techniques. The first time the novice OO design, coupled with too much new technology, so there are a lot of problems. The company had arranged for a cow to guide me, familiar with OO design, and familiar with these open source frameworks, the Tomcat and struts source code. But he is too busy to guide me for very limited time.
After the investor sent the design book, two engineers were soon sent to explain the instruction. This is a functional design specification, including a database design specification, and a function point design specification. The function point description describes each workflow, picture design and data flow. The two engineers briefed us on the concept of the product and then spent one weeks detailing their design, including the meaning of each field in the datasheet, and the business significance of each control on the screen. In addition to these functional requirements, they have some technical requirements.
To reduce the cost of owning customers, they do not want to bind their products to specific databases and operating systems, and they want to use a free platform. So they chose Java as the development language and used a series of free platforms. The selected middleware is JBoss, using the entity Bean as a way to access the database. We are not comfortable with the efficiency of the entity bean because it is assumed that he has used a lot of reflective technology. After a period of technical investigation, I decided not to take the entity Bean, but instead I wrote a lot of value object, each value object corresponds to a database table, the value object has only a few setter and getter methods, Save only data and do nothing. The property of Value object corresponds to the field one by one inside the database. corresponding to each value object, make a data table gateway, responsible for the data from the database to be found inside the value object, but also responsible for the value object inside the data back to the database.
According to this design, you need to write a gateway and a value Object for each datasheet, which is quite large. So we made a tool to generate code automatically, go to the database to traverse each data table, and then iterate through each of the fields in the table, the code generated automatically.
This is equivalent to implementing an ORM mechanism. When we were doing these things, Orm was a strange noun, and hibernate such an ORM framework had not been heard. Then we still need to solve the problem that the system runs on a variety of databases. The gateway uses JDBC to connect to the database, querying and modifying the data with SQL. So the problem is: to solve the small differences in SQL between different databases. I did this: I made a sqlparser interface, the function of which is to convert the ANSI SQL format query statements into various database query statements. Of course I do not have to do a very comprehensive, as long as I support the project used in the Query method and data type is enough. A few more specific parser are then developed to convert different database SQL formats.
By this time, the data inside the database was successfully transformed into the object within the program. Very good! As a matter of principle, the rest of the Oo road should be logical. But, unfortunately, I don't know how to use these value Object, and then I'm in a confused mood to graft the procedural code on this OO basis.
I designed a session bean for each screen that encapsulates all the business processes associated with the scene, allowing the session bean to invoke a bunch of value object to start work. Between the session Bean and the page, I did not let them call directly, because according to the company's cow said: "The page directly calls the business code is not good, coupled too strong." "This is true, but I have a" business code "Understanding is really problematic, so abruptly created a helper to block the page and session Bean in the middle, as a mouthpiece role.
So in the development of the following scenario: whenever the design changes, I will modify the design of the database, with the code generation tool to regenerate the value Object, and then modify the business process within the session bean, according to the new parameters and return values to modify the helper code, Finally modify the page's calling code, modify the page style.
The actual situation is much more complicated than what I say now. For example, the modification of the value object, the size of the program more and more after, I in order to avoid the memory of the large footprint and the decline in efficiency, have to have some database query logic written to the gateway and value object inside, so in the time of change, I also have to manually modify the gateway and value Object generated by the Code generation tool. This maintenance is very troublesome, which makes me wonder what the benefits of OO are. I have solved many problems with OO in this project, and these problems are caused by OO itself.