• 微软原版系统

  • 一键重装系统

  • 纯净系统

  • 在线技术客服

魔法猪系统重装大师 一键在线制作启动 U 盘 PE 系统 用一键重装的魔法拯救失去灵魂的系统
当前位置:首页 > 教程 > 电脑教程

中级.Net程序员应该知道的问题-ScottHanselman清单上列出的

时间:2015年04月02日 15:41:17    来源:魔法猪系统重装大师官网    人气:2999
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

  回答这20道题目的时候,明显感觉到难度,花了大半天的时间,其中很多是在借助了google 之后阅读了很多的文章才知道一些。看来,成为一位合格的中级.Net程序员要补的课还真是不少呢。
  很好奇,不知道博客园里的.Net程序员们有多少对这些问题都能够了如指掌,对答如流的?
中级,.Net,程序员,应该,知道,的,问题,面向,
栏目:电脑教程 阅读:1000 2023/12/27
Win7教程 更多>>
U盘教程 更多>>
Win10教程 更多>>
魔法猪学院 更多>>

Copyright © 2015-2023 魔法猪 魔法猪系统重装大师

本站发布的系统仅为个人学习测试使用,请在下载后24小时内删除,不得用于任何商业用途,否则后果自负,请支持购买微软正版软件。

在线客服 查看微信 返回顶部