Children's shoes often face these problems when writing software systems:
1. The program can be written and run properly. Why do we need to layer the program with one click?
2. What is the concept of hierarchy?
3. How can we perform a rational hierarchy? Is the higher the hierarchy, the better?
Answer:
Answer 1:If the program can run, OK. What should I do in layers? As mentioned in a Group of reports on the software development success rate Standish Group): 1994 software project success rate is 16%, 2001 is 28%, 2003 is 31%, we have not obtained data in recent years, but from these simple data, we see a linear growth at a rate of 1.7% every year. If we continue to grow at the current rate, we will reach a success rate of 2014 in 50%. This means that the customer's demand side will never be satisfied with the software you wrote. The customer may need to modify the logic and add features, you need to change the user experience user interface and operation method according to your needs ). Your program is constantly changing until it meets his requirements. That's why I said, dear child shoes, you can't afford to hurt them.
Answer 2:Can the customer's demand changes be solved at the layer? What are the benefits of doing so? Let's explain the concept of hierarchy in software development: layered architecture is actually a layer-3 architecture that we often talk about. For object-oriented programming, no matter how many layers are divided, it's almost all about the three layers. These three layers are: Presentation Layer UI), business logic layer BLL), and data access layer DAL ). It is precisely because a program has built these layers that it can grow and result in ever-changing needs. I often use gears for students to describe the relationship between these three layers, regardless of the gear changes, such as becoming larger, smaller, or quality changing, as long as the sertices can be coupled together, other gears will not be affected. The advantage is that we only need to care about the changes of one layer, rather than the changes of other layers. Of course, there must be good interfaces between layers. Just like gears, they can be coupled to each other, but they can be independent of each other.
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1T601F14-0.jpg "/>
Answer 3:So how to layer it? What are the roles of layers? In fact, hierarchical design is the most common type of object-oriented design. Many friends should have heard of the concept of "excessive design. In fact, this kind of mistake is common in hierarchical design, that is, it has been used in unnecessary projects with complicated hierarchical design. That is to say, we need to determine how to layer based on the needs of the project. First, let's look at the role of the layer in the traditional three-tier architecture, and we will further detail the three-tier architecture. Then, the degree of design is determined based on the project size.
Common Layer 3:
1. Presentation Layer UI): In general, the interface is displayed to the user, that is, what the user sees when using a system.
2. Business logic layer BLL): operations for specific problems can also be said to call methods in the data layer and process data business logic.
3. Data access layer DAL): Mainly used for adding, deleting, modifying, and querying operation data, including data entities. You can use XML objects or object operation objects to manage file data, or you can use ADO. the object operation data in. NET can also be used. the Entity Framework of the orm Framework in. NET, but this is highly dependent on the database.
Finer layers:
1. Presentation Layer UI): serves the same purpose as common layer-3 interfaces.
2. Business logic layer BLL): serves the same purpose as common Layer 3.
3. Data access layer interface IDAL): This interface is used to create operation methods for tables, views, and transactions.
4. Data access layer implementing DAL, SqlServerDAL, and OledbDAL): Implement IDAL interfaces based on different database provider class libraries, and add, delete, modify, and query specific data to provide and execute objects.
5. Data entity Model): Data entity created for a table or view.
6. Factory): The dependency injection is implemented through simple Factory and reflection technologies, which is conducive to a variety of database applications.
More refined layers:
------------- Performance Layer ------------------------
1. Presentation Layer UI): common Layer 3 functions the same.
------------- Business layer ------------------------
2. Business logic layer BLL): This layer is called Based on the specified request event.
3. aspect-layer AOP): integrates the methods in the DAL of a Multi-table operation method that implements a certain function through transactions and is called by BLL.
------------- Data access layer -------------------
4. Data access layer DAL): adds, deletes, modifies, and queries a table or view.
5. Data entity Model): Data entity created for a table or view.
------------ Core reusable code layer --------------
6. Data Factory): dependency injection is implemented through abstract Factory and reflection technologies, which is conducive to multiple database applications.
7. Data operator Helper): includes the data operator's interface and interface implementation, mainly for some execution methods of objects in the Provider.
8. Data Provider): includes the Provider interface and the implementation of different data providers, mainly providing operation objects for Helper.
Through the above description, we probably know the simple layering and detailed layering methods. Of course, there are still many methods in the detailed layering. Here we propose a common method.
What we need to know next is what kind of project requires application layering? Or to what extent should the hierarchy be? Here, we also need to mention that in addition to the project as a factor that determines the level of hierarchy, there is also a "person" factor. If you are a beginner, we recommend that you start with the simplest layer-3 implementation, No matter what projects you can get. If you have a certain programming Foundation and can understand the advantages of object-oriented programming, you can decide based on the project, detailed layered design is used in complex projects with high requirement change possibilities. That is to say, whether it is a large project or a small or medium-sized project, we focus on the future change of this project when designing a hierarchy. For example, in WEB development, some enterprise WEB sites are often received, and there is little change after the last molding, then you can use simple layering. If you want to implement an enterprise-level application that may change from business processes to user experience, you can use a multi-layer architecture.
This article is from the "Zhangjian technical column" blog, please be sure to keep this source http://jianle.blog.51cto.com/429692/633549