I 've been using mobile apps for almost a year. I 'd like to take some time to understand the application architecture. This document uses the mobile phone application of j2-based as an example. This section describes the program architecture features involved in enterprise application development.
From its birth to the present, the technology is still growing. Despite the differences in JSR standard support from various mobile phones and Virtual Machine implementations of various manufacturers, it is more or less a hindrance to the embodiment of the biggest advantage-cross-platform, but it is undeniable that the technology is still one of the most important technologies in the mobile development field. Because of its ease of development and high portability, developers engaged in Java can quickly invest in the development of j2s, which is much easier than C ++ development on the Symbian platform.
As an application of enterprise customers, the main business model is c/s. The server stores user data and responds to the complex business logic of online users. As the receiver of data, the client processes simple business logic and stores a small amount of data, such as chat records, local accounts, and passwords. Of course, the client may also be a PC.
(Figure 1)
For example, the instant messaging software IM (instant message) of a mobile phone, the server must support multiple clients online at the same time, store customer information, and process requests sent from each client, forward Customer A's information to Customer B, and forward customer C's offline information to all friends of customer C. That is to say, all communication between a client and another client must be transferred through the server. The following describes a simple architecture model of the client.
We can use the MVC design concept to design this framework. It can be roughly divided into the following layers.
Handler: processing network requests and network message distribution. This layer is the most critical and involves each layer of the overall structure.
Database: used to store a small amount of data. In j2s, RMS (record management system) is the primary bearer of this level. Each Mobile Phone may support different RMS sizes, making this precious storage space more precious. Handler controls the storage and extraction of databases for display at the view layer.
Model: This layer is mainly used to create logic control classes based on program requirements. Encapsulate data and create public interfaces. For example, a message type may be created for storage in the database.
View: displays the user interface and responds to and processes keyboard commands. Display some information assigned by the handler layer and send the requirement information to handler for processing. Therefore, this layer communicates directly with handler and does not directly involve database or network information.
(Figure 2)
Of course, it will be more complicated in actual application development. For example, there is a session to Control Message polling and network connections. Below I will use a pseudo code to further describe this model.
/** View: Display messsage, receive input */
Package view;
Import .....
Public Class View extends canvas
{
Public String GetUserName ();
Public String getuserpassword ();
Public void displaymessage (Graphics g)
{
G. drawstring (handler. getinstance (). getmessagecontent (), X, Y, 0 );
}
Public void commandaction (command C, displayable D)
{
Handler. getinstance (). setuserinfo (GetUserName (), getuserpassword ());
}
}
/**************************************/
/* Handler: Control Network Message */
Package handler;
Import ......
Public class Handler
{
Public senduserinfo (string name, string password );
Public void getresponse ()
{
If (OK)
{
Notfiydisplay ();
}
}
Public void notfiydisplay ()
{
Message mess = new message (mess. tostring ());
Database. putmessage (MESS)
View. getinstance (). repaint ();
}
Public String getmessagecontent ()
{
Message M = database. getinstance. getmessage ();
Return M. getcontent ();
}
}
/************************************/
/* Message: a model indicate message object */
Package Model;
Import ......
Public class message
{
Public message (string Str)
{
}
Public String getcontent ()
{
}
}
/**********************************/
/* Database: store bytes */
Package database;
Import ......
Public Database
{
Public void putmessage (Message mess)
{
}
Public message getmessage ()
{
}
}
/***********************************/
Complex applications also need to process multimedia content and various connection methods, and require higher thread management and network connections. It is worth noting that the code of an application can be reused. In this way, you only need to change the display of some view layers to adapt to different application types. Welcome to my MSN discussion application development, k7sem_88@hotmail.com