显示标签为“Back to Basics”的博文。显示所有博文
显示标签为“Back to Basics”的博文。显示所有博文

2009年3月17日星期二

March 17th:C#,Debug,HTML

C#
    This post touches on four major expression subjects:
    1) String Comparison - does a string contain a particular sub-string?
    a. finding valid HTML tags- RegEx.Matches return MactchCollection
    valid html tags: Regex HTMLTag = new Regex(@"(<\/?[^>]+>)");
    2) Splitting a string into segments(分割,部分)- we will take an IPv4 address and retrieve its dotted components
    a. splitting decimal Tcp/IP address looks like xxx.xxx.xxx.xxx with x being a decimal number
    Regex tcpIp = new Regex(@"(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})");
    3) String Replacement
    4) Substitution Patterns
    5) Stricter input validation- how to harden your expressions
    1) The ? conditional evaluation operator
    example:int max = (x > y) ? x : y;
    2) Null-Coalesce(合并,联合) operator(??)
    example:obejct e = ( c != null ) ? c : d; => object e = c ?? d;
    3) Object Initializers
    Customer c = new Customer{ Name="James",Address="204 Lime Street"};(c# 3.0)
    4) The using statement
    5) Aliases(别名) for long winded namespaces and types
    example: using Word = Microsoft.Office.Interop.Word;
                     Word.Application = new Word.Application(){ Visible = true};
    6) Nullable objects
    example: Nullable x = null;
     int? x =  null;
    7) Automatic Properties(c# 3.0)
    8) Type inference(c#3.0 var)
    note: There is no performance impact results form using type inference.The compiler does all the work figuring out the data type at compile time.
    9) Lambda Expressions
    10) string.IsNullOrEmpty
    Optional and named parameters in C# 4.0
    Example:app.Document.open(ref filename,ref missing.......);
    app.Documents.open(@"c:\Document.docx",Readonly:true);
    1) what is an anonymous type?
      One important motivation(动机)for this was to make code written with LINQ easier to read.Anonymous types simply mean that you don't specify the type- but let the complier do it instead.
    2) what is the beneficial for Anonymous type?
    a. simple definitions,simplified
    b. using anonymous types for creating arrays
    c. Saving time and code with anonymous types
    d. Combining Lambda expressions with Queries
    3) other questions?
    a. Is var typesafe? yes
    b. Is there a performance penalty(处罚,征罚) for using "var"? no
    c. On using anonymous definitions in large projects

Debugger
    1) Install the Visual Studio 2008 QFE( Quick-Fix-Engineering)
    2) Start Visual Studio 2008 and bring up Tools > Options > Debugging > General
      Turn OFF the "Enable Just My Code" setting
      Turn ON the "Enable Source Server Support" setting
    3) Next,bring up the "Symbols" page and set the symbols download URL and a cache location.
      Set the symbol file location to be:http://referencesource.microsoft.com/symbols

Sliverlight

Other

2009年3月7日星期六

March 7th-8th Links: ASP.NET MVC,Expression Tree,SQL Injection,Delegate,Lambda Expressions

ASP.NET

ASP.NET MVC

C#
    WHAT DOES IT MEAN TO SAY THAT A TYPE IS A REFERENCE TYPE?
    Basically,it means that every variable of that type that you manipulate is actually a pointer to the actual object on the heap.When you make a copy of this reference,you get another reference that points the same object.
    Now,let's consider what it means to compare these reference. What does equality mean between two reference variables? The answer is ,it depends on what your needs are and how you define equality.
    2. Fast Reflection Library- Codeplex
    You use a generic whenever you have a piece of code which can be re-used by different types.The classic example is a data structure,like a list or hashtable.  

Security

English:
    Vulnerabilities: 易受伤,弱点,漏洞
    aka: Also known as
    malicious: 恶意的,恶毒的
    Exponentially: 成倍的
    Utilize: 利用
    Fed up with:受够了..

2009年3月1日星期日

March 2th-6th Links:Design Patterns,Observer Pattern,Decorator Pattern

ASP.NET

ASP.NET MVC

c#
    2. Snippet: Check for Internet Connectivity(c#)
    WHAT IS AN INTERFACE?
    Interface is a contract that implementer must follow.In other words,an interface says what class must defined.Importantly,an interface doesn't specify(or care) how the implemention is actually achieved. As we move forward we'll see how helpful this can be to us.
    An interface can define zero or more members(methods or propties) and a class can implement zero or more interface.Interface members always have public.An interface with zero member is called marker-interface,they don't require implementer to do anything.
    An raise exist of interface is to provide developers with a language-level tool that allows classes to be decoupled from each other.

Design Patterns
    The decorator pattern can be used to make it possible to extend (decorate) the functionality of a class at runtime.
    

Web

English
    1. legacy: 继承,遗产
    2. merciless: 殘忍的
    3. pair with: 搭配
    4. violation: 违反,违背
    5. proper: 适当的,正确的
    6. crucial: 关键的,决定性的
    7. snippet: 小片,片段
    8. badminton: 羽毛球
    9. decouple:
    10. overlap: 重叠