Chapter 9 - Implementation Technology

  • It is not required to write programs, but it is necessary to be able to understand programs
  • In general, this chapter has no focus, it seems relatively easy (mainly the distributed content is discussed in OS)

Implementation Technology Definition

  • One of the primary tasks in the implementation phase is to construct a suitable program architecture so that all user requirements can be met and reflected in the future system.
  • The transformation process from design to code not only has the realization of the algorithmic process, but also takes into account the constraints of each specific project.
  • Key technologies related to implementation: data management strategies and methods, data persistence, XML, domain-specific language (DSL), model-driven architecture (MDA), refactoring (Refactoring), etc.

Implementation of non-functional requirements

  • Since non-functional requirements involve a wide range and different types, they need to be treated differently in design and implementation according to different requirements.
  • Hardware is one of the means to improve performance, but algorithms, resource utilization, etc. also need to be considered and monitored (when necessary).
  • Quality aspects (correctness) requirements: testability, program structure.
  • Security requirements: transmission security, data security, operational security. (Intrusion and Robustness)

Distributed Systems

  • There are multiple points of control in a distributed system because there are multiple subroutines that need to work simultaneously, like processes in an operating system.
  • The way and rules of information exchange between processes is a relatively complex problem in the information field, and the solution is closely related to the conditional requirements (key areas), such as database transactions.
  • Implementation requirements: isomorphism and heterogeneity, distribution management of objects in the network, synchronous call and asynchronous call, etc.

1. Synchronous and asynchronous calls

  • The biggest advantage of synchronous calls is that all processes know each other about the state they are in during the communication process
  • The disadvantage of synchronous calls is that relatively complex synchronous communication needs to be implemented . Since the sender and receiver need to wait for each other, the overall execution speed of the two processes will slow down .
  • Asynchronous calls are usually faster because the sender and receiver can work independently of each other .
  • The place where asynchronous calls are prone to problems is when the buffer is full . At this time, the entire system runs slowly or information may be lost .

2. Deadlock, competition and livelock

insert image description here

  • Deadlock generation, process competition
  • Livelock is also known as starvation
  • Solution: Scheduling problem, make a compromise between fairness and rationality.

3. Fat client, thin client, three-tier architecture

insert image description here

  • The three-tier architecture realizes the separation of view, business and data, improves system maintainability and provides better options for system distribution.

XML

  • XML is a standardized language defined by the W3C committee to describe data models and data.
  • Description of XML structure: DTD (Data Type Definition) and XSD (XML Schema Definition).
  • If an XML document describes and constrains its standard DTD or XSD, the document is said to be well formed, which specifies the validity of the XML document.
  • For the storage and processing of XML documents, there have been many available software packages or systems, so that every programming language has the ability to process XML documents.
  • XML is generally handled in two ways: Document Object Model (DOM) or Simple API for XML (SAX).
    • DOM is the first choice for complex object processing, such as when XML is more complex, or when random processing of data in documents is required.
    • SAX moves from the beginning of the document through each node in a stream to locate a specific node.

program wheel

  • For most frequently occurring problems, common solutions can be extracted in the form of library functions as a common resource sharing.
  • Library functions can be free or charged, and you should try to choose those function libraries with more users, because there may be fewer defects.
  • When testing the application, it is usually performed on the basis of assuming that the function library is correct, and there is no need to test the library function directly .
  • Valuable wheels:
    • Mature and stable, code specification, friendly interface, function meets expectations;
    • There is a guarantee of relevant support, such as sound documentation, and it is best to have actual use cases;
    • The community is relatively active, with many users, frequent maintenance, and timely defect handling;
    • Loosely coupled, easy to customize;
    • The price is right, there is a suitable license, preferably open source.

components

  • A component can be understood as a special object , and a component is a simple encapsulation of data and methods .
  • Using components enables drag-and-drop programming, fast property handling, and true object-oriented design .
  • Components are a further improvement of the idea of ​​class libraries . Instead of only providing the functions of a single class, they encapsulate a certain sub-application for use .
  • Components can implement interfaces to provide a class of objects that implement those interfaces.
  • When using off-the-shelf components to develop applications, components can generally work in two modes: design time and runtime.
    • In design time, components are displayed in a form under the form editor. The method of the component in the design time cannot be called, the component cannot directly interact with the end user, and it is not necessary to realize all the functions of the component.
    • In the running state, the component works in an application that is actually running. A component must be able to represent itself correctly, it needs to handle method calls and achieve effective collaboration with other components.
    • All components are visible in the form at design time, but not necessarily at runtime. For example, JTable and JLabel in Swing can be set to be invisible at runtime, but they all complete important functions.

frame

  • Quickly, efficiently and correctly accumulate a lot of original work into a larger -grained semi-finished system
  • Programmers only need to customize the necessary parameters to build it into a real system that meets user needs
  • The framework provides a common platform to embed business classes through interfaces or class inheritance, so as to achieve the purpose of system customization.
  • The main difference between a component and a framework is that control rights need to be transferred in the framework , that is to say, the classes in the framework will call the methods in the objects implemented by the user , and not the other way around, but this is the case in components. It happens - reflection .

data persistence

  • There are generally two types of persistent storage of data: physical files or database systems.
  • The advantage of the database system is that different applications can use the same data concurrently at the same time, providing good data sharing and security.
  • Most of the problems that exist in many distributed systems can be solved by database systems.

1. File Persistence

  • To directly use files to persist data, different programming languages ​​provide different technical support.
  • One of the basic features is the ability to allow developers to store data in files as binary raw data.
    • Based on this basic storage function, more convenient file storage services can be derived.
    • The advantage of the file storage method is that it is more readable and can be easily read by manual editing or other programs.
    • The problem is that developers have to write storage or read-in methods for each class that needs to be persisted, which is a very tedious job.
  • So a more direct idea is to be able to store the class as a whole. In order to be able to do this work in Java, it is necessary to implement the interface Serializable for the persistent class. Although this interface does not contain any methods, you only need to implement Just do it.
    • The types of all instance variables required by the persistent class also implement Serializable.
    • The disadvantage is that the stored files are in binary form, which can only be recognized and read by the application where this class is located.
    • Moreover, when some changes occur in the class in the program, such as adding a new instance variable, problems will arise when reading it again.
    • In order to be able to continue reading data from the stored binary file, a helper program must be used to convert the object to the new form of the type.

2. Database persistence

  • The storage of large amounts of data is generally carried out with the help of database systems.
  • Most new system development will choose a relational database to manage data.
  • The obvious disadvantage of relational databases is that the business storage model needs to be designed and built on the database side in advance, and some programming work and compatibility processing between object data and relational (table data) need to be done in the application in the data persistence layer.
  • One way to solve this impedance mismatch problem is to use separate functional software to realize the automatic management of the objects and database storage procedures in the application , which is the so-called object-relational mapping (OR Mapping) .
  • Complete efficient management of the conversion between business entity classes and their persistent forms, including transaction management, so that developers can concentrate on business function development.

Model Driven Architecture (MDA)

  • The basic idea of ​​Model Driven Architecture (MDA) is to provide a formal solution, independent of specific programming language or even architecture.
  • The process of using MDA for development can be divided into four stages:
    • CIM (Computation Independent Model): Focuses on the system environment and requirements, but does not involve the internal structure and operation details of the system.
    • PIM (Platform Independent Model): Focuses on the internal details of the system, but does not involve the specific platform that implements the system.
    • PSM (Platform Specific Model): Focuses on the details of the implementation of the system on a specific specific platform, such as EJB, J2EE or .NET are all specific platforms.
    • Coding: Finally, the programmers construct the code according to the diagram according to the UML model content of the PSM, and write the code suitable for a specific specific platform.
  • The software development life cycle described by MDA is not much different from the traditional life cycle. The main difference lies in the artifacts created by the development process, including PIM, PSM and code.
  • PIM is a model with a high level of abstraction, independent of any implementation technology. PIMs are converted to one or more PSMs.
  • PSM is a model tailored for a specific implementation technology, for example, EJB PSM is a system model expressed in EJB structure.
  • The final step of development is to convert each PSM into code, which is closely related to the application technology.
  • The transformation of MDA is automatically completed by tools, and the definition of transformation rules in this process is also very important, that is, the transition between models should be described formally.
    insert image description here
  • The transformation of PIM and PSM is described as the transition from Model 1 to Model 2 in the figure.
  • All models and transformation rules require a formal semantic definition, so the OMG organization has issued a series of specifications to standardize the MDA method, and the most important semantic description is included in the specification Meta Object Facility (MOF).
    insert image description here
  • A specific application of MDA is the construction of Entity Relationship Diagram (ERD) in the database design tool Power Designer.
  • The design of the database model is divided into four main stages in turn, namely, the conceptual model (Conceptual Design Model, CDM), the logical model (Logical Design Model, LDM), the physical model (Physical Design Model, PDM) and the database code, respectively corresponding to It is four levels of CIM, PIM, PSM and Coding in MDA .
    insert image description here
  • Models CDM and LDM are models independent of specific database platforms,
  • The field types contained in it are also neutral types, and the design tool is responsible for maintaining the mapping rules to the specific database platform.
  • PDM is the corresponding physical model on the Oracle 10g platform

refactor

  • The reconfigurability of complex programs is one of the goals of object-oriented . In order to ensure the realization of this goal, the program must be simplified as much as possible to increase its readability .
  • For example, in addition to the requirements on the behavior of the method in the detailed design document, additional guidelines can also :
    • Method names should be as self-explanatory as possible ;
    • The longest method should not exceed 12 lines, and contain as few while, switch and if logic blocks as possible .
  • The main consideration at the method level is how to integrate a grammatically correct program fragment into a new method.
  • Refactoring allows the structure of a program to be altered after it is first constructed so that it can be constructed in the desired form.
  • The refactored code is more readable and reusable, and its ideas can also be extended to the reconstruction and outsourcing of classes.

Guess you like

Origin blog.csdn.net/qq_42739587/article/details/114662002