随笔分类 -  Clean Code / Refactor

Regex
摘要:“Logical resources may be of various types, such as brushes, geometries, styles, and templates.Placing all those resources in a single file such as App.xaml hinders maintainability. A betterapproach would be to separate resources of different types (or based on some other criteria) totheir own files 阅读全文
posted @ 2013-07-02 22:03 DebugLZQ 阅读(14927) 评论(8) 推荐(3) 编辑
摘要:"Markup extensions are used to extend the capabilities of XAML, by providing declarativeoperations that need more than just setting some properties. These can be used to do prettymuch anything, so caution is advised – these extensions must preserve the declarative natureof XAML, so that non-dec 阅读全文
posted @ 2013-06-27 21:27 DebugLZQ 阅读(4703) 评论(7) 推荐(4) 编辑
摘要:附加属性附加属性,大家都不陌生,最常见的是Canvas.Left/Canvas.Top,类似的也有Grid.Row/Grid.Column等附加属性。举个最常见的例子 需要说明的是并不是所有的附加属性都是元素放进去后才会有附加效果,上面的例子只是刚好是这种错觉的巧合情况,Grid.Row也属于这... 阅读全文
posted @ 2013-06-26 23:35 DebugLZQ 阅读(27538) 评论(6) 推荐(8) 编辑
摘要:1.XAML接触WPF的第一眼就是XAML---XAML是用来描绘界面的。其实不然!"Actually, XAML has nothing to do with UI. It's merely a declarative way of constructing objects and setting their properties.”XAML和UI一点关系也没有,它仅仅是一种以声明方式来构建对象,设置对象属性的一种方式而已,和code behind file作用差不多。XAML这种声明方式构建对象的好处是,程序员只管声明自己要什么,至于如何构建则不需要考虑。XAML对WPF 阅读全文
posted @ 2013-06-25 21:45 DebugLZQ 阅读(5424) 评论(1) 推荐(1) 编辑
摘要:前面DebugLZQ的两篇博文:浅谈IOC--说清楚IOC是什么IoC Container Benchmark - Performance comparison在浅谈IOC--说清楚IOC是什么中,DebugLZQ介绍了什么是到底什么是IOC/DI,再复习一下,那么到底什么是IOC呢?就像Marti... 阅读全文
posted @ 2013-06-24 14:42 DebugLZQ 阅读(9749) 评论(1) 推荐(1) 编辑
摘要:DataTabe 对象在很多地方都会用到,特别是在Web Service、Socket等需网络传输的地方。但是在有些地方,如果直接传递的话,程序可能会报告DataTable无法序列化错误。解决问题的方法,是对DataTable进行序列化。FCL提供的用于序列化的方法组要有三种:1.XML Serialization2.Binary Serialization3.SOAP Serialization感兴趣的可查下相关的具体操作文章,如 Introducing Serialization in .NET、Object Serialization in the .NET Framework等。--- 阅读全文
posted @ 2013-06-23 21:05 DebugLZQ 阅读(2496) 评论(0) 推荐(0) 编辑
摘要:In the earlier few articles, I made a summary of the asynchronous method call. You can click this link to access the details.So if you read the articles above, you will know we have many many ways to achieve today's topic. Otherwise, in this article I'd like to share the best practice of asy 阅读全文
posted @ 2013-06-07 21:13 DebugLZQ 阅读(373) 评论(0) 推荐(0) 编辑
摘要:Original posted byJenni KonradonJan 20, 2012Red Gate recently introduced .NET Demon, a new extension that continuously tests and compiles code in the background in Visual Studio.In order to support continuous compilation, .NET Demon replaces Visual Studio's build system. To make this process fas 阅读全文
posted @ 2013-05-31 19:46 DebugLZQ 阅读(293) 评论(0) 推荐(0) 编辑
摘要:FxCop和StyleCop相似都是用来约束我们编码规范的,关于这两者以及VS自带的Code Analysis的区别可以参考DebugLZQ前面的博文。两者的安装过程非常简单,直接从网上下载这两个Cop的安装文件,按照默认设置安装即可。StyleCop安装文成后,我们就可以在VS的解决方案或是单个文件的任何位置右击使用,其默认已经集成到VS中。如下图所示。而FxCop安装完成后,并没有默认继承到VS中,安装完成后,如下:当然,我们可以运行这个“红绿灯”,新建一个FxCop Project,然后加载相应Project(编译成的exe、dll等),Analyze如下:更好的作法是,将FxCop集成 阅读全文
posted @ 2013-05-23 19:39 DebugLZQ 阅读(1395) 评论(0) 推荐(0) 编辑
摘要:Here I'm going to clarify the difference between FxCop and StyleCop and Analysis. The main reason I'm writing this post is to give a professional answer to the question about the relationship of the above three. As I'm a little bit green of the toolsI work out this artical mainly using r 阅读全文
posted @ 2013-05-22 22:39 DebugLZQ 阅读(1927) 评论(2) 推荐(0) 编辑
摘要:什么是类?将某类东西归纳在一起,可以成为一个类。类有很多种提炼角度,需要根据系统地目标、业务的场景,选取合适的角度对事物进行归纳。什么是类图?类图可能是UML中使用的最多的一种图。和其他图一样,类图的基本语法并不复杂,可能一两天就能掌握,但是真正做到灵活的使用类图,可能需呀多年的功力。类图是锻炼OOA(OO Analysis)和OOD(OO Design)思想的重要工具,有助于OOA、OOD思想的提升。本篇博文,重点讲述类图中类与类之间的关系以及这种关系在代码中的实现形式。写作本文的原因是:网上关于UML类图的语法规则等的资料很多,但是涉及到关系在代码中实现形式的文章却很少。这是很容易理解的: 阅读全文
posted @ 2013-05-13 22:40 DebugLZQ 阅读(10726) 评论(4) 推荐(3) 编辑
摘要:IntroductionHere I am going to discuss Liskov substitution principleof SOLID.BackgroundIf you read my previous two articles it will be better for you to understand SRP,OCP,ISP,DIP of SOLID.Understanding Open Closed Principle and Dependency InversionUnderstanding Single Responsibility and Interface S 阅读全文
posted @ 2013-05-12 12:46 DebugLZQ 阅读(267) 评论(0) 推荐(0) 编辑
摘要:IntroductionIn the previous onearticle,DebugLZQ discussed OCP(Open Closed Principle)and DIP(Dependency InversionPrinciple) of SOLID.Here I am going to discuss SRP(Single Responsibility Principle)and ISP(Interface Segregation Principle) of SOLID.BackgroundIf you read the previous one article it will 阅读全文
posted @ 2013-05-11 17:23 DebugLZQ 阅读(465) 评论(0) 推荐(0) 编辑
摘要:IntroductionIn the following three articles I'm going to discuss SOLID.This is the Part One of the series.I'll try to explain Open Colsed Priciple and Dependency Inversion.Now what does SOLID mean? SOLID is the OOD(Object-Orient Design) Principle,where each letter has its own meanS->Singl 阅读全文
posted @ 2013-05-10 17:22 DebugLZQ 阅读(868) 评论(0) 推荐(0) 编辑
摘要:前面的博文:WPF拖动总结中DebugLZQ遇到的问题是:DebugLZQ给容器中所有UI控件注册一个MouseLeftButton事件,Button控件无法捕获这儿事件的问题,加个断点看下,程序根本不到达这个地方。当时只是简短的提了一下,觉得不够,因此决定再发一篇博文来说一下。foreach (UIElement uiEle in LayoutRoot.Children){ uiEle.MouseMove += new MouseEventHandler(Element_MouseMove); uiEle.MouseLeftButtonDown += new MouseButtonE... 阅读全文
posted @ 2013-05-09 16:45 DebugLZQ 阅读(2785) 评论(3) 推荐(2) 编辑
摘要:这篇博文总结下WPF中的拖动,文章内容主要包括:1.拖动窗口2.拖动控件 Using Visual Studio 2.1thumb控件 2.2Drag、Drop(不连续,没有中间动画) 2.3拖动一个控件 2.4让一个窗口内的所有(指定的)控件可拖动3.Expression Blend X实现拖动(Best Practice)Update: Move and resize controls on a form at runtime (with drag and drop)小结1.拖动窗口 我们知道,鼠标放在窗口的标题栏上按下就可以拖动窗体。我们要实现在窗口的全部地方或特定地方按下鼠标左... 阅读全文
posted @ 2013-05-07 16:27 DebugLZQ 阅读(39587) 评论(8) 推荐(19) 编辑
摘要:今天DebugLZQ在做WPF拖动总结的时候,遇到了这个问题。baidu了下,貌似没有解决这个问题的权威答案,遂写下这篇博文。我想做的事情是:拖动一个窗体内的控件(Rectangle)到另一个容器控件内,而保留原来的控件。为了更好地把问题说清楚,请看如下代码片段:void canvas1_Drop(object sender, DragEventArgs e){ IDataObject data = new DataObject(); data = e.Data; if (data.GetDataPresent(typeof(Rectangle))) { Rectan... 阅读全文
posted @ 2013-05-06 11:08 DebugLZQ 阅读(8113) 评论(8) 推荐(6) 编辑
摘要:前面的一篇博文DebugLZQ使用三层架构实现了TaskVision,并在后面利用Webservice代替ClassLibrary实现SQL Server 2008数据库操作提供程序。关于三层架构的理解请参考前一篇博文。写这篇博文的目的在于,强调我前面一篇博文中提到但是今天又遇到且花了我一定时间去解... 阅读全文
posted @ 2013-05-01 12:10 DebugLZQ 阅读(4101) 评论(1) 推荐(1) 编辑
摘要:前言: 关于不同框架实现同一个TaskVision:前面DebugLZQ先是用WPF(没有使用MVVM,因为前面使用MVVM实现过过点餐系统),因而这个关键点就放在了WPF的Binding上面;然后用普通的Winform,没有加入任何模式,实现了相同的功能。因此这个重点放在了DataGridView... 阅读全文
posted @ 2013-04-30 21:45 DebugLZQ 阅读(5374) 评论(2) 推荐(6) 编辑
摘要:本文给出一个Functional Programming和Lazy Code的一个例子。跟着思路走,关键的地方会有相应的说明。我们想实现一个判断"素数"的小程序,如下:using System;namespace FunctionalProgramming{ class Program ... 阅读全文
posted @ 2013-03-28 22:23 DebugLZQ 阅读(294) 评论(0) 推荐(0) 编辑