.Net程序员面试 中级篇 (回答Scott Hanselman的问题)

 

  继《.Net 程序员面试 C# 语言篇 (回答Scott Hanselman的问题)》跟《.Net程序员面试 每个人都应知道篇 (回答Scott Hanselman的问题)》之后,今天回答Scott Hanselman在他清单上列出的“中级.Net程序员应该知道的问题”。

1. 面向接口,面向对象,面向方向的编程的不同 (Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.)

Interface-oriented (面向接口): 其实项目中非常频繁的使用Interface,但从来不知道这就叫 Interface-oriented programming. 使用Interface的好处就是降低代码的耦合程度,比方说,一个Url需要用户登陆才能访问,如果 thisUrl : IAuthentication, 那么你在实现 thisUrl class的时候,就不需要操心Authentication的问题。使用Interface的另外一个好处是,单元测试thisUrl 类的时候,可以mock IAuthentication.

Object-oriented (面向对象): 自己从来没有严谨的定义过,但知道对象有状态,有方法,相似对象的抽象叫做类,对象是类的具体。面向对象的编程有封装,多台,继承等概念。

Aspect-oriented (面向方向): 一种避免重复性代码的编程方法,当代码中很多地方都重复用到同一个功能的时候 e.g. logging,可以使用aspect统一处理logging这部分的逻辑。The Ted Neward Challenge (AOP without the buzzwords) 这篇文章对我理解这个概念非常有帮助。

2. 接口跟类的区别 Describe what an Interface is and how it’s different from a Class.

接口(Interface): 不能实列化,自己没有状态,方法也没有具体的实现,被继承时,继承类需要实现接口的所有方法。接口就像租房时网上下载的一个租房合同模板。

类 (Class): 可以被实例化,有状态,被继承时,继承类也不需要重新实现被继承类中的方法。但是如果被继承类的方法中有abstract修饰的,继承类则需要实现这个方法。类像是已经被填上内容的租房合同的模板。

3. 什么是反射?What is Reflection?

代码在运行过程中动态获取程序集的信息,对象的信息,或者直接调用对象的方法或属性 e.g. var i = 100; i.GetType(); 输出System.Int32.

4. XML web service 跟 .Net Remoting 的不同 (What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?)

XML Web service: 是开放标准,使用Http/SOAP协议交互。

.Net Remoting: 是微软自己的技术,只能在.Net里面使用。

因为自己没有接触过ASMX, .Net Remoting, 所以只能了解个皮毛,在网上看到一个答案,比较的详细:

Remoting assumes the other end is .NET. This is because .NET remoting using SOAP uses the SoapFormatter to serialize data. SoapFormatter embeds the type information required to deserialize the object into the message itself. This requires that the client and the server must have access to this assembly. Remoting believes in the .NET Type System. Remoting believes in sharing types and assemblies. Remoting can support DCOM style Client Activated Objects which are stateful. The use of CAOs though have to be carefully thought about because CAOs cannot be load balanced. ASMX model does not assume that the other end is .NET. ASMX uses XmlSerializer to serialize data. Xmlserailizer believes that the XML Type System, that is the XSD is superior and works on serializing data conforming to a schema. In other words XML Web Services believe in sharing schema and contracts over types and assemblies. This makes the Web Services interoperable. ASMX services are usually stateless.

5. XmlSchema和CLS的类型体系是否异种同形? (Are the type system represented by XmlSchema and the CLS isomorphic?)

查了baidu才知道, isomorphic的意思, 异种同形. XmlSchema跟CLS的类型体系是不完全一样的, 比如说数字类型, XmlSchema 就有negativeInteger等.Net没有的类型.

6. 早期绑定跟晚期绑定的不同?(what is the difference between early-binding and late-binding?)

不知道是不是这么翻译的,early-binding: 是指编译的时候绑定,late-binding是指运行的时候绑定.e.g. person.DoSomething() early binding.
late binding:

1 Type animal = typeof(Animal);
2  object o = Activator.CreateInstance(animal);
3 var text = animal.InvokeMember("DoSomething", BindingFlags.Default | BindingFlags.InvokeMethod, null, o, null);

7. Is using Assembly.Load a static reference or dynamic reference?

动态

8. 什么时候合适使用Assembly.LoadFrom 或 Assembly.LoadFile?(When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?)

自己不太明白,什么时候用比较合适,有哪位知道吗?

9. 一个程序集合格的名字是怎么样的?是文件名吗?如不是,区别是什么?(What is an Asssembly Qualified Name? Is it a filename? How is it different?)

一个程序集的名字有四个部分组成,文件名(file name),不包含后缀,Public key Token, Culture, Version. 跟文件名不同,

10. Assembly.Load("foo.dll") 对吗?(Is this valid? Assembly.Load("foo.dll");)

不对,Assembly.Load("foo, Version=1.0.2004.0, Culture=neutral, PublicKeyToken=8744b20f8da049e3")

11. strongly-named 程序集跟非strongly-named 程序集有何不同?(How is a strongly-named assembly different from one that isn’t strongly-named?)

strongly-named 程序集可以保成程序集的独特性,并且可以防止使用被别人篡改过的程序集

12. Can DateTimes be null?

DateTime 不能为Null.

13. 解释JIT, NGEN,以及它们的优劣?(What is the JIT? What is NGEN? What are limitations and benefits of each?)

JIT: Just In Time 编译,优势: 任何JIT都可以编译; 劣势: 启动时间比较长.

NGEN: 直接编译成机器代码,优势: 启动时间比较长; 劣势: 只能运行在本系统.

不确定是否这样解释?请高手指正.

14. How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?

CLR把对象分成三代, .Net GC通过一个对象被创建的时间来决定这个对象的寿命. 创建时间比较短的对象越早被收集, 创建时间比较长的对象越晚被收集.

non-deterministic finalization 是指你根本没有办法确定或控制一个对象被GC收集.

15. Finalize() 和 Dispose() 的区别 (What is the difference between Finalize() and Dispose()?)

GC在收集一个对象的时候, 调用Finalize(), 程序员没有办法调用. 但是程序员应该负责在使用未托管资源(unmanaged object or resources)时使用Dispose(), 确保该资源被GC及时收集.

16. How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?

using()可以确保Dispose()在using() block 结束的时候被调用. IDisposable 只有一个方法, Dispose(), 当一个类继承IDisposable时, 这个类的对象使用using()时, Dispose()被调用.

17. What does this useful command line do? tasklist /m "mscor*"

列出所有使用符合引号内pattern的dll的进程.

18. What is the difference between in-proc and out-of-proc?

In-proc 发生在一个进程之内, Out-of-proc 发生在不同进程之间。

19. What technology enables out-of-proc communication in .NET?

.Net remoting

20. When you’re running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003?

Windows XP and 2000 : aspnet_wp.exe

Windows 2003 : w3wp.exe

Scott Hanselman的问题-3的更多相关文章

  1. “.Net 社区虚拟大会”(dotnetConf) 2016 Day 3 Keynote: Scott Hanselman

    美国时间 6月7日--9日,为期三天的微软.NET社区虚拟大会正式在 Channel9 上召开,美国时间6.9 是第三天, Scott Hanselman 做Keynote.今天主题围绕的是.NET ...

  2. 北京时间28号0点以后Scott Hanselman同志台宣布dotnet core 1.0 rtm

    今日占住微信号头条的好消息<终于来了!微软.Net Core 1.0下载放出>.本人立马跑到官网http://dot.net看了一下,仍然是.net core 1.0 Preview 1版 ...

  3. Scott Hanselman's 2014 Ultimate Developer and Power Users Tool List for Windows -摘自网络

    Everyone collects utilities, and most folks have a list of a few that they feel are indispensable.  ...

  4. .Net 程序员面试 C# 语言篇 (回答Scott Hanselman的问题)

    过去几年都在忙着找项目,赶项目,没有时间好好整理深究自己在工作中学到的东西.现在好了,趁着找工作的这段空余时间,正好可以总结和再继续夯实自己的.Net, C#基本功.在05年的时候,Scott Han ...

  5. .Net程序员面试 每个人都应知道篇 (回答Scott Hanselman的问题)

    昨天回答了Scott Hanselman在他清单上关于C#那部分的题目,.Net 程序员面试 C# 语言篇 (回答Scott Hanselman的问题),今天接着回答他在清单上列出的"每个写 ...

  6. .Net程序员面试 中级篇 (回答Scott Hanselman的问题)

    继<.Net 程序员面试 C# 语言篇 (回答Scott Hanselman的问题)>跟<.Net程序员面试 每个人都应知道篇 (回答Scott Hanselman的问题)>之 ...

  7. Scott Hanselman的问题-2

    .Net程序员面试 每个人都应知道篇 (回答Scott Hanselman的问题)   昨天回答了Scott Hanselman在他清单上关于C#那部分的题目,.Net 程序员面试 C# 语言篇 (回 ...

  8. Scott Hanselman的问题-1

    Scott Hanselman的问题 .Net 程序员面试 C# 语言篇 (回答Scott Hanselman的问题)   过去几年都在忙着找项目,赶项目,没有时间好好整理深究自己在工作中学到的东西. ...

  9. Connect() 2016 大会的主题 ---微软大法好

    文章首发于微信公众号"dotnet跨平台",欢迎关注,可以扫页面左面的二维码. 今年 Connect 大会的主题是 Big possibilities. Bold technolo ...

随机推荐

  1. Metasploit渗透测试实验报告

    Metasploit渗透测试实验报告

  2. java9新特性-13-增强的 Stream API

    1.使用说明 Java 的 Steam API 是java标准库最好的改进之一,让开发者能够快速运算,从而能够有效的利用数据并行计算.Java 8 提供的 Steam 能够利用多核架构实现声明式的数据 ...

  3. HD-ACM算法专攻系列(3)——Least Common Multiple

    题目描述: 源码: /**/ #include"iostream" using namespace std; int MinComMultiple(int n, int m) { ...

  4. html页面颜色名称和颜色值转换

    public static string ToHtmlColor(string colorName) { try { if (colorName.StartsWith("#")) ...

  5. 创建支持SSH服务的镜像

    一.基于commit命令创建 docker commit CONTAINER [REPOSITORY [:TAG]] 1.使用ubuntu镜像创建一个容器 docker run -it ubuntu ...

  6. ES6学习笔记(十四)Generator函数

    清明时节雨纷纷,路上行人欲断魂. 借问酒家何处有,牧童遥指杏花村. 二零一九年农历三月初一,清明节. 1.简介 1.1.基本概念 Generator 函数也是 ES6 提供的一种异步编程解决方案,据说 ...

  7. 推荐《SQL基础教程(第2版)》中文PDF+源代码+习题答案

    我认为<SQL基础教程(第2版)>非常适合数据库学习的初学者.论述的角度是读者的角度,会换位思考到读者在看到这一段时候会发出怎样的疑问,非常难得:原始数据的例题只有一道,但是可以反复从不同 ...

  8. 转载 :Linux有问必答:如何在Debian或Ubuntu上安装完整的内核源码

    http://linux.cn/article-5015-1.html 问题:我需要为我的Debian或Ubuntu下载并安装完整树结构的内核源码以供编译一个定制的内核.那么在Debian或Ubunt ...

  9. unity C# StackOverflowException

    有时候图省事,属性这样写public int pageCount{get{return pageCount;}set{pageCount=value;}}可能会报栈溢出的错误, StackOverfl ...

  10. shiro整合thymeleaf

    1.引入依赖 <!--thymeleaf中使用shiro--> <dependency> <groupId>com.github.theborakompanioni ...