There is no best architecture, but the most appropriate architecture. The evidence-based architecture is an architectural concept promoted in the book "expert one-on-one J2EE development without EJB". In our words, we will find the most suitable architecture.
I am now in Soho, and there are not many big jobs, but small jobs keep going. My work has the following features:
(1) I did not know the time required. The requirements are all explored from prototype to demo to version 1 to version 2. Frequent changes in requirements must be based on agile methods;
(2) generally, there is not much data to be stored, with a maximum of millions;
(3) requires extreme development efficiency. If a job is completed in 10 days and 20 days, the former is twice the latter.
In the above (1)-(3) drive, I found out the architecture:
From the bottom up, let's briefly talk about:
(1) Database: db4o. Who knows who to use, haha, cool. What's Orm, SQL, and dataset. Everything is a common object. The database is almost zero. Data access is also very simple.
(2) There is a logic layer on db4o to cope with demand changes. This layer is mainly a variety of object objects and requires good design. Otherwise, the changes in requirements cannot be handled. I generally need to design a relatively complete Event System for later modification and combination.
(3) Service Layer: mainly required by RIA applications. For winformProgram.
(4) UI logic layer: I didn't get this layer at the beginning. In the end, this layer is added because it takes too much time on the interface. This layer mainly includes:
A) for a single control, the common operation logic of the control is encapsulated into an extension method;
Example: The invoke method in the winform program is very annoying to use, involving multiple threads, but also to Judge multiple ishandlecreated = true (often forgotten, leading to a bug ). Therefore, it needs to be encapsulated into an extension method.
CodeAs follows:
Code
Public Class Controlfunccontext
{
Public Control {Get;Private Set;}
Public Delegate delegate {Get;Private Set;}
Public Controlfunccontext (control CTL, delegate D)
{
This. Control=CTL;
This. Delegate=D;
}
Public Void Invoke0 ()
{
If (Control. ishandlecreated = True )
{
Delegate. dynamicinvoke ();
}
}
Public Void Invoke1 < T > (T obj)
{
If (Control. ishandlecreated = True )
{
Delegate. dynamicinvoke (OBJ );
}
}
Public Void Invoke2 < T0, T1 > (T0 obj0, T1 obj1)
{
If (Control. ishandlecreated = True )
{
Delegate. dynamicinvoke (obj0, obj1 );
}
}
}
Public Static Class Formclasshelper
{
Public Static Void Invokefunc0 ( This Control CTL, func0 func0)
{
If (CTL. ishandlecreated = True )
{
Controlfunccontext FC= NewControlfunccontext (CTL, func0 );
CTL. Invoke (NewFunc0 (FC. invoke0 ));
}
}
Public Static Void Invokefunc1 < T > ( This Control CTL, func1 < T > Func1, t OBJ)
{
If (CTL. ishandlecreated = True )
{
Controlfunccontext FC = New Controlfunccontext (CTL, func1 );
CTL. Invoke ( New Func1 < T > (FC. invoke1 < T > ), OBJ );
}
}
Public Static Void Invokefunc2 < T0, T1 > ( This Control CTL, func2 < T0, T1 > Func2, t0 obj0, T1 obj1)
{
If (CTL. ishandlecreated = True )
{
Controlfunccontext FC = New Controlfunccontext (CTL, func2 );
CTL. Invoke ( New Func2 < T0, T1 > (FC. invoke2 < T0, T1 > ), Obj0, obj1 );
}
}
}
B) for multiple controls, use the mediator mode to abstract the combinations of multiple controls into the mediator class for reuse. At first, I encapsulated the user controls. The results showed that they were too inflexible. Finally, I switched to mediator and used the extension method to develop biubiu quickly.
(5) UI: HTML is the source of all evil. If you can choose one, I mainly use winform, flex, and SL as the front-end. Pure web development does not touch (there are too many web development tasks on the market, so you can skip this process ).
The above architecture depends on the project. If the data part of the project is critical, I am still using relational databases conservatively. Although db4o has been in use for so many years, it must be conservative.
If the above five points can be fully implemented, the development will be as cool as flying in the air.
BTW. If everything is too good, writing a program is really enjoyable, just like writing a poem ......