Developers hotly discuss GitHub code search policy and explore the best search solutions

Recently, a developer named koepnick was unable to log in to his GitHub account because he used GitHub to search for his own repository code on an old computer without a mobile phone or other devices to assist in verification. He posted an article angrily criticizing GitHub: If you are not logged in, you cannot use search. Code service, it is better to abandon it than this.

In fact, as early as June this year, GitHub officially issued an announcement stating "Code search now requires login." After the official announcement, in addition to the policy that global search for code on GitHub.com already requires user login, since June 7 Effectively, this policy has been expanded to include repository-wide searches. That is, to access the full functionality of GitHub's new code search and code navigation, you need to create an account or log in to GitHub.com.

Martin Woodward, Vice President of Developer Relations at GitHub, responded to Koepnick's dissatisfaction, saying that this was done mainly to help prevent the server from being overwhelmed by anonymous robot requests and ensure that it can support the load of developer visits on GitHub.

This incident that occurred on GitHub immediately aroused the attention and discussion of a large number of developers. Many programmers said that there is nothing wrong with enabling the login operation. "I think Microsoft sees the code on their platform as an asset because they can use it to train artificial intelligence that can be sold. They don't want other people to use the code on their platform." Do the same thing." However, some programmers believe that GitHub's idea of ​​requiring login to prevent the server from being overwhelmed by anonymous robot requests is naive and indirectly harms the user experience, and some users directly recommend other open source code search tools to replace it.

Nowadays, there are very few opportunities for developers to write code manually. Many programmers often choose to find functions through search engines, search and filter among countless similar functions, compare the pros and cons of different functions, and then choose the most suitable function. Making calls, but this behavior not only consumes a lot of time and energy, but also relies heavily on the individual developer's abilities. Just as GitHub's new code search has more content than ordinary search engines, the move to open a login account does affect part of the user experience and invisibly pushes users to other code tools.

In China, the function AI generator specially designed for developers launched by Feisuan SoFlu software robot can replace search engines and provide directly usable function solutions according to developers' needs.

FuncGPT is a function AI generator specially designed for developers. It receives natural language input and then outputs function solutions that can be used directly. The power of FuncGPT (FuncGPT) is that it understands natural language, which means you don’t need to have strong programming knowledge or be familiar with various functions and methods. Just describe your problem to FuncGPT and it will provide you with a solution. This greatly lowers the threshold for programming, allowing more developers to quickly find functions that suit them.

As an important part of Feisuan SoFlu software robot, FuncGPT (Hui Function) supports the creation of all types of functions. Use natural language to describe Java function requirements and generate high-quality, highly readable Java function code in real time. The generated code can be directly copied to IDEA, or imported into the Java fully automatic development tool function library with one click, thereby improving developers' coding efficiency.

The following is a command entered in FuncGPT (Function function) [Function function: Map batch assignment

Parameter 1: Parameter name: target; Parameter type: Map; Parameter description: Map object

Parameter 2: Parameter name: keyAndValue; Parameter type: Object; Parameter description: key value and value value, corresponding one after another (key=2n, value=2n+1)] Example:




// 类名:MapUtil
// 函数名:bulkAssignValues
// 函数功能:批量将键值对赋值给Map对象
// POM依赖包:
// <dependency>
//     <groupId>org.apache.commons</groupId>
//     <artifactId>commons-lang3</artifactId>
//     <version>3.12.0</version>
// </dependency>

import org.apache.commons.collections4.MapUtils;

import java.util.Map;

public class MapUtil {
    /**
     * 批量将键值对赋值给Map对象
     * @param target 目标Map对象
     * @param keyAndValue 键值对,先后对应(key=2n,value=2n+1)
     */
    public static void bulkAssignValues(Map<Object, Object> target, Object... keyAndValue) {
        if (target == null) { // 检查目标Map是否为空
            throw new IllegalArgumentException("Target Map cannot be null"); // 抛出异常,目标Map不能为空
        }

        if (keyAndValue == null || keyAndValue.length % 2 != 0) { // 检查键值对参数是否为空或键值对个数是否为偶数
            throw new IllegalArgumentException("Invalid key-value pairs"); // 抛出异常,键值对参数不合法
        }

        for (int i = 0; i < keyAndValue.length; i += 2) {
            Object key = keyAndValue[i];
            Object value = keyAndValue[i + 1];
            target.put(key, value); // 将键值对赋值给目标Map对象
        }
    }
}

// 函数示例
// 批量将键值对赋值给Map对象示例
// 入参:target,目标Map对象
// 入参:keyAndValue,键值对,先后对应(key=2n,value=2n+1)
// 调用示例:
// Map<String, Integer> targetMap = new HashMap<>();
// MapUtil.bulkAssignValues(targetMap, "key1", 1, "key2", 2, "key3", 3);
// System.out.println(targetMap);
// 输出结果:例如,将键值对赋值给Map对象,结果为:{key1=1, key2=2, key3=3}
// 则输出结果为:{key1=1, key2=2, key3=3}

 

The above Java code generated by FuncGPT (Hui Function) defines a class named MapUtil, which contains a static method named bulkAssignValues. The function of this method is to assign key-value pairs to Map objects in batches.

Dependency package: The code contains a dependency on Apache Commons Lang, version 3.12.0. Apache Commons Lang is a sub-project of the Apache Software Foundation ASF and provides a rich component library for Java. The MapUtils class comes from Apache Commons Collections, which provides some practical methods for operating and processing Maps.

Function design: The bulkAssignValues ​​function accepts two parameters, a target Map object and an array of key-value pairs. The function first checks whether the target Map object is empty, and throws an exception if it is empty. Then check whether the key-value array is empty or the length is an even number, and throw an exception if the condition is not met. Finally, each key-value pair is added to the target Map object in turn by looping through the array of key-value pairs.

Readability: Code comments and variable naming are clear and easy to understand. The design and naming of functions also comply with Java coding standards.

Performance: This function does not perform any unnecessary operations and directly adds the input key-value pairs to the target Map. Therefore, its performance is efficient.

Error handling: The function throws an IllegalArgumentException exception when encountering illegal parameters, which complies with Java's exception handling specifications.

 

To sum up, on the basis of supporting the creation of all types of functions in seconds, FuncGPT (Hui Function) has an in-depth study and understanding of Java syntax through best practices in coding and joint training with large-scale machines, so the generated function code It is of high quality, complies with industry standards, and avoids common coding errors and inefficiencies. Compared with the demo-level code cases received by search engines, FuncGPT (FuncGPT) provides developers with corresponding solutions for different customized demand scenarios. Based on the precise code plan, developers often only need to make slight adjustments to generate code that meets the developer's specific functional requirements. New experience for second-level function development

Follow the public account [SoFlu Software Robot] to unlock more functions and improve development efficiency!

IntelliJ IDEA 2023.3 & JetBrains Family Bucket annual major version update new concept "defensive programming": make yourself a stable job GitHub.com runs more than 1,200 MySQL hosts, how to seamlessly upgrade to 8.0? Stephen Chow's Web3 team will launch an independent App next month. Will Firefox be eliminated? Visual Studio Code 1.85 released, floating window Yu Chengdong: Huawei will launch disruptive products next year and rewrite the history of the industry. The US CISA recommends abandoning C/C++ to eliminate memory security vulnerabilities. TIOBE December: C# is expected to become the programming language of the year. A paper written by Lei Jun 30 years ago : "Principle and Design of Computer Virus Determination Expert System"
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/4868096/blog/10319646