1. 面向接口,面向?qū)ο,面向方向的編程的不?(Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.)
Interface-oriented (面向接口): 其實(shí)項(xiàng)目中非常頻繁的使用Interface,但從來(lái)不知道這就叫 Interface-oriented programming. 使用Interface的好處就是降低代碼的耦合程度,比方說(shuō),一個(gè)Url需要用戶登陸才能訪問(wèn),如果 thisUrl : IAuthentication, 那么你在實(shí)現(xiàn) thisUrl class的時(shí)候,就不需要操心Authentication的問(wèn)題。使用Interface的另外一個(gè)好處是,單元測(cè)試thisUrl 類的時(shí)候,可以mock IAuthentication.
Object-oriented (面向?qū)ο?: 自己從來(lái)沒有嚴(yán)謹(jǐn)?shù)亩x過(guò),但知道對(duì)象有狀態(tài),有方法,相似對(duì)象的抽象叫做類,對(duì)象是類的具體。面向?qū)ο蟮木幊逃蟹庋b,多臺(tái),繼承等概念。
Aspect-oriented (面向方向): 一種避免重復(fù)性代碼的編程方法,當(dāng)代碼中很多地方都重復(fù)用到同一個(gè)功能的時(shí)候 e.g. logging,可以使用aspect統(tǒng)一處理logging這部分的邏輯。The Ted Neward Challenge (AOP without the buzzwords) 這篇文章對(duì)我理解這個(gè)概念非常有幫助。
2. 接口跟類的區(qū)別 Describe what an Interface is and how it’s different from a Class.
接口(Interface): 不能實(shí)列化,自己沒有狀態(tài),方法也沒有具體的實(shí)現(xiàn),被繼承時(shí),繼承類需要實(shí)現(xiàn)接口的所有方法。接口就像租房時(shí)網(wǎng)上下載的一個(gè)租房合同模板。
類 (Class): 可以被實(shí)例化,有狀態(tài),被繼承時(shí),繼承類也不需要重新實(shí)現(xiàn)被繼承類中的方法。但是如果被繼承類的方法中有abstract修飾的,繼承類則需要實(shí)現(xiàn)這個(gè)方法。類像是已經(jīng)被填上內(nèi)容的租房合同的模板。
3. 什么是反射?What is Reflection?
代碼在運(yùn)行過(guò)程中動(dòng)態(tài)獲取程序集的信息,對(duì)象的信息,或者直接調(diào)用對(duì)象的方法或?qū)傩?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: 是開放標(biāo)準(zhǔn),使用Http/SOAP協(xié)議交互。
.Net Remoting: 是微軟自己的技術(shù),只能在.Net里面使用。
因?yàn)樽约簺]有接觸過(guò)ASMX, .Net Remoting, 所以只能了解個(gè)皮毛,在網(wǎng)上看到一個(gè)答案,比較的詳細(xì):
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的類型體系是不完全一樣的, 比如說(shuō)數(shù)字類型, XmlSchema 就有negativeInteger等.Net沒有的類型.
6. 早期綁定跟晚期綁定的不同?(what is the difference between early-binding and late-binding?)
不知道是不是這么翻譯的,early-binding: 是指編譯的時(shí)候綁定,late-binding是指運(yùn)行的時(shí)候綁定.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?
動(dòng)態(tài)
8. 什么時(shí)候合適使用Assembly.LoadFrom 或 Assembly.LoadFile?(When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?)
自己不太明白,什么時(shí)候用比較合適,有哪位知道嗎?
9. 一個(gè)程序集合格的名字是怎么樣的?是文件名嗎?如不是,區(qū)別是什么?(What is an Asssembly Qualified Name? Is it a filename? How is it different?)
一個(gè)程序集的名字有四個(gè)部分組成,文件名(file name),不包含后綴,Public key Token, Culture, Version. 跟文件名不同,
10. Assembly.Load("foo.dll") 對(duì)嗎?(Is this valid? Assembly.Load("foo.dll");)
不對(duì),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 程序集可以保成程序集的獨(dú)特性,并且可以防止使用被別人篡改過(guò)的程序集
12. Can DateTimes be null?
DateTime 不能為Null.
13. 解釋JIT, NGEN,以及它們的優(yōu)劣?(What is the JIT? What is NGEN? What are limitations and benefits of each?)
JIT: Just In Time 編譯,優(yōu)勢(shì): 任何JIT都可以編譯; 劣勢(shì): 啟動(dòng)時(shí)間比較長(zhǎng).
NGEN: 直接編譯成機(jī)器代碼,優(yōu)勢(shì): 啟動(dòng)時(shí)間比較長(zhǎng); 劣勢(shì): 只能運(yùn)行在本系統(tǒng).
不確定是否這樣解釋?請(qǐng)高手指正.
14. How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?
CLR把對(duì)象分成三代, .Net GC通過(guò)一個(gè)對(duì)象被創(chuàng)建的時(shí)間來(lái)決定這個(gè)對(duì)象的壽命. 創(chuàng)建時(shí)間比較短的對(duì)象越早被收集, 創(chuàng)建時(shí)間比較長(zhǎng)的對(duì)象越晚被收集.
non-deterministic finalization 是指你根本沒有辦法確定或控制一個(gè)對(duì)象被GC收集.
15. Finalize() 和 Dispose() 的區(qū)別 (What is the difference between Finalize() and Dispose()?)
GC在收集一個(gè)對(duì)象的時(shí)候, 調(diào)用Finalize(), 程序員沒有辦法調(diào)用. 但是程序員應(yīng)該負(fù)責(zé)在使用未托管資源(unmanaged object or resources)時(shí)使用Dispose(), 確保該資源被GC及時(shí)收集.
16. How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?
using()可以確保Dispose()在using() block 結(jié)束的時(shí)候被調(diào)用. IDisposable 只有一個(gè)方法, Dispose(), 當(dāng)一個(gè)類繼承IDisposable時(shí), 這個(gè)類的對(duì)象使用using()時(shí), Dispose()被調(diào)用.
17. What does this useful command line do? tasklist /m "mscor*"
列出所有使用符合引號(hào)內(nèi)pattern的dll的進(jìn)程.
18. What is the difference between in-proc and out-of-proc?
In-proc 發(fā)生在一個(gè)進(jìn)程之內(nèi), Out-of-proc 發(fā)生在不同進(jìn)程之間。
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道題目的時(shí)候,明顯感覺到難度,花了大半天的時(shí)間,其中很多是在借助了google 之后閱讀了很多的文章才知道一些?磥(lái),成為一位合格的中級(jí).Net程序員要補(bǔ)的課還真是不少呢。
很好奇,不知道博客園里的.Net程序員們有多少對(duì)這些問(wèn)題都能夠了如指掌,對(duì)答如流的?