both IOS and Android are popular mobile operating systems, and are used by mobile terminals and smart devices, both of which are designed with advanced software technology and use advanced design patterns to facilitate application development.
What techniques are used in the design of the framework? What design patterns are used? What are the similarities and differences between the design ideas and the application development model?
- Both use a frame pattern.
The IOS framework is called Cocoa Touch.
The framework provides two functions, one is a collection of classes, each class constructs a problem space, and provides a complete solution and service. Two more important is that the classes in the framework depend on each other to form an overall structure for the entire application. A framework-defined structure is a generic structure that provides a running template for an application, so that many of the framework classes are either abstract or intentionally incomplete, and this class typically implements a large number of common code, but makes the important part of the work or not complete. It is either done in a secure default manner.
Because the application structure is generic, the developer is specialized by the hooks provided by the framework or by other means, such as subclasses. To meet the requirements of a particular application; Designing an application is to insert application code into the design provided by the framework to complete the design, and to run and manage the application's life cycle by the framework driver.
The frame to use. The developer must accept the application structure it defines, and then use and customize as many of its classes as needed. The specific application is adapted to fit the structure.
In the broad sense of metaphor, the framework is like the frame of a house, and the application code is akin to a door, window, wall panel, and other elements that make a house unique.
Both the IOS framework and the Android framework provide a variety of ways for applications. To modify and extend its common behavior.
A way to add application-specific behavior to the framework. is to create the self-stator class of the framework class. Subclasses fill in the gaps in their superclass, providing the missing parts of the framework class.
Example from a stator class. Occupy its position in the object network defined by the framework, and also inherit the ability of the framework to work with other objects.
Such design patterns are called template patterns.
Android, for example, uses this pattern to customize the behavior of the application. The Android framework provides the application with the common default implementation of the activity, SERVICE, Content providers, broadcast receivers four application components, which are subclasses of these components, An application development can be completed based on some of the methods required to overwrite the component.
iOS uses a trust and protocol model to implement some of the specific behavior of the application.
In iOS, a UIKit in the framework provided by Cocoa Touch provides and manages the behavior of the application, including the launch of the application until exiting, and the UIKit framework manages many of the core behaviors of the application.
The UIKit framework contains a UIApplication object, the UIApplication object is the heart of the application, which receives events from the system and then dispatches the event to custom code that is implemented by the application for processing.
The detailed application only needs to instantiate the UIApplication object object to be able, does not need to subclass, the application specific behavior uses the trust and the Protocol pattern to be implemented by an application to entrust the object.
The application invokes the Uiapplicationmain function of the UIApplication object to launch the app by instantiating an application-entrusted object and passing it as a parameter to the Uiapplicationmain function.
The application is entrusted as a subclass of Uiresponder, and also implements the Uiapplicationdelegate protocol. Application-related events (primarily various application state change events) used to process UIApplication object delegation to achieve application customization.
The protocol pattern is one of the unique design patterns used by the OSX operating system framework.
A protocol is a declaration of a programmable interface, no matter what class can implement its method.
An instance of the class associated with the protocol, invoking the method of the Protocol, and obtaining the value returned by the class formally adopted and implemented by the Protocol. This type of communication between objects. A specific goal has been created. such as parsing XML code or copying objects. Objects on both sides of the Protocol interface can pass inheritance. The implementation of long distances is related to each other. As such, the agreement can be used as a sub-class substitution method.
Apple provides a framework that declares dozens of agreements.
The model-View-controller (MVC) design pattern is used in the development of two applications.
The view Controller object in the iOS framework acts as a controller role in MVC mode. Manages the rendering of application content on the screen. The view controller is responsible for displaying and managing individual views and their sub-views, as well as the interaction between those views and other parts of the application. When rendered. The view controller installs the view into the application's form so that they are displayed.
The Uiviewcontroller class in the iOS Uikit framework is the base class for all view controller objects, and each view controller object is an instance of the Uiviewcontroller class. It provides default functionality for loading views, rendering views, and rotating views in response to device rotation and several other standard system behaviors. The application implementation requires subclasses of the Uiviewcontroller class. Used to load application-specific views.
UIKit and other frameworks define additional view controller classes to implement the standard system interface. Like picker, tab bar interface and navigation interface.
The View Controller object provides the infrastructure to manage content-related views and coordinate the display and hiding of views. The view controller is also used to manage the child hierarchies of the application view.
Because the IOS app shows very limited space for content, the view controller also provides the infrastructure needed to pull the view out of a view controller. Replace it with a view from the view controller. Therefore, a view controller is a way for you to implement various types of content conversions.
The view controller object, which can be viewed as a self-contained unit, handles the creation and destruction of its own view, handling the display of its view on the screen. and coordinates the interaction between the view and other objects in the application.
The application loads the view controller and related views through a concatenation diagram or a nib resource file. The concatenation diagram or nib resource file contains views and view controllers that the application uses to present the content on the screen today.
A view in a tandem diagram. are organized according to the view controller that displays them. A tandem chart also determines the transformation of a set of views (called transitions), bringing users from a set of views to a group.
When you create a project, the name of the main concatenation diagram file is specified by the Nsmainstoryboardfile key in the Info.plist file that the application includes. An application that uses a nib file instead of a concatenation diagram. The ability to replace the Nsmainstoryboardfile key with the Nsmainnibfile key. and use this key to specify the main nib file to use.
The iOS framework's form corresponds to a UIWindow object, and the UIWindow object coordinates the rendering of one or more views on the screen.
Most applications have only one form. Used to render content on the home screen, but the application may have another form that displays content on an external monitor.
To change the content of your application, use the view controller to change the view displayed in the corresponding form. You will not replace the form itself.
Other than the host that acts as a view. The form also works with UIApplication objects. The event is routed to the view and view controller.
The iOS framework's view objects contain objects such as views, controls, and layer objects, and views and controls visually render the contents of the application. The view is used to draw content within the specified rectangular area and respond to events in that area. Control is a special kind of view that is responsible for implementing common interface objects. such as button, text bar, and toggle switch.
The view object is passed through the application's controller object. Understand the changes to model data and pass the controller object. Send user-initiated changes to the application's model object
The UIKIT framework provides a standard view, and each view object finally inherits from the UIView class. Used to render many types of content. Subclasses by directly UIView (or its subclasses). You can also define your own custom views.
In addition to including views and controls, applications can incorporate the Core Animation layer into their view and control hierarchies. A Layer object is actually a data object that represents the visual content.
Views use a lot of layer objects behind the scenes to render their content. You can also add custom layer objects to the interface. To implement complex animations and other types of complex visual effects.
The views provided by the UIKIT framework are organized into view hierarchies. The views displayed by the application are arranged in a hierarchical structure (intuitively based on include). This mode agrees that the application treats the individual view and the composition view equally.
The root of the hierarchy is a Form object; Each view below the root has a parent view and 0 or more child views.
The parent view includes child views.
The view hierarchy is a structural component of paint and event processing.
Model objects in the iOS framework can be implemented by the Uidocument object provided by the Uikit framework to implement a document type data model. You can also define your own data model and its associated business logic based on the types of data that you need to provide in the framework.
iOS applications can also use the core data framework to create and implement model objects. Core Data provides an infrastructure. To manage changes made to the model object. and store the model objects in a file, and then fetch them back. The Core Data Framework also provides many other features: self-support for undo and redo. and maintaining the relationship between the objects; Agree to save only a subset of the model objects in memory at any given time, use patterns to describe narrative model objects, agree to maintain non-intersecting collections of editing objects, support data storage version number management and migration.
Version number management allows you to easily upgrade the user files of the old version number to the current version number. Agree to store data in ICloud and then access data from multiple devices.
While the Android system does not have a separate View controller object, the activity component of the application serves as the view controller role for creating and loading, rendering views, loading the data provided by the model object through the model adapter adapter interface, and updating the display to the view.
The user's changes to the data model on the view are also the responsibility of the activity to update the model through the model adapter interface. Adapter serves as the middleman between data models and views.
The Android system form object is not open for application. Managed by the Framework's form management service.
The Android system is also an application-specific form, corresponding to the system-provided root view object.
The view object is rendered in the form.
Each view object of the Android system inherits from the view class, including the view and ViewGroup objects. The UI of an app is constructed from a view tree that consists of views and ViewGroup objects that are used to draw content on the screen and interact with the user, such as a button buttons or text fields.
The ViewGroup object is the container for the view and can include other view and ViewGroup objects in order to implement the layout of the interface.
ViewGroup objects and other view and ViewGroup objects included in them are organized in the form of a view tree.
The visual structure of the application UI of an Android system is defined by the detailed layout object layouts, and each detail layout object layout is a ViewGroup object. Includes linear layout, Relative layout, Web view, and more.
A View object consisting of multiple sub-views that comprise the application interface is displayed by loading the Setcontentview function into the application as the activity component of the View controller role.
The availability of model objects for Android systems is primarily provided by the content providers, and is provided to the view through a model adapter adapter object provided by the activity.
All rights reserved, please note the link when reprinted, thank you!
IOS vs. Android framework and app development model against one