zoukankan      html  css  js  c++  java
  • github后端开发面试题大集合(三)

    作者:小海胆
    链接:https://www.nowcoder.com/discuss/3616
    来源:牛客网

    13.软件架构相关问题:

    • 什么情况下缓存是没用的,甚至是危险的?
    • 为什么事件驱动的架构能提高可扩展性(scalability)?
    • 什么样的代码是可读性强的代码?
    • 紧急设计(Emergent Design)和演化架构(Evolutionary Architecture)之间的区别是什么?
    • 横向扩展(scale out) vs 纵向扩展(scale up): 有什么区别?分别在什么场景下使用?
    • 分布式系统中如何处理"故障切换(failover)"和"用户会话(user session)"?
    • 什么是CQRS(Command Query Responsibility Segregation)?他和最早的Command-Query Separation原则有什么区别?
    • 什么是三层架构?
    • 如何设计一个可扩展性高的系统?
    • 处理C10k问题的策略有哪些?
    • 如果让你来设计一个去中心化的P2P系统,你会如何设计?
    • 为什么CGI的扩展性不好?
    • 在设计系统时,你如何防止供应商依赖(Vendor Lock-in)?
    • 在可扩展性上,发布/订阅(Publish-Subscribe)模式有什么缺点?
    • 80年代以后,CPU有哪些变化?这些变化,对编程产生了什么影响?
    • 性能生命周期(performace lifecycle)中,你认为哪个部分是需要考虑进去的? 如何管理?
    • 除了恶意攻击造成的拒绝服务现象以外,哪些设计或者架构上的问题会导致拒绝服务?
    • 性能和可扩展性之间有什么关系?
    • 什么时候紧耦合是OK的?
    • 一个系统要有什么特征才能适配云计算环境(Cloud Ready)?
    • Does unity of design imply an aristocracy of architects?


    14.面向服务架构相关问题:

    • 在SOA中,为什么长期存活的事务(Long-lived transation)不被看好,而Saga却被看好?
    • SOA和MicroService之间有什么区别?
    • 我们来谈谈Web服务的版本管理、版本兼容性、重大变更管理这些事情吧.
    • 在saga中事务和补偿操作(compensation operation)之间的区别是什么?在SOA中呢?
    • 微服务不能做得太"微",你认为什么时候微服务太"微"了?
    • MicroService架构的优劣是什么?


    15.安全相关问题:

    • 什么是双因素认证(Two Factor Authentication)?在一个已有的Web应用中,你如何实现这种机制?


    16.比尔盖茨式问题:

    • 如果你把一面镜子放在扫描仪上,会发生什么?
    • 假设有一个和你完全一样的克隆人,而他是你的上司,你愿意和他工作吗?
    • 现在请你面试一下我。
    • 为什么Quora上的回答会比Yahoo Answer上的回答好?
    • 对手是现代语言,你的任务是要为Cobol辩护,你会如何进行?
    • 10年后的你是什么样子?
    • 假设你是我老板,我被解雇了。你会如何通知我?
    • 我想要重构一个系统,而你想要从头重写。我们来争论一下该怎么弄吧。然后我们反转角色,再争论一下。
    • 老板要你对公司撒谎,你的反应是什么?
    • 如果你可以穿越到以前,你会给年轻时候的你什么建议?


    17.代码示例问题:

    • 这段Javascript函数的输出是什么?
     
    1
    2
    3
    4
    5
    6
    7
    8
    function hookupevents() {
      for (var i = 0; i < 3; i++) {
        document.getElementById("button" + i)
          .addEventListener("click", function() { 
            alert(i); 
          });
      }
    }
    • 关于类型擦除(Type Erasure),这段Java代码的输出是什么?为什么?
     
    1
    2
    3
    4
    ArrayList<Integer> li = new ArrayList<Integer>();
    ArrayList<Float> lf = new ArrayList<Float>();
    if (li.getClass() == lf.getClass()) // evaluates to true
      System.out.println("Equal");
    • 你能指出哪儿有内存泄漏吗?
    public class Stack {
        private Object[] elements;
        private int size = 0;
        private static final int DEFAULT_INITIAL_CAPACITY = 16;
        public Stack() {
            elements = new Object[DEFAULT_INITIAL_CAPACITY];
        }
        public void push(Object e) {
            ensureCapacity();
            elements[size++] = e;
        }
        public Object pop() {
            if (size == 0)
                throw new EmptyStackException();
            return elements[--size];
        }
        /**
         * Ensure space for at least one more element, roughly
         * doubling the capacity each time the array needs to grow.
         */
        private void ensureCapacity() {
            if (elements.length == size)
                elements = Arrays.copyOf(elements, 2 * size + 1);
        }
    }
    • if语句,或者更加通用点,条件表达式通常是过程式编程/命令式编程的形式。你能去掉这段代码中的switch语句,用面向对象的方式来修改这段代码吗?
    public class Formatter {
        private Service service;
        public Formatter(Service service) {
            this.service = service;
        }
        public String doTheJob(String theInput) {
            String response = service.askForPermission();
            switch (response) {
            case "FAIL":
                return "error";
            case "OK":
                return String.format("%s%s", theInput, theInput);
            default:
                return null;
            }
        }
    }
    • 你能去掉这里的if语句,将它改成更加面向对象吗?
    public class TheService {
        private final FileHandler fileHandler;
        private final FooRepository fooRepository;
        public TheService(FileHandler fileHandler, FooRepository fooRepository) {
            this.fileHandler = fileHandler;
            this.fooRepository = fooRepository;
        }
        public String Execute(final String file) {
            final String rewrittenUrl = fileHandler.getXmlFileFromFileName(file);
            final String executionId = fileHandler.getExecutionIdFromFileName(file);
            if ((executionId == "") || (rewrittenUrl == "")) {
                return "";
            }
            Foo knownFoo = fooRepository.getFooByXmlFileName(rewrittenUrl);
            if (knownFoo == null) {
                return "";
            }
            return knownFoo.DoThat(file);
        }
    }
    
    • 如何重构这段代码?
    function()
    { HRESULT error = S_OK; if(SUCCEEDED(Operation1()))
        { if(SUCCEEDED(Operation2()))
            { if(SUCCEEDED(Operation3()))
                { if(SUCCEEDED(Operation4()))
                    {
                    } else {
                        error = OPERATION4FAILED;
                    }
                } else {
                    error = OPERATION3FAILED;
                }
            } else {
                error = OPERATION2FAILED;
            }
        } else {
            error = OPERATION1FAILED;
        } return error;
    }
     
  • 相关阅读:
    mysql的权限定义
    数据库的启动流程和关闭介绍/mysql初始化配置文件
    SQL 执行顺序
    AJAX 同步请求锁浏览器
    JSON
    Json.NET
    JSON.parse()和JSON.stringify()
    the XMLHttpRequest Object
    命名方式
    varchar 和 nvarchar 的区别和使用
  • 原文地址:https://www.cnblogs.com/wuer888/p/7656870.html
Copyright © 2011-2022 走看看