- 博客(38)
- 资源 (1683)
- 收藏
- 关注
原创 Access Control
类级别的访问控制只有两种:public 或者 package,也就是说class前面只能是public或者什么都没有。要想控制类不被访问,把构造函数私有化即可
2009-07-31 14:17:00 657
转载 Initialization & Cleanup笔记
public class Flower {int petalCount = 0;String s = "initial value";Flower(int petals) {petalCount = petals;print("Constructor w/ int arg only, petalCount= "+ petalCount);}Flower(String ss) {print("Con
2009-07-31 10:55:00 643
原创 Operator笔记
特别之处: 能进行&& 运算的只能是boolean型,不能是其他任何类型,否则编译时报错boolean限制非常多,不能与其他任何类型转换if(X=Y),除了X,Y是boolean型之外,编译器会报错,避免了C/C++中的问题byte,char,short在进行运算时都是提升到int进行运算的!但是有两种情况:(1)byte b;b*=222;这样编译器不会报错,会直接进行强
2009-07-30 15:05:00 550
原创 JavaScript设计模式学习——Chain of Responsibility
/* Interfaces. */var Publication = new Interface(Publication, [getIsbn, setIsbn, getTitle, setTitle, getAuthor, setAuthor, getGenres, setGenres, display]);var Library =
2009-07-29 14:50:00 696
原创 JavaScript设计模式学习——Command
/* Command, Composite and MenuObject interfaces. */var Command = new Interface(Command, [execute]);var Composite = new Interface(Composite, [add, remove, getChild, getElement])
2009-07-29 14:24:00 1394
原创 JavaScript设计模式学习——Observer
function Publisher(){ this.subscribers = [];}Publisher.prototype.deliver = function(data){ this.subscribers.forEach(function(fn){ fn(data); }); return this;}Fu
2009-07-29 10:57:00 558
原创 JavaScript设计模式学习——FlyWeight
数据集中管理:var Car = function(make, model, year){ this.make = make; this.model = model; this.year = year;};Car.prototype = { getMake: function(){ return this.make;
2009-07-29 09:58:00 696
原创 JavaScript设计模式学习——Basic Function
Interface: var Interface = function(name, methods) { if(arguments.length != 2) { throw new Error("Interface constructor called with " + arguments.length + "arguments, bu
2009-07-28 15:31:00 617
原创 JavaScript设计模式学习——Composite
//定义组合模式需要实现的接口var Composite = new Interface(Composite,[add,remove,getChild]); var GalleryItem = new Interface(GalleryItem,[hide,show]); var DynamicGallery=function(id){
2009-07-28 14:13:00 855
转载 交换两个数组使两个数组和的差最小
今天又看见了这个题目,好像上次是李灾跟我说腾讯面他的时候问了这个问题的。想了半天,在网上也看了半天,发现一个不错的算法,先帖出来:^ ^ /* 有两个数组a,b,大小都为n,数组元素的值任意整形数,无序; 要求:通过交换a,b中的元素,使[数组a元素的和]与[数组b元素的和]之间的差最小。*//* 求解思路: 当前数组a和数组b的
2009-07-28 13:07:00 14967 16
原创 JavaScript设计模式学习——Factory
/* DisplayModule interface. */var DisplayModule = new Interface(DisplayModule, [append, remove, clear]);/* ListDisplay class. *///通过接口实现工厂,这是通过List方式显示RSSvar ListDisplay = function
2009-07-28 10:24:00 1019
原创 JavaScript设计模式学习——Singleton
/* Basic Singleton. */var Singleton = {attribute1: true,attribute2: 10,method1: function() {},method2: function(arg) {}}; 单件模式最主要的用途之一就是命名空间:/* GiantCorp namespace. */var Giant
2009-07-27 14:11:00 799
原创 Prototype框架源码分析汇总
Prototype 学习——Prototype对象Prototype 学习——工具函数学习($方法)Prototype 学习——工具函数学习($A方法)Prototype 学习——工具函数学习($w,$F方法) Prototype学习——工具函数($H,$R,Try.these,document.getElemen
2009-07-27 13:55:00 2544
原创 浅析Javascript原型继承
JS没有提供所谓的类继承,据说在2.0中要加入这种继承方式,但是要所有浏览器都实现2.0的特性那肯定又得N多年。昨天看了crockford的一个视频,里面讲解了一下JS的继承方式,按照PPT里面说的,一共分了三类:Prototypal,pseudoclassical,Parasitic Inheritance。 下面主要介绍一下原型继承:When a function object is
2009-07-26 09:30:00 15823 6
原创 Prototype学习——Selector对象
这个对象在帮助文档上并没有,但是这个对象确是整个DOM操作的核心类,工具函数$$,其实就是调用这个类的方法:function $$() {return Selector.findChildElements(document, $A(arguments));} 这个类可以分成三个部分:第一个部分就是根据不同的浏览器,判断使用什么DOM操作方法。其中操作IE就是用普通的getEl
2009-07-23 18:46:00 1575
原创 C语言学习笔记(五)——内存的使用
为指针分配了内存,但是内存大小不够,导致出现越界错误。char *p1 = “abcdefg”;char *p2 = (char *)malloc(sizeof(char)*strlen(p1));strcpy(p2,p1);p1 是字符串常量,其长度为7 个字符,但其所占内存大小为8 个byte。初学者往往忘了字符串常量的结束标志“/0”。这样的话将导致p1 字符串中最后一个
2009-07-21 15:23:00 1051
原创 C语言学习笔记(四)——数组和指针
int *p = NULL;这时候我们可以通过编译器查看p 的值为0x00000000。这句代码的意思是:定义一个指针变量p,其指向的内存里面保存的是int 类型的数据;在定义变量p 的同时把p 的值设置为0x00000000,而不是把*p 的值设置为0x00000000。这个过程叫做初始化,是在编译的时候进行的。 int *p;*p = NULL;同样,我们可以在
2009-07-21 14:22:00 1748
原创 C语言学习笔记(三)——预编译指令
另外ANSI 标准C 还定义了如下几个宏:_LINE_ 表示正在编译的文件的行号_FILE_ 表示正在编译的文件的名字_DATE_ 表示编译时刻的日期字符串,例如: "25 Dec 2007"_TIME_ 表示编译时刻的时间字符串,例如: "12:30:55"_STDC_ 判断该文件是不是定义成标准C 程序 ===============================
2009-07-20 16:05:00 940
原创 C语言学习笔记(二)——表达式
++、--作为前缀,我们知道是先自加或自减,然后再做别的运算;但是作为后缀时,到底什么时候自加、自减?这是很多初学者迷糊的地方。假设i=0,看例子: //例子为逗号表达式,i 在遇到每个逗号后,认为本计算单位已经结束,i 这时候自加。A),j =(i++,i++,i++); j=3,i=3 //例子为逗号表达式,i 在遇到每个逗号后,认为本计算单位
2009-07-20 15:26:00 693
原创 C语言学习笔记(一)——数组指针杂项
32位机 int *p = NULL;sizeof(p)的值是多少? 4sizeof(*p)呢? 4 这里需要理解一下数组首地址和数组元素首地址。&a,&a[0],a,虽然这两个地址是一样的,但是含义确实不一样的。
2009-07-20 12:23:00 1020 2
原创 Prototype学习——工具函数($H,$R,Try.these,document.getElementsByClassName)
$H就是建立Hash对象的便捷方法,关于Hash对象具体参考【Prototype 学习——Hash对象 】$R就是简历ObjectRange对象的便捷方法,关于ObjectRange对象具体参考【Prototype 学习——ObjectRange对象 】 Try.these:Accepts an arbitrary number of functions and returns t
2009-07-19 20:15:00 1288
原创 Prototype 学习——Hash对象
这个对象相当于Java中的HashMap,当然了功能没HashMap那么强大。提供一直基本的方法,简单的方法就不在源码中注释了。 //Hash对象的工具函数function $H(object) { return new Hash(object);};var Hash = Class.create(Enumerable, (function() { //初
2009-07-18 21:07:00 1202
原创 Prototype 学习——Array对象
这个对象扩展了JS原生的Array对象,提供了一些基本的工具函数,有些方法非常简单,源码里就不在注释了。 Array.from = $A;(function() { //Array原型的引用 var arrayProto = Array.prototype, slice = arrayProto.slice, //JS 1.6里面会有原生的for
2009-07-18 20:36:00 1837
原创 Prototype 学习——PeriodicalExecuter对象
This is a simple facility for periodical execution of a function. This essentially encapsulates the native clearInterval/setInterval mechanism found in native Window objects.This is especially usefu
2009-07-18 20:22:00 867
原创 Prototype 学习——String对象
这个对象里面的方法就是提供了一些字符串操作的工具方法,比较重要的gsub方法,下面做了详细的注释,简单的方法就不说了,一看就明白了。 //String对象的静态方法Object.extend(String, { interpret: function(value) { return value == null ? : String(value); },
2009-07-18 19:56:00 1123
原创 Prototype 学习——Template对象
这里的Template对象其实就是格式化字符串的工具,就像java中的String.format方法。这个对象只提供一个方法evaluate。 var Template = Class.create({ //初始化方法 initialize: function(template, pattern) { this.template = template.toString
2009-07-18 16:11:00 788
原创 Prototype 学习——Enumerable对象
Enumerable provides a large set of useful methods for enumerations, that is, objects that act as collections of values. It is a cornerstone of Prototype. Enumerable is what we like to call a mo
2009-07-17 14:50:00 939
原创 Prototype 学习——Number对象
这个对象提供一些操作数值类型的工具函数 Object.extend(Number.prototype, (function() { //返回十六进制颜色之 function toColorPart() { return this.toPaddedString(2, 16); } //返回连续的下一个数值 function suc
2009-07-15 22:08:00 843
原创 Prototype 学习——ObjectRange对象
Ranges represent an interval of values. The value type just needs to be “compatible,” that is, to implement a succ method letting us step from one value to the next (its successor).Prototype provide
2009-07-15 21:17:00 868
原创 Prototype 学习——RegExp对象
帮助文档上没有这个对象,实际上源代码中这个对象还是有方法的,就1静态方法,作用也不是很大,这里简单说一下,因为以后介绍别的对象时会用到这个RegExp RegExp.prototype.match = RegExp.prototype.test;RegExp.escape = function(str) { return String(str).replace(/([.*+?
2009-07-13 21:35:00 806
原创 Prototype 学习——Class对象
Prototype’s object for class-based OOP. prototype OOP编程的基础,详细说明一下源码:/* Based on Alex Arnells inheritance implementation. */var Class = (function() { //临时存储parent的prototype function s
2009-07-13 21:10:00 2519
原创 Prototype 学习——Date对象
这个对象里面就一个toJSON方法,非常简单,看一下源码:Date.prototype.toJSON = function() { return " + this.getUTCFullYear() + - + (this.getUTCMonth() + 1).toPaddedString(2) + - + this.getUTCDate().toPadde
2009-07-12 19:59:00 931
原创 Prototype 学习——Function对象
这个对象就是对function的一些扩充,最重要的当属bind方法,prototype的帮助文档上特意说了一句话:Prototype takes issue with only one aspect of functions: binding.其中wrap方法也很重要,在类继承机制里面就是利用wrap方法来调用父类的同名方法。 argumentNames bind bindAsE
2009-07-12 16:29:00 1105
原创 Prototype 学习——Object对象
Object is used by Prototype as a namespace; that is, it just keeps a few new methods together, which are intended for namespaced access (i.e. starting with “Object.”).上面说的namespace个人理解就相当于C#中的静态类,提供
2009-07-12 10:05:00 897
原创 Prototype 学习——工具函数学习($w,$F方法)
$w方法 Splits a string into an Array, treating all whitespace as delimiters. Equivalent to Rubys %w{foo bar} or Perls qw(foo bar).function $w(string) {if (!Object.isString(string)) return [
2009-07-11 20:35:00 879
原创 Prototype 学习——工具函数学习($A方法)
$A方法:Accepts an array-like collection (anything with numeric indices) and returns its equivalent as an actual Array object. This method is a convenience alias of Array.from, but is the preferred w
2009-07-11 20:13:00 796
原创 Prototype 学习——工具函数学习($方法)
$ $$ $A $F $H $R $w Try.these document.getElementsByClassName $方法——被成为瑞士军刀(Swiss Army knife)If provided with a string, returns the element in the document with matching ID;
2009-07-11 19:36:00 942
原创 Prototype 学习——Prototype对象
环境:Prototype Version: 1.6.1_rc3 Aptana Studio, build: 1.2.5.023247 IE7FF2.0.0.4Opera 10 beta =============================================================var Prototype = { Ver
2009-07-11 18:40:00 1312
Functional Programming in Swift (2014-10-01)
2015-05-21
The.Creation.and.Science.of.Web.Design.Jan.2009
2009-02-28
Packt.Publishing.Learning.Website.Development.with.Django.Mar.2008
2009-02-28
MS - Microsoft SQL Server 2008 T-SQL Fundamentals (2008.10).
2009-02-28
Microsoft Press - Microsoft Visual C# 2008 Express Edition Build a Program Now!.
2009-02-28
Microsoft .NET Architecting Applications for the Enterprise
2009-02-28
GoF Design Patterns with examples using Java and UML2
2009-02-28
Exploring C++ The Programmer’s Introduction to C++.
2009-02-28
Developing Service-Oriented AJAX Applications on the Microsoft Platform
2009-02-28
Building the Agile Enterprise With SOA, BPM and MBM
2009-02-28
Apress.Pro.Oracle.Application.Express.Sep.2008.eBook-DDU
2009-02-28
jQuery UI 1.6 - The User Interface Library for jQuery (Feb 2009)
2009-02-23
iPhone Open Application Development Second Edition
2009-02-23
I.O.U.S.A. One Nation. Under Stress. In Debt
2009-02-23
Delivering Business Intelligence with Microsoft SQL Server(TM) 2E 2008
2009-02-23
Apress[1].Pro.JavaScript.Design.Patterns.Dec.2007
2009-02-23
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人