统计

留言簿(1)

DB

Others

QA

Tech Website

阅读排行榜

评论排行榜

2010年12月13日 #

【转载】自动化测试体系整体解决方案探讨

     摘要:  一个完整的自动化测试框架体系包含以下几个部分:1、自动化测试框架;2、测试脚本以及测试数据管理;3、测试脚本的执行管理系统;4、测试结果的显示与分析系统。其中最重要的是自动化测试框架部分。  阅读全文

posted @ 2011-08-30 18:59 XXXXXX 阅读(324) | 评论 (0)编辑 收藏

Java开源测试工具

     摘要: JUnit

JUnit是由 Erich Gamma 和 Kent Beck 编写的一个回归测试框架(regression testing framework)。Junit测试是程序员测试,即所谓白盒测试,因为程序员知道被测试的软件如何(How)完成功能和完成什么样(What)的功能。Junit是一套框架,继承TestCase类,就可以用Junit进行自动测试了。
更多JUnit信息  阅读全文

posted @ 2011-08-30 17:29 XXXXXX 阅读(333) | 评论 (0)编辑 收藏

Linux Directory Structure (File System Structure) Explained with Examples

     摘要: Have you wondered why certain programs are located under /bin, or /sbin, or /usr/bin, or /usr/sbin?
For example, less command is located under /usr/bin directory. Why not /bin, or /sbin, or /usr/sbin? What is the different between all these directories?
In this article, let us review the Linux filesystem structures and understand the meaning of individual high-level directories  阅读全文

posted @ 2011-08-29 11:41 XXXXXX 阅读(1829) | 评论 (1)编辑 收藏

【转】互联网产品开发中的“快”字诀

     摘要: 当今互联网的发展,已不是大鱼吃小鱼的时代,而是快鱼吃慢鱼的时代。互联网产品的制胜原则就是一个字——“快”。在各种形态的产品研发中,我们始终贯彻如一的价值观之一就是“快”,我们应该如何来理解和诠释“快”?又会从哪些方面来执行贯彻这个原则呢?  阅读全文

posted @ 2011-08-28 23:47 XXXXXX 阅读(310) | 评论 (0)编辑 收藏

【转载】软件测试的十二个误区

     摘要: 软件测试的十二个误区大体总结如下:

1) 测试人员不需要了解软件开发的知识:
这个很要命的,我们谈到软件测试人员未来的发展方向大致有:自动化测试,性能测试,测试管理,项目经理。这其中自动化测试和性能测试包括项目管理,都会要求对软件开发有深入的理解,如何能设计一个好的自动化框架,好的性能测试用例,如何管理一个开发团队,这都需要我们在软件开发方面有所掌握。不单要掌握,而且要精通。此其一。
其二:如果不了解开发知识,测试人员很容易被开发人员牵着鼻子走,因为开发人员随便一忽悠,你如果不了解个中奥妙,你一个字也说不上来。(以前我们讨论 Cookie和Session,由于GoAhead不支持Session,只能用Cookie来控制,差点别开发人员忽悠了)  阅读全文

posted @ 2011-08-23 13:25 XXXXXX 阅读(370) | 评论 (0)编辑 收藏

【转】Painless threading

     摘要: 写在前面:写Android程序有一个很重要的原则,不阻塞UI线程。因此Android提供了5种方法来,让一些耗时的作业在其它线程中执行,然后把结果返回给UI线程,以免阻塞UI线程。  阅读全文

posted @ 2011-08-23 09:25 XXXXXX 阅读(339) | 评论 (0)编辑 收藏

Heuristics of Software Testability

探讨了软件测试的可测试性,主要包括Controllability, Observability, Availability,Simplicity, Stability 和 Information.


HeuristicsOfSoftwareTestability.pdf

posted @ 2011-08-19 23:24 XXXXXX 阅读(1367) | 评论 (0)编辑 收藏

【转】selector in Android

     摘要: android的selector的用法:
首先android的selector是在drawable/xxx.xml中配置的。
先看一下listview中的状态:
把下面的XML文件保存成你自己命名的.xml文件(比如list_item_bg.xml),在系统使用时根据ListView中的列表项的状态来使用相应的背景图片。drawable/list_item_bg.xml  阅读全文

posted @ 2011-08-16 23:12 XXXXXX 阅读(265) | 评论 (0)编辑 收藏

UI/Application Exerciser Monkey

     摘要: The Monkey is a command-line tool that that you can run on any emulator instance or on a device. It sends a pseudo-random stream of user events into the system, which acts as a stress test on the application software you are developing.

The Monkey includes a number of options, but they break down into four primary categories:

Basic configuration options, such as setting the number of events to attempt.
Operational constraints, such as restricting the test to a single packag  阅读全文

posted @ 2011-08-13 10:14 XXXXXX 阅读(488) | 评论 (0)编辑 收藏

【转】Python的标准logging模块

     摘要: Programmers can configure logging either by creating loggers, handlers, and formatters explicitly in a main module with the configuration methods listed above (using Python code), or by creating a logging config file. The following code is an example of configuring a very simple logger, a console handler, and a simple formatter in a Python module:

  阅读全文

posted @ 2011-08-12 14:49 XXXXXX 阅读(1196) | 评论 (0)编辑 收藏

Android Debug Bridge

     摘要:   阅读全文

posted @ 2011-08-11 13:22 XXXXXX 阅读(877) | 评论 (0)编辑 收藏

【转】Linux IPC


一)Linux环境进程间通信(一)管道及有名管道
http://www.ibm.com/developerworks/cn/linux/l-ipc/part1/

二)Linux环境进程间通信(二): 信号
上:http://www.ibm.com/developerworks/cn/linux/l-ipc/part2/index1.html
下:http://www.ibm.com/developerworks/cn/linux/l-ipc/part2/index2.html

三)Linux环境进程间通信(三)消息队列
http://www.ibm.com/developerworks/cn/linux/l-ipc/part3/

四)Linux环境进程间通信(四)信号灯
http://www.ibm.com/developerworks/cn/linux/l-ipc/part4/

五)Linux环境进程间通信(五): 共享内存
上:http://www.ibm.com/developerworks/cn/linux/l-ipc/part5/index1.html
下:http://www.ibm.com/developerworks/cn/linux/l-ipc/part5/index2.html

posted @ 2011-07-31 08:53 XXXXXX 阅读(226) | 评论 (0)编辑 收藏

【转】深入理解Android消息处理系统

     摘要: Android系统中Looper负责管理线程的消息队列和消息循环,具体实现请参考Looper的源码。 可以通过Loop.myLooper()得到当前线程的Looper对象,通过Loop.getMainLooper()可以获得当前进程的主线程的Looper对象。  阅读全文

posted @ 2011-07-29 11:53 XXXXXX 阅读(246) | 评论 (0)编辑 收藏

Glossary of Android

     摘要: The list below defines some of the basic terminology of the Android platform.

.apk file
Android application package file. Each Android application is compiled and packaged in a single file that includes all of the application's code (.dex files), resources, assets, and manifest file. The application package file can have any name but must use the .apk extension. For example: myExampleAppname.apk. For convenience, an application package file is often referred to as an ".apk".
Re  阅读全文

posted @ 2011-07-25 11:42 XXXXXX 阅读(292) | 评论 (0)编辑 收藏

Manifest.permission Summary

     摘要:   阅读全文

posted @ 2011-07-24 15:15 XXXXXX 阅读(682) | 评论 (0)编辑 收藏

Special Methods for Customizing Classes

     摘要: C.__init__(self[, arg1, ...] )
Constructor (with any optional arguments)

C.__new__(self[, arg1, ...] )[a]
Constructor (with any optional argu ments); usually used for setting up subclassing of immutable data types

C.__del__(self)
Destructor

C.__str__(self)
Printable string representation; str() built-in and print statement

C.__repr__(self)
Evaluatable string representation; repr() built-in and '' operator

  阅读全文

posted @ 2011-07-21 23:25 XXXXXX 阅读(234) | 评论 (0)编辑 收藏

【转】再谈Yahoo关于性能优化的N条军规

     摘要: 本来这是个老生常谈的问题,上周自成又分享了一些性能优化的建议,我这里再做一个全面的Tips整理,谨作为查阅型的文档,不妥之处,还请指正;
如果你已经对yahoo这些优化建议烂熟于心,果断点这里

  阅读全文

posted @ 2011-07-21 09:21 XXXXXX 阅读(198) | 评论 (0)编辑 收藏

【转】Choosing a test automation framework


Five test auomation framework are discussed in this paper.
1) The Test Script Modularity Framework
2) The Test Library Architecture Framework
3) The Keyword-Driven or Table-Driven Testing Framework
4) The Data-Driven Testing Framework
5) The Hybrid Test Automation 

posted @ 2011-07-15 22:30 XXXXXX 阅读(288) | 评论 (0)编辑 收藏

ASE入门

     摘要: 一、ASE(Android Scripting Environment)为Android系统带来了脚本语言的技术,通过它我们可以编辑和执行脚本,和脚本解释交互。脚本可以访问多数Android API,目前有一个开源项目叫做Scripting Layer for Android (SL4A) ,提供了对python,javaScript, Lua等脚本的支持。ASE主要通过两种方式来访问 Android API,一种是通过JSON-RPC来访问,另外一种通过BeanShell(Java语言的动态版本)直接访问Android API。SL4AL架构如下图:  阅读全文

posted @ 2011-07-10 10:08 XXXXXX 阅读(2588) | 评论 (0)编辑 收藏

获取Android的Java源代码并在Eclipse中关联查看的最新方法

感谢一网友做出的努力,具体请看:http://618119.com/archives/2011/01/01/201.html

posted @ 2011-07-09 09:38 XXXXXX 阅读(220) | 评论 (0)编辑 收藏

【转】Android 2.1 源码结构分析

     摘要:   阅读全文

posted @ 2011-07-09 09:37 XXXXXX 阅读(235) | 评论 (0)编辑 收藏

Android Coding for Life-Battery Life

关于Android编程中如果省电的讲解

可以作为开发者的参考 :)

posted @ 2011-07-08 09:37 XXXXXX 阅读(1544) | 评论 (0)编辑 收藏

【转】Java学习的30个目标以及系统架构师推荐的书

     摘要: 2.你需要学习JAVA语言的基础知识以及它的核心类库 (collections,serialization,streams,networking, multithreading,reflection,event,handling,NIO,localization,以及其他)。  阅读全文

posted @ 2011-06-18 15:25 XXXXXX 阅读(668) | 评论 (1)编辑 收藏

学习Python的好网站

1)http://www.pythonchallenge.com/
  提供了不同level的Python题目,非常有趣的题目。做完一题后,把URL中的pc改为pcc可以看到上一题的答案

2)http://projecteuler.net/
  里面有200多道题目,不要要求提交代码,只要最终答案,提供用各种语言来解决问题。这里(http://dcy.is-programmer.com/posts/8750.html)有部分题目的答案

非常好玩,有兴趣的朋友,快来试试吧

看看 project euler 的第一道题:

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.

用 python 语言写出来是:

 

print sum(i for i in xrange(11000if i % 3 == 0 or i % 5 == 0)

 


 

posted @ 2011-06-17 20:26 XXXXXX 阅读(4365) | 评论 (2)编辑 收藏

Dom4j解释XML示例

     摘要:   阅读全文

posted @ 2011-06-15 17:53 XXXXXX 阅读(348) | 评论 (0)编辑 收藏

【转】《InfoQ Explores: REST》介绍

This is the first edition of what is expected to become a recurring series on InfoQ. The idea behind this minibook is that a number of InfoQ articles and interviews which deal with a particular topic (in this case, REpresentational State Transfer, or REST) are combined together to provide a detailed exploration suitable for both beginners and advanced practitioners.

Read More: http://www.infoq.com/minibooks/emag-03-2010-rest;jsessionid=1E2375E822D980824403DAD46588FAFE

posted @ 2011-06-15 12:39 XXXXXX 阅读(232) | 评论 (0)编辑 收藏

Python中的Closure


#定义:如果在一个内部函数里,对在外部作用域(但不是在全局作用域)的变量进行引用,那么内部函数就被认为是闭包(closure)
分解来说,包含下面3个条件:
1) 需要函数嵌套, 就是一个函数里面再写一个函数.
2) 外部函数需要返回一个内部函数的引
3) 外部函数中有一些局部变量, 并且, 这些局部变量在内部函数中有使用
一些概念:
1)自由变量: 外部函数中定义的局部变量, 并且在内部函数中被使用
2) 闭包: 那个使用了自由变量并被返回的内部函数就称为闭包

#支持闭包的语言有这样的特性:
1)函数是一阶值(First-class value),即函数可以作为另一个函数的返回值或参数,还可以作为一个变量的值
2)函数可以嵌套定义,即在一个函数内部可以定义另一个函数

#代码示例

 1def counter(start_at=0):
 2    count = [start_at]
 3    def incr():
 4        count[0] += 1   #对局部变量的引用
 5        return count[0]
 6    return incr  #返回一个函数对象
 7
 8
 9if __name__ == '__main__':
10    c = counter(3)
11    print type(c)
12    print c()
13    print c()
14


 

posted @ 2011-06-15 07:31 XXXXXX 阅读(1291) | 评论 (0)编辑 收藏

Trie Tree

     摘要: #Trie Tree的基本特点
1)根节点不包含字符,除根节点外每个节点只包含一个字符
2)从根节点到某一个节点,路径上经过的字符连接起来,为该节点对应的字符串

3)每个节点的所有子节点包含的字符串不相同
  阅读全文

posted @ 2011-06-14 16:57 XXXXXX 阅读(1061) | 评论 (0)编辑 收藏

Bloom Filter

     摘要: The Bloom filter, conceived by Burton Howard Bloom in 1970, is a space-efficient probabilistic data structure that is used to test whether an element is a member of a set.False positivesare possible, but false negatives are not. Elements can be added to the set, but not removed (though this can be addressed with a counting filter). The more elements that are added to the set, the larger the probability of false positives
  阅读全文

posted @ 2011-06-12 23:58 XXXXXX 阅读(281) | 评论 (0)编辑 收藏

【转】How Google Tests Software - A Brief Interlude

     摘要: These posts have garnered a number of interesting comments. I want to address two of the negative ones in this post. Both are of the same general opinion that I am abandoning testers and that Google is not a nice place to ply this trade. I am puzzled by these comments because nothing could be further from the truth. One such negative comment I can take as a one-off but two smart people (hey they are reading this blog, right?) having this impression requires a rebuttal. Here are the comments:  阅读全文

posted @ 2011-06-06 16:03 XXXXXX 阅读(291) | 评论 (0)编辑 收藏

【转】How Google Tests Software - Part Six

     摘要:   阅读全文

posted @ 2011-06-04 16:08 XXXXXX 阅读(224) | 评论 (0)编辑 收藏

【转】How Google Tests Software - Part Seven

     摘要:   阅读全文

posted @ 2011-06-04 16:08 XXXXXX 阅读(245) | 评论 (0)编辑 收藏

【转】How Google Tests Software - Part Five

     摘要:   阅读全文

posted @ 2011-06-04 15:54 XXXXXX 阅读(275) | 评论 (0)编辑 收藏

【转】How Google Tests Software - Part Four

     摘要: One of the key ways Google achieves good results with fewer testers than many companies is that we rarely attempt to ship a large set of features at once. In fact, the exact opposite is often the goal: build the core of a product and release it the moment it is useful to as large a crowd as feasible, then get their feedback and iterate. This is what we did with Gmail, a product that kept its beta tag for four years. That tag was our warning to users that it was still being perfected. We removed   阅读全文

posted @ 2011-06-04 15:43 XXXXXX 阅读(241) | 评论 (0)编辑 收藏

【转】How Google Tests Software - Part Three

     摘要: Lots of questions in the comments to the last two posts. I am not ignoring them. Hopefully many of them will be answered here and in following posts. I am just getting started on this topic.  阅读全文

posted @ 2011-06-04 10:44 XXXXXX 阅读(270) | 评论 (0)编辑 收藏

【转】How Google Tests Software - Part Two

     摘要:   阅读全文

posted @ 2011-06-02 11:00 XXXXXX 阅读(256) | 评论 (0)编辑 收藏

Android好文章

     摘要:   阅读全文

posted @ 2011-06-01 15:17 XXXXXX 阅读(199) | 评论 (0)编辑 收藏

【转】Avoiding Memory Leaks

     摘要: Android applications are, at least on the T-Mobile G1, limited to 16 MB of heap. It's both a lot of memory for a phone and yet very little for what some developers want to achieve. Even if you do not plan on using all of this memory, you should use as little as possible to let other applications run without getting them killed. The more applications Android can keep in memory, the faster it will be for the user to switch between his apps. As part of my job, I ran into memory leaks issues in Andr  阅读全文

posted @ 2011-06-01 14:52 XXXXXX 阅读(323) | 评论 (0)编辑 收藏

【转】Android = Java ?

     摘要: The Java community is now swamped with discussions about Oracle's patent suit against Google's Android platform. I've been contributing my opinion in several places, but there is one critical topic that needs repeating the same comments everywhere... so, this blog spills the beans once and completely.  阅读全文

posted @ 2011-05-31 11:06 XXXXXX 阅读(533) | 评论 (0)编辑 收藏

Activity Lifecycle

     摘要: Activities in the system are managed as an activity stack. When a new activity is started, it is placed on the top of the stack and becomes the running activity -- the previous activity always remains below it in the stack, and will not come to the foreground again until the new activity exits.  阅读全文

posted @ 2011-05-31 09:31 XXXXXX 阅读(270) | 评论 (0)编辑 收藏

【转】How google test software-part one

     摘要: The one question I get more than any other is "How does Google test?" It's been explained in bits and pieces on this blog but the explanation is due an update  阅读全文

posted @ 2011-05-30 08:10 XXXXXX 阅读(685) | 评论 (0)编辑 收藏

【转】To new or not to new

     摘要: Dependency injection asks us to separate the new operators from the application logic. This separation forces your code to have factories which are responsible for wiring your application together. However, better than writing factories, we want to use automatic dependency injection such as GUICE to do the wiring for us. But can DI really save us from all of the new operators?  阅读全文

posted @ 2011-05-29 10:20 XXXXXX 阅读(242) | 评论 (1)编辑 收藏

【转】How to think about OO

     摘要: Everyone seems to think that they are writing OO after all they are using OO languages such as Java, Python or Ruby. But if you exam the code it is often procedural in nature  阅读全文

posted @ 2011-05-29 09:48 XXXXXX 阅读(267) | 评论 (1)编辑 收藏

【转】The SET Career Path

By James Whittaker

I’ve had a number of questions about the SET role and it seems I have confused folks when I say that the SWE is a tester and the SET is a tester and at the same time the SWE is a developer and the SET is a developer. What could possibly be confusing about that?

Oh, yeah. Right.

My next series of posts are going to detail the role of the SET and all will eventually be clear but some clarification on career path seems worthwhile.

SETs are developers who write test code and automation as their primary task. They are in every sense of the word a developer. When we interview SETs, SWEs are on the interview loop and SWE questions are asked. They are not all of the interview, but they are part of it.

This means that the skill set that our SETs possess makes them perfect candidates for switching to the SWE role. There is neither incentive nor deterrent to do so. SETs and SWEs are on the same pay scale and bonus structure (I have both roles reporting to me so I have real visibility into salary data) and their promotion velocity (again based on actual data) is roughly equivalent. This means that SETs have no outside influences to prompt them one way or the other.

The key factor is really the type of work you are doing. SETs who find themselves involved in SWE work usually convert to SWE. SWEs are also drawn in the opposite direction. Much of this happens through our 20% time work. Any SET interested in SWE work can take on a 20% task doing feature development. Any SWE interested in automation can find a group and sign up for a 20%. Right now I have both SWEs and SETs involved in such cross pollination.

The ideal situation is that the title reflects the actual work that you are involved in. So if an SET starts doing more feature dev work than automation, he or she should convert, same for SWEs doing automation work. In my time here, conversions in both directions have happened, but it is not all that common. The work of both roles is engaging, interesting and intense. Few Googlers are walking around bored.

Bottom line: do the work you are passionate about and capable of and the right job title will find you.

posted @ 2011-05-25 00:04 XXXXXX 阅读(264) | 评论 (0)编辑 收藏

Visitor模式和Double Dispatch


一、概念
  静态分派(Static Dispatch),发生在编译时期,分派是根据静态类型信息发生的,方法重载就是静态分派。
  动态分派(Dynamic Dispatch),发生在运行时期,动态分派动态地置换掉某个方法。面向对象的语言用动态分派实现多态性。
  Java语言支持静态多分派和动态的单分派,利用设计模式Java可以实现Double Dispatch,即访问者模式。

二、Visitor Pattern
  目的:封装一些施加于某种数据结构元素之上的操作。
  UML图:
 
   主要原理:“反传球”,Element来Visitor之间二轮调用,调用过程中用sinlge dispatch确定类型


    

posted @ 2011-05-24 16:54 XXXXXX 阅读(1602) | 评论 (1)编辑 收藏

【转】性能测试指标的基本概念

     摘要:   阅读全文

posted @ 2011-05-21 15:04 XXXXXX 阅读(317) | 评论 (0)编辑 收藏

REST-表象化状态转变


记录关于REST的一些技术:

1、REST简介:http://zh.wikipedia.org/zh/REST
2、InfoQ 深入浅出REST:  http://www.infoq.com/cn/articles/rest-introduction

posted @ 2011-05-10 22:07 XXXXXX 阅读(298) | 评论 (0)编辑 收藏

【转】架构就是关注点分离

     摘要: 要设计良好的架构,必须做到关注点分离,这样可以产生高内聚、低耦合的系统,这是美丽架构的终极原则  阅读全文

posted @ 2011-05-10 22:02 XXXXXX 阅读(359) | 评论 (0)编辑 收藏

CyclicBarrier in Java

     摘要: A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point. CyclicBarriers are useful in programs involving a fixed sized party of threads that must occasionally wait for each other. The barrier is called cyclic because it can be re-used after the waiting threads are released.  阅读全文

posted @ 2011-05-07 15:35 XXXXXX 阅读(630) | 评论 (0)编辑 收藏

CountDownLatch in Java

     摘要: A java.util.concurrent.CountDownLatch is a concurrency construct that allows one or more threads to wait for a given set of operations to complete  阅读全文

posted @ 2011-05-07 15:10 XXXXXX 阅读(240) | 评论 (0)编辑 收藏

Multithreaded Servers in Java

文章描述了实现 Multithreaded Servers的3种方法:
1)单线程,性能性差,请求等待时间长
2)多线程,把接受请求和处理请求的线程分开,接受后交给 worker处理
3)线程池,性能最佳,有效地防止负载过重,重复利用线程,请求多时,让请求排队接收处理
4)主要用socket来通信, ServerSocket 和 Socket

具体文章请看:http://tutorials.jenkov.com/java-multithreaded-servers/index.html

posted @ 2011-05-07 09:58 XXXXXX 阅读(162) | 评论 (0)编辑 收藏

【转】探索式测试

     摘要:   阅读全文

posted @ 2011-05-05 22:58 XXXXXX 阅读(248) | 评论 (0)编辑 收藏

回调机制

     摘要: 软件模块之间总是存在着一定的接口,从调用方式上,可以把他们分为三类:同步调用、回调和异步调用。
同步调用是一种阻塞式调用,调用方要等待对方执行完毕才返回,它是一种单向调用,如HTTP;
回调是一种双向调用模式,也就是说,被调用方在接口被调用时也会调用对方的接口;
异步调用是一种类似消息或事件的机制,不过它的调用方向刚好相反,接口的服务在收到某种讯息或发生某种事件时,会主动通知客户方(即调用客户方的接口),如JMS;
  阅读全文

posted @ 2011-04-29 22:36 XXXXXX 阅读(339) | 评论 (0)编辑 收藏

【转】关于多线程编程您不知道的 5 件事

     摘要: 虽然很少有 Java™ 开发人员能够忽视多线程编程和支持它的 Java 平台库,更少有人有时间深入研究线程。相反地,我们临时学习线程,在需要时向我们的工具箱添加新的技巧和技术。以这种方式构建和运行适当的应用程序是可行的,但是您可以做的不止这些。理解 Java 编译器的线程处理特性和 JVM 将有助于您编写更高效、性能更好的 Java 代码  阅读全文

posted @ 2011-04-28 11:59 XXXXXX 阅读(211) | 评论 (0)编辑 收藏

Python设计的核心理念

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

posted @ 2011-04-18 09:10 XXXXXX 阅读(333) | 评论 (0)编辑 收藏

You’ve got to find what you love(By Steve Jobs)

     摘要: This is the text of the Commencement address by Steve Jobs, CEO of Apple Computer and of Pixar Animation Studios, delivered on June 12, 2005.

I am honored to be with you today at your commencement from one of the finest universities in the world. I never graduated from college. Truth be told, this is the closest I’ve ever gotten to a college graduation. Today I want to tell you three stories from my life. That’s it. No big deal. Just three stories.

The first story is about conn  阅读全文

posted @ 2011-04-05 10:34 XXXXXX 阅读(418) | 评论 (0)编辑 收藏

【转】软件构架设计 读书笔记

     摘要: 1. 软件架构概述
1.1 什么是软件架构

◎ 软件架构的概念很混乱。如果你问五个不同的人,可能会得到五种不同的答案。

◎ 软件架构概念主要分为两大流派:
组成派:软件架构 = 组件 + 交互。
决策派:软件架构 = 重要决策集。

◎ 组成派和决策派的概念相辅相成。
  阅读全文

posted @ 2011-04-04 00:08 XXXXXX 阅读(1115) | 评论 (0)编辑 收藏

关系数据库设计范式介绍

     摘要: 所谓第一范式(1NF)是指数据库表的每一列都是不可分割的基本数据项,同一列中不能有多个值,即实体中的某个属性不能有多个值或者不能有重复的属性。如果出现重复的属性,就可能需要定义一个新的实体,新的实体由重复的属性构成,新实体与原实体之间为一对多关系。在第一范式(1NF)中表的每一行只包含一个实例的信息。简而言之,第一范式就是无重复的列。
  阅读全文

posted @ 2011-03-22 20:23 XXXXXX 阅读(450) | 评论 (3)编辑 收藏

不错的Linux性能监控工具--dstat

OS实时监控工具dstat,整合了vmstat, iostat, ifstat, netstat等常见os监控工具的优点,输出的结果简单直观,并且结果可以保存到csv文件。
dokie@ubuntu:~$ dstat
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq
| read  writ| recv  send|  in   out | int   csw 
 
14   5  78   3   0   0| 553k  109k|   0     0 |  83B  989B| 983  2190 
  
8   2  90   0   0   0|   0     0 |2076B 1383B|   0     0 |1076  1407 
  
9   3  89   0   0   0|   0    72k|7530B  420B|   0     0 | 721  1501 
  
9   4  87   0   0   0|   0     0 |9547B  564B|   0     0 | 750  1474 
  
8   2  89   0   0   0|   0     0 |  12k  672B|   0     0 | 772  1681 
  
9   2  89   0   0   0|   0     0 |  13k  792B|   0     0 | 677  1396 


dokie@ubuntu:~$ dstat -h
Usage: dstat [
-afv] [options..] [delay [count]]
Versatile tool 
for generating system resource statistics

Dstat options:
  
-c, --cpu              enable cpu stats
     
-0,3,total           include cpu0, cpu3 and total
  
-d, --disk             enable disk stats
     
-D total,hda           include hda and total
  
-g, --page             enable page stats
  
-i, --int              enable interrupt stats
     
-5,eth2              include int5 and interrupt used by eth2
  
-l, --load             enable load stats
  
-m, --mem              enable memory stats
  
-n, --net              enable network stats
     
-N eth1,total          include eth1 and total
  
-p, --proc             enable process stats
  
-r, --io               enable io stats (I/O requests completed)
  
-s, --swap             enable swap stats
     
-S swap1,total         include swap1 and total
  
-t, --time             enable time/date output
  
-T, --epoch            enable time counter (seconds since epoch)
  
-y, --sys              enable system stats

  
--aio                  enable aio stats
  
--fs                   enable fs stats
  
--ipc                  enable ipc stats
  
--lock                 enable lock stats
  
--raw                  enable raw stats
  
--socket               enable socket stats
  
--tcp                  enable tcp stats
  
--udp                  enable udp stats
  
--unix                 enable unix stats
  
--vm                   enable vm stats

  
-M stat1,stat2         enable external plugins
     
--mods stat1,stat2

  
--list                 list all internal and external plugins

  
-a, --all              equals -cdngy (default)
  
-f, --full             expand -C, -D, -I, -N and -S discovery lists
  
-v, --vmstat           equals -pmgdsc -D total

  
--integer              show integer values
  
--nocolor              disable colors (implies --noupdate)
  
--noheaders            disable repetitive headers
  
--noupdate             disable intermediate updates
  
--output file          write CSV output to file

  delay is the delay in seconds between each update
  count is the number of updates to display before exiting
  The 
default delay is 1 and count is unspecified (unlimited)


常用的命令:dstat -cdlmnpsy
导出为CVS:
dstat -ta --output osstat.csv

posted @ 2011-03-17 00:19 XXXXXX 阅读(783) | 评论 (0)编辑 收藏

Programming config. for Ubuntu

1. 安装JDK 

http://wiki.ubuntu.org.cn/Java%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE

2. 安装Python

  1). apt-get install python

 2). PyDev for eclipse: 

 Name:PyDev,Location:http://pydev.org/updates

  Ref:http://www.cnblogs.com/Realh/archive/2010/10/10/1847251.html

3. 安装dstat--性能监测工具
     apt-get install dstat

posted @ 2011-03-16 19:46 XXXXXX 阅读(203) | 评论 (0)编辑 收藏

【转】淘宝QA Team中的安全测试文章


下面是来自 Taobao QA Team中的安全测试方面的文章,对初学者很有指导意义
安全测试学习笔记系列:
1. http://qa.taobao.com/?p=11352
2.http://qa.taobao.com/?p=11363
3.http://qa.taobao.com/?p=11472
4.http://qa.taobao.com/?p=11479
5.http://qa.taobao.com/?p=11484


------
WEB漏洞攻击之SQL注入:http://qa.taobao.com/?p=11403

 

posted @ 2011-03-15 15:54 XXXXXX 阅读(368) | 评论 (0)编辑 收藏

JavaScript常见事件

     摘要: onabort 当用户中断下载图像时触发。
onactivate 当对象设置为活动元素时触发。
onafterprint 对象所关联的文档打印或打印预览后立即在对象上触发。
onafterupdate 当成功更新数据源对象中的关联对象后在数据绑定对象上触发。
onbeforeactivate new 对象要被设置为当前元素前立即触发。
onbeforecopy 当选中区复制到系统剪贴板之前在源对象触发。
onbeforecut 当选中区从文档中删除之前在源对象触发。
onbeforedeactivate 在 activeElement 从当前对象变为父文档其它对象之前立即触发。
onbeforeeditfocus 在包含于可编辑元素内的对象进入用户界面激活状态前或可编辑容器变成控件选中区前触发。
onbeforepaste 在选中区从系统剪贴板粘贴到文档前在目标对象上触发。
  阅读全文

posted @ 2011-03-09 15:59 XXXXXX 阅读(196) | 评论 (0)编辑 收藏

Java集合框架比较


 

数组类ArrayJava中最基本的一个存储结构。它用于存储一组连续的对象或基本类型的数据。其中的元素的类型必须相同。

Array是最有效率的一 种:

1、效率高,但容量固定且无法动态改变。 Array还有一个缺点是,无法判断其中实际存有多少元素,length只是告诉我们Array的容量。

2Java中有一个Arrays类,专门用来操作Array,提供搜索、排序、复制等静态方法。 equals():比较两个Array是否相等,Array拥有相同元素个数,且所有对应元素两两相等。 fill():将值填入Array中。 sort():用来对Array进行排序。 binarySearch():在排好序的Array中寻找元素。 System.arraycopy()Array的复制。

Java Collections Framework成员主要包括两种类型,即:CollectionMap类型。 Java中提供了CollectionMap接口。其中ListSet继承了Collection接口;VectorArrayList LinkedList三个类实现List接口,HashSetTreeSet实现Set接口,HashTableHashMap TreeMap实现Map接口。由此可见,Java中用8种类型的基本数据结构来实现其Collections Framework;下面分别进行介绍。

Vector:基于ArrayList,性能也就不可能超越Array,并且Vector"sychronized",这个也是VectorArrayList的唯一的区别。

ArrayList:同Vector一样是一个基于Array的,但是不同的是ArrayList不是同步的。所以在性能上要比Vector优越一些,但 是当运行到多线程环境中时,可需要自己在管理线程的同步问题。从其命名中可以看出它是一种类似数组的形式进行存储,因此它的随机访问速度极快。

LinkedListLinkedList不同于前面两种List,它不是基于Array的,所以不受Array性能的限制。它每一个节点(Node 都包含两方面的内容:

1、节点本身的数据(data);

2、下一个节点的信息(nextNode)。所以当对LinkedList做添加,删除动作的时候 就不用像基于ArrayList一样,必须进行大量的数据移动。只要更改nextNode的相关信息就可以实现了所以它适合于进行频繁进行插入和删除操 作。这就是LinkedList的优势。Iterator只能对容器进行向前遍历,而 ListIterator则继承了Iterator的思想,并提供了对List进行双向遍历的方法。

List总结:

1、所有的List中只能容纳单个不同类型的对象组成的表,而不是KeyValue键值对。例如:[ tom,1,c ]

2、所有的List中可以有相同的元素,例如Vector中可以有 [ tom,koo,too,koo ]

3、所有的List中可以有null元素,例如[ tom,null,1 ]

4、基于ArrayListVectorArrayList)适合查询,而LinkedList(链表)适合添加,删除操作

HashSet:虽然SetList都实现了Collection接口,但是他们的实现方式却大不一样。List基本上都是以Array为基础。但是 Set则是在HashMap的基础上来实现的,这个就是SetList的根本区别。HashSet的存储方式是把HashMap中的Key作为Set 对应存储项,这也是为什么在Set中不能像在List中一样有重复的项的根本原因,因为HashMapkey是不能有重复的。HashSet能快速定位 一个元素,但是放到HashSet中的对象需要实现hashCode()方法0

TreeSet则将放入其中的元素按序存放,这就要求你放入其中的对象是可排序的,这就用到了集合框架提供的另外两个实用类Comparable Comparator。一个类是可排序的,它就应该实现Comparable接口。有时多个类具有相同的排序算法,那就不需要重复定义相同的排序算法,只要实现Comparator接口即可。TreeSetSortedSet的子类,它不同于HashSet的根本就是TreeSet是有序的。它是通过SortedMap来实现的。

Set总结:

1Set实现的基础是MapHashMap);

2Set中的元素是不能重复的,如果使用add(Object obj)方法添加已经存在的对象,则会覆盖前面的对象; Set里的元素是不能重复的,那么用什么方法来区分重复与否呢? 是用==还是equals()? 它们有何区别? Set里的元素是不能重复的,即不能包含两个元素e1e2e1.equalse2))。那么用iterator()方法来区分重复与否。 equals()是判读两个Set是否相等。==方法决定引用值(句柄)是否指向同一对象。

HashMapTreeMapHashtable

1HashMap也用到了哈希码的算法,以便快速查找一个键,TreeMap则是对键按序存放,因此它有一些扩展的方法,比如 firstKey(),lastKey()等。

2Hashtable:不允许空(null)键(key)或值(value),Hashtable的方法是Synchronize的,在多个线程访问 Hashtable时,不需要自己为它的方法实现同步,而HashMap 就必须为之提供外同步。 HashtableHashMap采用的hash/rehash算法都大概一样,所以性能不会有很大的差异。

3HashMapHashtable的区别:HashMapHashtable(线程案例的)的轻量级实现(非线程安全的实现),他们都完成了Map接口。主要区别在于HashMap允许空(null)键key)或值(value,非同步,由于非线程安全,效率上可能高于Hashtable

Map总结:

是一种把键对象和值对象进行关联的容器,Map有两种比较常用的实现: HashTableHashMapTreeMap

posted @ 2011-03-07 14:25 XXXXXX 阅读(1560) | 评论 (0)编辑 收藏

MySQL出错信息表查询

     摘要: 1005:创建表失败 1006:创建数据库失败 1007:数据库已存在,创建数据库失败 1008:数据库不存在,删除数据库失败 1009:不能删除数据库文件导致删除数据库失败 1010:不能删除数据目录导致删除数据库失败 1011:删除数据库文件失败 1012:不能读取系统表中的记录 1020:记录已被其他用户修改 1021:硬盘剩余空间不足,请加大硬盘可用空间...  阅读全文

posted @ 2011-03-05 20:40 XXXXXX 阅读(14497) | 评论 (0)编辑 收藏

一位资深经理人的职业生涯感悟

     摘要: 序言      在担任公司高管的几年间,我面试过数以百计的各个层面的员工,其中最让我感到遗憾的一个现象就是很多人有着非常好的素质,甚至有的还是名校的毕业生,因为不懂得去规划自己的职业,在工作多年后,依然拿着微薄的薪水,为了一份好一点的工作而奔波。很多这样的人,他们只要稍微修正一下自己的职业方向,就能够在职业发展上走得更从容。      有一次一个大连理工大学的研究生,好像是学电子的...  阅读全文

posted @ 2011-03-05 15:37 XXXXXX 阅读(969) | 评论 (1)编辑 收藏

软件测试的常阅博客


国外:

BJ Rolison (I.M.Testy)   http://blogs.msdn.com/imtesty
BJ是微软负责EE工作的Test Architecture,也是HWTSaM的作者。他的文章非常有条理,看起来也比较容易,其中的数据也非常丰富,是我喜欢的风格。

Alan Page  http://blogs.msdn.com/alanpa/ 
Alan是微软负责EE工作的Director,是HWTSaM的主要作者,他的博客是了解微软测试非常好的一个窗口。最近几年,他不限于测试技术的推广,他更多的考虑是测试管理,以及测试氛围/文化的形成,以及对于测试的影响。我很同意他的一句话“95%的UI自动化测试都是浪费时间”详情。他的博客文章比较随意,有时也不知道他在唠叨些什么,但不时却有很多精彩的观点。

Google Test Blog http://googletesting.blogspot.com
这是Google官方的测试博客,信息量很少,除了每年一次的Google Automation Test Conference之外,文章较少。今年6月,James Whittaker离开微软,加入Google后,才到这里增加不少好文章。

James Bach的博客  http://www.satisfice.com/blog/ 
James是一个软件测试的资深人士,90年代曾在Apple和Boland公司���过测试管理工作,后来在其他一些公司负责测试流程和质量管理,2000年自己创办了satisfice测试咨询公司,提供软件质量保证相关的咨询和培训. 他和Cem Kaner撰写了很多Explorary Testing相关的文章和书籍,并且提出了Context-Driven-Testing,这些方法论很适合现在的Agile Testing的特点。

Adam Goucher的博客  http://adam.goucher.ca/ 
一个多产高质的测试写作专家,基本上每个月都有10多篇关于测试的文章,有时候一天写了多篇,真是非常佩服他的写作能力。他的思想很有深度,对软件测试各个方面都有全面的理解,他阅读了几乎所有新出的测试书籍,并且些了与其相关的评论。这些评论通常非常尖锐。比如说,HWTSaM的评论,他的评论就比较中肯。对James Whittalkes的 Exploratory Testing评论 却是嗤之以鼻。 


软件测试杂文集:http://blogs.msdn.com/b/cheno/

文章转自:http://www.cesoo.com/

posted @ 2011-03-05 12:16 XXXXXX 阅读(188) | 评论 (0)编辑 收藏

Java设计模式总结

一、写在前面
        刚开学,趁着有时间把设计模式重新整理一次。学好设计模式是走向架构的第一步,系统架构应该朝着可维护,可扩展,强壮性好的方向去发展。大学的最后一个学期了,时间不多了,3月初就要去腾讯实习了,还有毕设。加油 :)

二、常见的模式分类
 

创建模式

结构模式

行为模式

简单工厂模式

适配器模式

不变模式

工厂方法模式

缺省适配模式

策略模式

抽象工厂模式

合成模式

模版方法模式

单例模式

装饰模式

观察者模式

多例模式

代理模式

迭代子模式

建造模式

享元模式

责任链模式

原始模型模式

门面模式

命令模式

桥梁模式

备忘录模式

状态模式

访问者模式

解释器模式

调停者模式



三、主要模式的定义和描述
以下内容来自《head first 设计模式》一书
 

模式

定义

描述

装饰者

动态地将责任附加到对象上。若要扩展功能,装饰者提供了比继承更有弹性的替代方案

包装一个对象,以提供新的行为

状态

允许对象在内部状态改变时改变它的行为,对象看起来好像修改了它的类

封装了基本状态的行为,并使用委托在行为之间切换

迭代器

提供一种方法顺序访问一个聚合对象中的各个元素,而又不暴露其内部的表示

在对象的集合之中游走,而不暴露集合的实现

外观(门面)

提供一个统一的接口,用来访问子系统中的一群接口。外观定义了一个高层接口,让子系统更多容易使用

简化一群类的接口

策略

定义算法族,分别封装起来,让它们之间可以互相替换,此模式让算法的变化独立于使用算法的客户

封装可以互换的行为,并使用委托来决定使用那一种

代理

为另一个对象提供一个替身或点位符以访问这个对象

包装对象,以控制对此对象的访问

工厂方法

定义了一个创建对象的接口,但由子类决定要实例化的类是哪一个。工厂方法让类把实例化推迟到子类

由子类决定要创建是具体类是哪一个

抽象工厂

提供一个接口,用于创建相关或依赖对象的家族,而不需要明确指定具体类

允许客户创建对象的家族,而无需指定他们的具体类

适配器

将一个类的接口,转换成客户期望另一个接口。适配器让原来不兼容的类可以合作无间

封装对象,并提供不同的接口

观察者

在对象之间定义一对多的依赖,这样一来,当一个对象改变时,依赖它的对象都会收到通知并自动更新

让对象能够在状态改变时被通知

模板方法

在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中。模板方法使得子类可以在不改变算法结构的情况下,重新定义算法中的某些步骤

由子类决定如何实现一个算法中的步骤

组合

允许你将对象组成树结构来表现“整体/部分”的层次结构。组合能让客户以一致的方式处理个别对象和对象组合

客户用一致的方式处理对象集合和单个对象

单件(单体)

确保一个类只有一个实例,并提供全局访问点

确保只有一个对象被创建

命令

将请求封装成对象,这可以让你使用不同的请求、队列,或者日志请求来参数化其它对象。命令模式也可以支持撤销操作

封装请求为对象


  四、参考资料
         IBM社区设计模式方面资料: http://www.ibm.com/developerworks/cn/java/design/
         常见OO原则:http://www.blogjava.net/jicheng687/archive/2011/02/13/344174.html

--END--

posted @ 2011-02-21 23:40 XXXXXX 阅读(3137) | 评论 (0)编辑 收藏

InfoQ的架构师月刊

今天无意中看到InfoQ(http://www.infoq.com/cn/architect)这个网站,里面的内容很不错,介绍的内容算是国内最先进的的,有兴趣的朋友可以看看

posted @ 2011-02-15 17:16 XXXXXX 阅读(209) | 评论 (0)编辑 收藏

【JUnit源码解读】--观察者模式

一、观察者模式定义
         观察者模式(Observer): 在对象之间定义一对多的依赖,这样一来,当一个对象改变状态,依赖它的对象都会收到通知,并自动更新

二、在JUnit中的体现




TestResult中用Vector保存各个监听器(文本界面、图形界面和Eclipse插件)
protected Vector fListeners;  //监听器集合

在测试运行阶段,如果出现Error 或者 Failure,TestResult 则会通知各个监听器
public synchronized void addFailure(Test test, AssertionFailedError t) {
        fFailures.addElement(
new TestFailure(test, t));
        
//观察者模式在这里体现出来了,当fFailures有变化时,马上通知其它Listeners
        for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) {
            ((TestListener)e.nextElement()).addFailure(test, t);
        }

    }


posted @ 2011-02-15 10:33 XXXXXX 阅读(211) | 评论 (0)编辑 收藏

【Junit源码解读】--概括

一、在单元测试领域里,JUnit可以说是王者,它不但精致,而且使用方便。最后有些时间,把JUnit源码读读,顺便复习下设计模式 :)

二、参考文章
        在深入看代码之前,先看下面的文章,对JUnit有一个基本的了解后,看代码会更有目的性。
        JUnit官方网站:http://www.junit.org
        分析 JUnit 框架源代码: http://www.ibm.com/developerworks/cn/java/j-lo-junit-src/
        JUnit A cook's tour:  http://junit.sourceforge.net/doc/cookstour/cookstour.htm

三、核心架构
        我分析的源码的版本是JUnit 3.8.2,这个版本相对简略,把核心思想表现出来了,没有4.X版本那么多附加的功能
        
        JUnit是一个模式密集型的框架,主要用组合模式、模样方法、观察者模式、参数收集方法、命令模式、装饰者模式和适配器模式。其中核心是  前三种


核心类之间的关系


Test、TestCase和TestSuit构成了测试框架的基础,它们用composite模式组合在一起,使得客户端可以将对象的集合以及个别的对象(TestCase)一视同仁.TestRusult用来保存测试结果,和TestListner组成observer模式,支持文本界面、图形界面和 Eclipse 集成组件三种监听器
和JUnit A cook's tour中提到的模式图很相似

类与类之间的关系在此就不作解释了,可以看看参考文章。有兴趣的朋友,欢迎一起讨论 :)

posted @ 2011-02-13 17:09 XXXXXX 阅读(367) | 评论 (0)编辑 收藏

常见的OO原则

封装变化

多用组合,少用继承

针对接口编程,不针对实现编程

为交互对象之间的松耦合设计而努力

类应该对扩展开放,对修改关闭

只和朋友交谈

别找我,我会找你

类应该只有一个改变的理由

posted @ 2011-02-13 10:23 XXXXXX 阅读(482) | 评论 (0)编辑 收藏

【Effective Java】--异常

38、只针对不正常的条件使用异常
异常只应该被用于不正常的条件,它们永远不应该被用于不正常的条件
设计API启示:一个良好的API不应该强迫它的客户为了正常的控制流而使用异常。对于边界的判断常用的有两种方法:状态测试方法和可被识别的返回值


40、对于可以恢复的条件使用被检查的异常,对于程序错误使用运行时异常
 Thowable(可抛出异常)有三种结构:被检查的异常(checked exception)、运行时异常(run-time exception)和错误(error)
如果期望调用者能够恢复,那么,对于这样的条件应该使用被检查的异常
运行时异常和错误,不需要也不应该是被捕获的抛出物
用运行时异常来指明程序错误
对于被检查的异常,提供一些辅助方法是非常重要的,通过这些方法,调用者可以获得一些有助于恢复的信息


41、避免不必要地使用被检查的异常

42、尽量使用标准异常
      


43、抛出的异常要适合于相应的抽象
高层的实现应该捕获低层的异常,同时导出一个可以按照高层抽象进行解释的---异常转译
低层的异常对于调试该异常被拨出的情形非常有帮助的话,可以使用异常链接。即低层的异常被高层的异常保存起来,并且高层的异常提供一个公有的访问方法来获得低层异常

44、每个异常的抛出都必须有文档

45、在细节消息中包含失败--捕获信息
为了捕获失败,一个异常的的字符串表示应该包含所有“对异常有贡献”的参数和域的值
在异常构造函数中以参数形式引入这些信息


46、努力使失败保持原子性
一个失败方法调用应该使用对象保持“它在被调用之前的状态” ---failure atomic
几种解决方法:在执行操作之前检查参数的有效性
调整计算机过程,使得任何可能会失败的计算部分发生在对象状态被修改之前
编写一段恢复代码
在对象上临时都拷贝一份,当操作完成之后把临时拷贝中的结果复制给原来的对象。如:Collections.sort

47、不要忽略异常
写上try catch块

posted @ 2011-02-12 18:02 XXXXXX 阅读(224) | 评论 (0)编辑 收藏

【编程珠现】-算法设计技术

        【编程珠玑】第一部分的基础知识已经看完,比较有感触的有以下几点:
            1)、数据决定程序结构:对不同的程序,选用最合适的数据结构,必要是可以借助数据库来解决问题
            2)、学会写伪代码:伪代码是思想的结晶,抛开算法的细节,抓住算法的本质思想。

          第二部分是关于程序性能的讲解。在算法设计技术章节讲到了以下几个重要的技术:
            1)、保存状态,避免重要计算:这也是动态规划所采用的思想,别浪费中间结果,它们很宝贵
            2)、将信息预处理至数据结构中:保存中间结果的一种方法
            3)、分治算法:算法课上第一个学习的算法,如:二分查找、Strassen矩阵乘法等等。核心思想在于把问题分解成简单的子问题,然后对子
                        问题进行合并,经常和递归一起使用
            4)、扫描算法
            5)、累积:通常用于求前i个值的和
            6)、下界:许多问题要证明它的下界是多少


            下面是习题14的解答思想:
             描述:给定整数m、n和整数(实)数向量x[n],请找到出现使总和x[i]+……+x[i+m]最接近0的整数i( 0<=i<n-m)
             解决思路:从i+1开始的长度为m+1的子向量等当前子向量减去x[i-1],再加上x[i+m]

              
int alg(int * x, int m , int n){
    
if0 == n )
        
return 0;

    
int i ;
    
int start = 0;
    
int subVal = 0;
    
int sum = 0;

    
for( i = 0; i <= m; i++){
        sum 
+= x[i];
    }

    subVal 
= abs(sum);
    
    
for( i = 1; i < n-m; i++){
        sum 
-= x[i-1];
        sum 
+= x[i+m];
        cout 
<< "sum " << sum <<endl;
        
if(abs(sum) < subVal){  //如果subVal比当前sum绝对值大
            start = i;
            subVal 
= abs(sum);
            
        }

    }

    
    cout 
<< "sum: " <<  sum << endl;
    cout 
<< "subVal: " << subVal << endl;
    
    
return start;
}

         原题中的向量为实数,核心算法还是一样的,只是浮点数比较的时候要注意下
         有兴趣的朋友欢迎一起讨论 :)

posted @ 2011-01-14 11:20 XXXXXX 阅读(251) | 评论 (0)编辑 收藏

【编程珠玑】-啊哈!算法


        一、二分搜索
                二分搜索可以说是无处不在,应用它的前提是,对象有序且在某一范围之内。

        二、基本操作的威力
                灵机一动,经过许久的思考,得出的解决方案或许就是一些基本操作的组合,不是吗?
                求逆代码:把ab变成ba,可以有如下的方法:ab->arb->arbr->(arbr)r->ba
                   E.G.  n元向量左移i个位置
reverse(0, rotdist - 1);
reverse(rotdist, n
-1);
reverse (
0, n-1);
      
        三、排序
                变位分词的应用,关键在于:选择标识和集中具有相同标识的单词

        四、原理
                1)排序:产生有序输出,将相等的元素集中在一起
                2)二分搜索
                3)标识:当使用等价类定义时,定义一种标识使同类中每一项都具有相同的标识,而该类之外的其它项则没有该标识,这是很有用的
                4)问题的定义:用户的需求才是程序设计的根本
                5)问题解决者的观点:优秀的程序员有点懒,他们坐下来等待灵机一动的出现而不急于使用最开始的想法编程
               

posted @ 2011-01-11 11:49 XXXXXX 阅读(347) | 评论 (0)编辑 收藏

【编程珠玑】-开篇


       昨天入手《编程珠玑》(第二版)一书,去年寒假已经把这书看了一大半,发现里面的一些算法和观点简单而富有哲理。

       一、准确描述问题:程序员的主要问题与其说是技术问题,还不如说是心理问题,他不能解决问题,是因为他企图解决错误的问题。所以准确描述一个问题非常重要,实际中往往体现中需求文档的规范性和无异性中。

      二、位图或者向量表示集合
              1)、位图数据结构的实现
  
#define BITSPERWORD 32
#define SHIFT 5
#define MASK 0x1F
#define N 10000000

int a[1 + N/BITSPERWORD];

void set(int i) {        a[i>>SHIFT] |=  (1<<(i & MASK)); }

void clr(int i) {        a[i>>SHIFT] &= ~(1<<(i & MASK)); }
int  test(int i)return a[i>>SHIFT] &   (1<<(i & MASK)); }
            2)、位图可以用于排序和和统计当中,合理应用往往可以得到时间-空间折中与双赢

        三、原理
         1)、正确的问题:明确了问题,这场战役就成功了90%
         2)、位图数据结构
         3)、多趟算法:这些算法多趟读入其输入数据,每次完成一步
         4)、时间-空间折中与双赢
         5)、简单的设计:设计者确定其设计已经达到了完美的标准不是不能增加任何东西,而是不能再减少任何东西
         6)、程序的设计阶段

posted @ 2011-01-08 10:41 XXXXXX 阅读(211) | 评论 (0)编辑 收藏

K-Menas算法


一、算法简介
 k-means 算法接受输入量 k ;然后将n个数据对象划分为 k个聚类以便使得所获得的聚类满足:同一聚类中的对象相似度较高;而不同聚类中的对象相似度较小。聚类相似度是利用各聚类中对象的均值所获得一个“中心对象”(引力中心)来进行计算的。


二、伪码

算法:K-means。
输入:
    K:聚类的数目
    D:包含n个对象的数据集
输出:K个聚类的集合
方法:
1)    从D中任意选择K个对象作为初始聚类中心;
2)    repeat
         根据聚类中对象的均值,将每个对象(再)指派到最相似的聚类;
          更新聚类均值,即计算每个聚类中对象的均值;
3)    until聚类不再发生变化

算法复杂度为: O(nkt).其中t为迭代次数

三、准确性评价



四、应用和扩展

posted @ 2011-01-04 11:05 XXXXXX 阅读(460) | 评论 (0)编辑 收藏

Install MySQL5.1.25 on Ubuntu

      Ubuntu crashed tonight which urged me to reintsall the system and MySQL. Damn!

-------------------main procedure-------------------

shell> groupadd mysql

shell> useradd -g mysql mysql

shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -

shell> cd mysql-VERSION

shell> ./configure --prefix=/usr/local/mysql

shell> make

shell> make install

shell> cp support-files/my-medium.cnf /etc/my.cnf

shell> cd /usr/local/mysql

shell> bin/mysql_install_db --user=mysql

shell> chown -R root  .

shell> chown -R mysql var

shell> chgrp -R mysql .

shell> bin/mysqld_safe --user=mysql &

------------------initilize the password ------------------
#set the password for root
shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');

#creat user mysql and set its password '123456'
CREATE USER mysql@localhost IDENTIFIED BY '123456';
GRANT ALL ON db_name.* TO mysql@localhost


References: http://dev.mysql.com/doc/refman/5.1/zh/index.html

posted @ 2010-12-29 00:20 XXXXXX 阅读(309) | 评论 (0)编辑 收藏