显示标签为“Regular Expression”的博文。显示所有博文
显示标签为“Regular Expression”的博文。显示所有博文

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月14日星期六

March 14th-16th Links:ASP.NET Task,SOLID,Regular Experssion,ReSharper,SQL SERVER...

ASP.NET
    In this article,I'll take about scheduled Task Manager in a ASP.NET Environment.We often need to make scheduled tasks running in background but it's not very simple to make it with asp.net.I based my article on StackoverFlow article which uses ASP.NET Cache to schedule tasks.

C#

Continous Intergration,NAnt,NUnit,NCover

ReSharper

SQL SERVER
     P.S. : Use ROW_NUMBER() clause and PARTITION BY clause

Other
    Regardless of which software development methodology and hierarchy(等级制度)you use,there's 1 core practice I think every team should use: estimation(估计) and tracking.
    What do you need to do?
    The first thing you need to break-down(分离) tasks and assign them to people.The next thing you need to do is put an estimate,in hours or days,on each task.This can either be done together by the team(preferred)or you can let each developer estimate his or her own tasks.
    All of these things can be done using a modern bug-tracker.We currently use Redmine.
    1) MSBuild/NANT/Build Automation
    2) WCF,WPF and WF
    3) Silverlight and Expression
    4) JQuery
    5) W3C Design Compliance & "Table-less Design"
    6) AZure
    1) Never check in changes that can't be built.
    2) Check in related changes atomically.
    Atomically(原子性)means all related changes are checked in at the same time.
    3) Make use of shelving.
    4) Get All Current code and build before checking in.