zoukankan      html  css  js  c++  java
  • 代码风格

    public static ExceptionConfig executeException(Exception e) {

     

            if(e!=null)//1

    ExceptionConfig ex=null;//3

    ActionMessage msg=null;

           List exceptionConfig = ConfigManager.getAllException();

           if (exceptionConfig != null)//2

               for (int i = 0; i < exceptionConfig.size(); i++) {

                  Object o = exceptionConfig.get(i);

                  if (o instanceof ExceptionConfig) { //4

                      ex= (ExceptionConfig) o;

                      if (e.getClass().getName().equals(ex.getType())) {

    msg = new ActionMessage(ex.getKey(), e.getMessage());

                          ActionMessages.addMessage(msg);

                         return ex;

                      }

                  }

               }

           return null;//5

        }

     

    在方法的输入方面

    1首先必须判断输入的参数 是否为空 防止NullPoint的出现  例如1

    2每通过调用方法获得对象都需要进行是否为null判断 例如2

    3如果出现循环中需要实例化对象获取的对象 可以在循环外 定义该

    对象 null 例如3

    4如果取出的对象是object类型 需要拆箱成其他类型 可以使用instaceof 判断

    类型是否是否相同 例如4

    在方法的输出方面

             1 根据输出也就是返回值的类型 进行返回 如果是对象类型 如果出现异常 其他原因时返回空  如果是原始数据类型像int型可以返回 0

  • 相关阅读:
    Bank5
    面向对象特征之多态性
    继承性与super的使用练习
    阿里云服务器被挖矿minerd入侵的解决办法
    ES Pipeline Aggregation(管道聚合)
    Elasticsearch索引自动套用模板
    docker.service启动失败:Unit not found的原因及解决办法
    Kubernetes集群资源监控
    Kunbernetes-基于NFS的存储
    Kubernetes核心技术Helm
  • 原文地址:https://www.cnblogs.com/liaomin416100569/p/9332055.html
Copyright © 2011-2022 走看看