Analysis Mode-Measurement and Surveying

Source: Internet
Author: User
Quantity (Quantity)
Object Model: Data Model:

Unit: the Unit main table. It generally stores the code and text description of the measurement Unit (may need to handle multi-language problems ).
Unit_Ratio: unit conversion rate

Quantity mainly encapsulates the unit-related logic, for example: Person1.Height. Add (8.5, Unit. Get ("cm "));
Person1.Height. Add (0.03, Unit. Get ("m "));
Quantity diff = person1.Height-person2.Height;

One of the main functions of the Unit processing logic is the unit conversion operation. For example, the overload code of the Quantity subtraction operator is similar to the following: Public static Quantity operator-(Quantity left, Quantity right)
{
Quantity diff = new Quantity (left. _ amount, left. _ unit );
Diff. _ amount + = right. _ amount * right. _ unit. Ratio (left. _ unit );
Return diff;
}

Measurement)
Measurement is a further abstraction of the quantity model. In this document, a physical examination is used as an example to obtain a set of metric data, such as height, weight, and blood pressure, if different fields are used in a table as shown in the preceding figure to store various metrics and units, there will be a large number of self-segments. Therefore, the following pattern applies:
Object Model:

Data Model:

PhenomenonType2: measurement type, such as length, weight, and volume. Each measurement type is associated with multiple measurement units)

Sample Data:


1. Various metrics (PhenomenonType) of a person's health check results (in fact there should be a physical check object) are stored in the Measurement
2. In the object model, Measurement and Quantity are separated to perform their respective duties.
3. When you select a unit, you can narrow down the unit range based on the measurement type (PhenomenonType). For example, the length unit can only be selected for the height attribute.
4. A basic unit (Is_Basic) can be maintained for each measurement type. Some internal operations of the system are subject to the basic unit, such as finance, inventory transactions, monthly checksum, and erp mrp operations.
To simplify the maintenance of the unit conversion rate by end users, the conversion rate between each unit and the basic unit can be maintained. The system automatically calculates the conversion rate between any two units in the same measurement type, however, the system can not make the logic hard-coding more flexible. This is a basic business design and guidance method.

Ing (Observation)
Ing is a further abstraction of the above two modes
Although the measurement model uses the measurement type to bring more flexibility and versatility, it still considers the measurement type "quantity + unit". Taking the color blindness as an example, it is still an evaluation indicator, but the evaluation results are generally shown as A set of optional values: Class A red blind, Class B red blind, Class B red weak, and Class B green weak.
Therefore, an Observation class is extracted and two types are derived from it: Measurement and CategoryObservation)
Object Model:

Data Model:

CagegoryOption3: List of optional values for each category evaluation (CategoryObservation) Type
PhenomennonType3: add an Observation_Type field to differentiate the ing type, for example, 1: Measurement, 2: CategoryObservation
Using object-oriented means, Measurement3, CategoryObservation3 and Observation3 implement interfaces or inherit the relationship between the base classes. using structured design means, they only have weak associations, martin provides a detailed description of generalization in the book.
The preceding example shows how to use Single table inheritance to implement this inheritance relationship. The Category_Option field of the Measurement subtype is invalid and the Amount and Unit fields of the CategoryObservation subtype are invalid; categoryObservation3 and Measurement3 need to be implemented using different sub-classes due to behavioral differences. Measurement3 and Quantity3 are also separated due to different responsibilities. The figure clearly shows redundant and repetitive smells, so it is not an optimization design, but it is appropriate to understand Martin's Observation.

Timeliness of Conversion Rate
The conversion between units fluctuates over time, typically the exchange rate between various currencies. In this case, you need to add an effective time range for the conversion rate. For example:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.