假设: 我有一个Java/Android的模块化库,可以设置这样的: package com.mycorp.app.sample.integration;
public class ModuleConnector {
public static final LogcatLogger LOGCAT_LOGGER
= new LogcatLoggerImpl.Confi
我有一个包含项目集合的类。为方便起见,我提供GetCurrentItem这是由 public Type GetCurrentItem
{
get { return this.items[this.items.Count - 1]; }
}
如果在列表中没有的项目,这将抛出一个异常实现。 我应该抛出异常还是应该返回null?如果这是我交给你的API,你会期望什么?异常或null?有
背景:本着"program to an interface, not an implementation"和Haskell type classes的精神,作为一个编码实验,我正在考虑创建一个主要建立在接口和扩展方法组合基础上的API意味着什么。我有两条准则: 只要有可能就避免类继承。接口应实现为sealed class es。 (这是出于两个原因:首先,因为子类化引发了一些关于如何在其派生类中指