Home Common Problem What is the purpose of coding in management information system code design?

What is the purpose of coding in management information system code design?

Aug 28, 2020 pm 02:16 PM
coding

The purpose of coding is: uniqueness, standardization, and systematization. Codes represent various objective entities with numbers or characters. The purpose of designing codes during the system development process is: uniqueness, standardization, and systematization.

What is the purpose of coding in management information system code design?

Codes use numbers or characters to represent various objective entities. The purpose of designing codes during the system development process is:

1. Unique ization;

2. Standardization;

3. Systematization.

Six principles of code design

Single Responsibility Principle

Definition: one A class or an interface is best responsible for only one responsibility.

Origin of the problem: Class T is responsible for two different responsibilities P1 and P2. Because responsibility P1 needs to be changed and the T class needs to be modified, it may cause the function of responsibility P2 that was originally running normally to malfunction.

Solution: Follow the single responsibility principle. Create new classes respectively to correspond to the corresponding responsibilities; this way you can avoid modifying the class from affecting other responsibilities;

When encountering the proliferation of responsibilities, only when the logic is simple enough, Violating the Single Responsibility Principle at the code level. Only when the number of methods in the class is small enough can the Single Responsibility Principle be violated at the method level;

Advantages: The complexity of the class will be reduced and the readability will be reduced. It will be greatly improved and maintainability will also be improved.

Liskov Substitution Principle

Where the base class is used, its subclasses can be used arbitrarily, which can ensure that the subclass can perfectly replace the base class; this kind The spirit is actually the embodiment of the constraints and norms of the inheritance mechanism. In the specific implementation of parent classes and subclasses, the relationship characteristics in the inheritance hierarchy are strictly controlled to ensure that when replacing the base class with a subclass, program behavior will not cause problems and can continue normally.

For inheritance, the parent class defines a series of specifications and contracts. Although it is not mandatory for all subclasses to comply, if the subclass arbitrarily modifies these non-abstract methods, the entire inheritance system will be affected. Cause damage.

If you have to rewrite the method of the parent class, the more common method is: the original parent class and subclass both inherit a more popular base class, remove the original inheritance relationship, and use dependency , aggregation, combination and other relationships instead;

principle includes the following four levels of meaning:

* Subclasses can implement the abstract methods of the parent class, but cannot override the non-abstract methods of the parent class Methods;

* Subclasses can add their own unique methods;

* When a method of a subclass overrides a method of a parent class, the formal parameters of the method are larger than the input parameters of the parent class method. Better and looser;

* When a method of a subclass implements an abstract method of a parent class, the return value of the method is more stringent than that of the parent class;

Dependence Inversion Principle

Definition: High-level modules should not rely on low-level modules, both should rely on their abstractions; abstractions should not rely on details; details should rely on abstractions, and the core idea is to rely on abstractions;

Origin of the problem: Class A directly depends on class B. If you want to change class A to depend on class C, you must modify the code of class A; in this scenario, class A is generally a high-level module responsible for complex business Logic; Class B and Class C are low-level modules responsible for basic principle operations; if class A is modified, it will bring unnecessary risks to the program.

Solution: Modify class A to depend on interface I. Class B and class C each implement interface I. Class A indirectly contacts class B and class C through interface I, which will reduce the cost of modifying class A. Probability;

In practice, we generally need to do the following three points:

* Low-level modules must have abstract classes or interfaces, or both;

* The declared type of the variable should be an abstract class or interface as much as possible;

* Follow the Liskov substitution principle when using inheritance;

Interface Segregation Principle

Definition: The client should not rely on interfaces it does not need; the dependence of one class on another class should be based on the smallest interface, otherwise it will cause interface pollution; class A depends on class B through interface I, class C depends on class D through interface I. If interface I is not the minimum interface for class A and class B, then class B and class D must implement methods they do not need; the meaning of the

principle is: establish For a single interface, do not build a huge and bloated interface. Try to refine the interface as much as possible and have as few methods as possible in the interface. That is to say, we should establish a dedicated interface for each class instead of trying to build a huge interface for all those who rely on it. Class to call;

Note that the interface should be as small as possible, but there must be a limit. Refining the interface can improve programming flexibility, but if it is too small, the number of interfaces will be as small as possible, making Design complexity. Therefore, it must be moderate. Customize services for classes that rely on interfaces. Only expose to the calling class the methods it needs, and hide the methods it does not need;

Rule:

* An interface only serves one sub-module or business logic and serves customization;

* Compress the public methods in the interface through business logic to make the interface look more concise;

* Modify interfaces that have been polluted as much as possible. If the risk of change is too great, use the adapter mode to transform;

* According to the specific business, understand the logic in depth and use your heart to control the design ideas;

How to implement interface isolation, there are two main methods:

1. Delegation separation, by adding a new interface type to delegate the customer's request, isolating the direct dependence between the customer and the interface, please note This will also increase the system overhead;

2. Separate multiple inheritance and realize customer needs through multiple inheritance of interfaces;

Dimiter's Law

Definition: An object should keep the least knowledge about other objects. The core spirit is: don’t talk to strangers. The popular meaning is that an object should know less about the classes that need to be coupled and associated to call; this will lead to The degree of coupling between classes is reduced, and each class minimizes its dependence on other classes.

Principle of synthesis and reuse

The principle is to use synthesis/aggregation as much as possible instead of inheritance;

Opening and closing principle

Definition: A software entity such as a class, template, and function should be closed to extensions and modifications;

Solution: When the software needs to change, try to extend the behavior of the software entity. Implement changes instead of modifying existing code to implement changes;

  • Single Responsibility Principle: Implementation classes must have a single responsibility;

  • Richter Replacement principle: do not destroy the inheritance system;

  • Dependency inversion principle: interface-oriented programming;

  • Interface isolation principle: be careful when designing interfaces Simple one;

  • Demit's Law: Reduce coupling;

Opening and Closing Principle: General outline, open to expansion, closed to modification;

For more related knowledge, please visit: PHP Chinese website!

The above is the detailed content of What is the purpose of coding in management information system code design?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 common classification feature encoding techniques 11 common classification feature encoding techniques Apr 12, 2023 pm 12:16 PM

Machine learning algorithms only accept numerical input, so if we encounter categorical features, we will encode the categorical features. This article summarizes 11 common categorical variable encoding methods. 1. ONE HOT ENCODING The most popular and commonly used encoding method is One Hot Enoding. A single variable with n observations and d distinct values ​​is converted into d binary variables with n observations, each binary variable is identified by a bit (0, 1). For example: the simplest implementation after coding is to use pandas' get_dummiesnew_df=pd.get_dummies(columns=[‘Sex’], data=df)2,

How many bytes do utf8 encoded Chinese characters occupy? How many bytes do utf8 encoded Chinese characters occupy? Feb 21, 2023 am 11:40 AM

UTF8 encoded Chinese characters occupy 3 bytes. In UTF-8 encoding, one Chinese character is equal to three bytes, and one Chinese punctuation mark occupies three bytes; while in Unicode encoding, one Chinese character (including traditional Chinese) is equal to two bytes. UTF-8 uses 1~4 bytes to encode each character. One US-ASCIl character only needs 1 byte to encode. Latin, Greek, Cyrillic, Armenian, and Hebrew with diacritical marks. , Arabic, Syriac and other letters require 2-byte encoding.

Knowledge graph: the ideal partner for large models Knowledge graph: the ideal partner for large models Jan 29, 2024 am 09:21 AM

Large language models (LLMs) have the ability to generate smooth and coherent text, bringing new prospects to areas such as artificial intelligence conversation and creative writing. However, LLM also has some key limitations. First, their knowledge is limited to patterns recognized from training data, lacking a true understanding of the world. Second, reasoning skills are limited and cannot make logical inferences or fuse facts from multiple data sources. When faced with more complex and open-ended questions, LLM's answers may become absurd or contradictory, known as "illusions." Therefore, although LLM is very useful in some aspects, it still has certain limitations when dealing with complex problems and real-world situations. In order to bridge these gaps, retrieval-augmented generation (RAG) systems have emerged in recent years. The core idea is

Several common encoding methods Several common encoding methods Oct 24, 2023 am 10:09 AM

Common encoding methods include ASCII encoding, Unicode encoding, UTF-8 encoding, UTF-16 encoding, GBK encoding, etc. Detailed introduction: 1. ASCII encoding is the earliest character encoding standard, using 7-bit binary numbers to represent 128 characters, including English letters, numbers, punctuation marks, control characters, etc.; 2. Unicode encoding is a method used to represent all characters in the world The standard encoding method of characters, which assigns a unique digital code point to each character; 3. UTF-8 encoding, etc.

PHP coding tips: How to generate a QR code with anti-counterfeiting verification function? PHP coding tips: How to generate a QR code with anti-counterfeiting verification function? Aug 17, 2023 pm 02:42 PM

PHP coding tips: How to generate a QR code with anti-counterfeiting verification function? With the development of e-commerce and the Internet, QR codes are increasingly used in various industries. In the process of using QR codes, in order to ensure product safety and prevent counterfeiting, it is very important to add anti-counterfeiting verification functions to the QR codes. This article will introduce how to use PHP to generate a QR code with anti-counterfeiting verification function, and attach corresponding code examples. Before starting, we need to prepare the following necessary tools and libraries: PHPQRCode: PHP

What are the hdb3 encoding rules? What are the hdb3 encoding rules? Aug 29, 2023 pm 01:38 PM

The coding rules are: 1. If the previous code is 0 and the current data bit is 0, the code is 0; 2. If the previous code is 0 and the current data bit is 1, the code is bipolar pulse (+A or - A), and the counter is increased by 1; 3. If the previous code is 1 and the current data bit is 1, the code is 0, and the counter is increased by 1; 4. If the previous code is 1, the current data bit is 0, The encoding method is determined based on the parity of the counter. If it is an even number, the encoding is (+B or -B). If it is an odd number, the encoding is zero level and the counter is cleared and so on.

How to solve the problem of encoding of php database query results How to solve the problem of encoding of php database query results Mar 21, 2023 am 11:49 AM

PHP is a popular web programming language that can be used to write dynamic web pages and applications. In practical applications, PHP often needs to interact with the database to query and process data. However, when using PHP to get results from a database, you may encounter encoding problems, which often result in garbled characters. So, how to solve the problem of encoding of PHP database query results?

Learn how to improve coding performance based on GenAI in one article Learn how to improve coding performance based on GenAI in one article Apr 01, 2024 pm 06:49 PM

Hellofolks, my name is Luga, and today we will talk about technologies related to the artificial intelligence (AI) ecological field - GenAI. Facing the challenges of rapid technological innovation and differentiated business scenarios, traditional coding methods have begun to become acclimated and cannot fully cope with the growing demands. At the same time, emerging general-purpose GenAI (artificial intelligence technology) has great potential to meet this demand. As a representative of artificial intelligence technology, GenAI has begun to be widely used in all walks of life with its strong potential and capabilities. It can automatically learn and adapt to coding needs in different scenarios, greatly improving coding efficiency and quality. Through deep learning and model optimization, GenAI is able to accurately understand different