随笔分类 -  Programming Data

摘要:昨晚看书,讲到了异常与错误其实还真的没有认真的分析过,这二者的关系是怎么样的。Mary Campione在The Java Tutorial(Java指南)中所写的,“一个异常是在一个程序执行过程中出现的一个事件,它中断了正常指令的运行。”merican Heritage Dictionary的解释,一个错误是“偏离了可接受的代码行为的一个动作或一个实例。” 我的理解是这样的:异常,是他需要的条件不满足,而发生或者说是出现了你不要的结果,是一个潜在的错误错误,是因为操作或者是需要的条件已经满足,但是条件的满足只是在量上的满足,比如一个函数要两个参数,你提供的也是两个。但是没能满足他“质”上的要 阅读全文
posted @ 2011-07-05 11:06 Podevor 阅读(464) 评论(0) 推荐(0)
摘要:Test Driven DevelopmentWhen you code, alternate these activities:add a test, get it to fail, and write code to pass the test (DoSimpleThings,CodeUnitTestFirst)remove duplication (OnceAndOnlyOnce,DontRepeatYourself,ThreeStrikesAndYouAutomate)This inner loop pumps the outer loops ofExtremeProgramming- 阅读全文
posted @ 2011-07-01 08:11 Podevor 阅读(225) 评论(0) 推荐(0)
摘要:(1)引用被创建的同时必须被初始化,指针则可以在任何时候被初始化。(2)不能有NULL 引用,引用必须与合法的存储单元关联,指针则可以是NULL。(3)一旦引用被初始化,就不能改变引用的关系,指针则可以随时改变所指的对象。 阅读全文
posted @ 2011-06-23 16:16 Podevor 阅读(120) 评论(0) 推荐(0)
摘要:在多重循环中,如果有可能,应当将最长的循环放在最内层,最短的循环放在最外层,以减少CPU 跨切循环层的次数。for (row=0; row<100; row++){for ( col=0; col<5; col++ ){sum = sum + a[row][col];}}低效率:长循环在最外层 for (col=0; col<5; col++ ){for (row=0; row<100; row++){sum = sum + a[row][col];}}高效率:长循环在最内层如果循环体内存在逻辑判断,并且循环次数很大,宜将逻辑判断移到循环体的外面。如果N 非常大,最好采 阅读全文
posted @ 2011-06-23 15:35 Podevor 阅读(296) 评论(0) 推荐(0)
摘要:假设整型变量的名字为value,它与零值比较的标准if 语句如下:if (value == 0)if (value != 0)不可模仿布尔变量的风格而写成if (value) // 会让人误解value 是布尔变量if (!value)假设布尔变量名字为flag,它与零值比较的标准if 语句如下:if (flag) // 表示flag 为真if (!flag) // 表示flag 为假其它的用法都属于不良风格,例如:if (flag == TRUE)if (flag == 1 )if (flag == FALSE)if (flag == 0假设浮点变量的名字为x,应当将if (x == 0.0 阅读全文
posted @ 2011-06-23 15:26 Podevor 阅读(170) 评论(0) 推荐(0)
摘要:学习linux下的c/c++编程1,先有linux环境搭minGW和cygwin都有点麻烦,最最简单的办法还是装个真正的linux,用虚拟机也好,在网络上的另一台机器也好。这样不仅快,而且你有了真正的环境。2.会C/C++语言(估计你会的)3.入门阶段熟悉gcc命令行,最基本的参数,如,-g,-W,-O,-o,-c 建议看man gcc(很大找想要的)4.编译第一个helloworld程序: 基本命令 gcc helloworld.c -o helloworld前面四个阶段的时间估计只要1-2天就可以了5.提高阶段,你需要开始了解,并熟悉ld,gdb,编写基本的Makefile,了解make. 阅读全文
posted @ 2011-06-22 13:52 Podevor 阅读(224) 评论(0) 推荐(0)
摘要:This is an ongoing battle for me, I've tried Code::Blocks, Anjuta, Netbeans, Eclipse, Qt Creator, and many many others...My personal favorite is Netbeans, it has some of the best code-completion I've seen, with Visual Studio on Windows being the only one to top it for me. You can also use it 阅读全文
posted @ 2011-06-21 10:00 Podevor 阅读(130) 评论(0) 推荐(0)
摘要:You can debug by adding printf statements to a program, but this is clumsy and very time consuming. A debugger like gdb is a much more efficient debugging tool. Adding printf statements in your program is a way that can cosume your more time.If you wanna chanage this situation and scientific way i.. 阅读全文
posted @ 2011-06-21 09:41 Podevor 阅读(115) 评论(0) 推荐(0)
摘要:The C compiler on eniac is gcc. Its C++ counterpart is g++. To compile a C or C++ program: % gcc file.cor% g++ file.cThis compiles file.c into an executable binary named a.out.Here are a few options to gcc and g++: -o outputfileTo specify the name of the output file. The executable will be named a.o 阅读全文
posted @ 2011-06-16 10:04 Podevor 阅读(205) 评论(0) 推荐(0)
摘要:为了便于分析这里建立了两个模型来了分析作用域的问题:这里我们看到的是一个上端很尖的沙漏,现在有沙子从上端漏下,很自然的,下面的local scope 以及global scope 都不可能碰到。语句作用域里面的变量不能被local 和global 访问和操作,局部作用域里面的变量也不能被全局作用域操作再来看看这个模型。现在沙漏尖端在下,那么当在上面放入沙子时,很自然的,下面的local和statement都可以接触到。全局变量可以在局部访问和操作,也可以才语句作用域中操作;局部变量可以在语句作用域中操作。 阅读全文
posted @ 2011-06-06 10:59 Podevor 阅读(146) 评论(0) 推荐(0)