摘要: //注意:密钥必须为8位 private const string m_strEncryptKey = "abcd1234"; /// /// 加密字符串 /// /// 明码 /// 加密后的密码 ... 阅读全文
posted @ 2014-04-21 13:41 遥远的守望 阅读(215) 评论(0) 推荐(0) 编辑
摘要: Android 4.0 后 貌似规定了 在主线程中不允许访问网络,在子线程中不允许修改UI. 否则会抛出NetworkOnMainThreadException 异常解决办法:采用继承AsyncTask实现AsyncTask中定义的几个方法onPreExecute()doInBackground(Params...)onProgressUpdate(Progress...)onPostExecute(Result)onCancelled()注意:Task的实例必须在UI 线程中创建execute方法必须在UI 线程中调用 1 private class MyTask extends Asyn. 阅读全文
posted @ 2014-01-23 17:40 遥远的守望 阅读(361) 评论(0) 推荐(0) 编辑
摘要: web Service 三种基本元素: SOAP 、WSDL 、UDDI什么是SOAP: XML+HTTP 基本的Web Service平台 SOAP 简易对象访问协议 ,是一宗用于发送消息的格式,独立于平台,独立于语言,基于XML什么是WSDL: WSDL是基于XML的用于描述Web Service以及如何访问Web Service的语言 WSDL 网络服务描述语言,使用XML编写什么是UDDI: UDDI是一种目录服务 UDDI指通用的描述、发现以及整合,用于存储有关Web Service的信息的目录,由WSDL描述的网络服务接口目录,精SOAP进行通讯 阅读全文
posted @ 2013-12-31 10:04 遥远的守望 阅读(232) 评论(0) 推荐(0) 编辑
摘要: TDD的三个阶段红灯、绿灯、重构 :明确了实施TDD所要遵循的工作流 (需求--->测试-->代码[重构])红灯阶段: 为不存在的代码编写测试绿灯阶段: 仅编写适量的代码以通过测试重构阶段: 重构代码,考虑其可维护性、可读性或代码整体质量 重构测试,对测试进行维护,保持其整洁性 阅读全文
posted @ 2013-12-30 17:32 遥远的守望 阅读(285) 评论(0) 推荐(0) 编辑
摘要: OOP 封装 继承 多态SOLID SRP 单一职责 Single Responsibility Principle OCP 开放封闭 Open/Close Principle LSP 里氏替换 Liskov Substitution Principle ISP 接口分离 Interface Segregation Principle DIP 依赖倒置 Dependency Inversion Principle 阅读全文
posted @ 2013-12-30 17:19 遥远的守望 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 用多态替换条件 3中交通工具public class Car : Vehicle{ public int AmountOfFuelNeededToFillTank() { return 12; }}public class Airplane : Vehicle{ public int AmountOfFuelNeededToFillLeftFuelTank() { return 3; } public int AmountOfFuelNeededToFillRightFuelTank() { retur... 阅读全文
posted @ 2013-12-27 15:40 遥远的守望 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 封装字段public class Widget{ private object _internalWidgetState; public string _widgetModelNumber;}将成员变量封装在一个字段中public class Widget{ private object _internalWidgetState; public string ModelNumber {get; private set;}} 阅读全文
posted @ 2013-12-27 15:07 遥远的守望 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 重命名变量、字段、方法和类public double GetValue(int a,int b){ var answer=(a*a)*b*p; return answer;}同一方法,采用合适的名称命名变量:public double GetVolumeOfACylinder(int radius,int height){ var volumeofACylinder=(radius*radius)*height*Pi; return volumeofACylinder;} 阅读全文
posted @ 2013-12-27 15:02 遥远的守望 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Try/Catch 块过多public Customer GetCustomer(string customerId){ try { var command = new SqlCommand(); var reader = command.ExecuteReader(); var customer = new Customer(); while(reader) { customer.customerId=customerId; customer.CustomerNam... 阅读全文
posted @ 2013-12-27 14:45 遥远的守望 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 析取方法public string PlaceOrderForWidgets(int quantity,string customerNumber){ var invoice=new Invoice { InvoiceNumber=Guid.NewGuid().ToString(), TotalPrice=PricePerWidget*quantity, Quantity=quantity }; var customer=_customerService.GetCustomer(customerNumber); invoice.CustomerN... 阅读全文
posted @ 2013-12-27 14:28 遥远的守望 阅读(213) 评论(0) 推荐(0) 编辑