Nice TWiki > Doc > CodeExamples (r1.54) TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
Doc . { Changes | Index | Search | Go }
This section is a repository for code fragments and programs, for illustration purposes. Please create a specific page for each example. Its WikiWord should end with the word Example.

Examples for novices

HelloWorldNoviceExample: Setup, compile and run Hello World.

FiboNoviceExample: Setup, compile and run Fibonacci function.

ScissorsPaperRockNoviceExample: Setup, compile and run the Scissors Paper Rock multimethod implementation.

Download Language Shootout Examples 25 simple example programs (See The Great Computer Language Shootout )

Multimethod Examples

FiniteStateMachineMultiMethodExample: A simple Finite State Machine encoded directly with multimethods.

BinaryMethodsMultiMethodExample: Multimethods provide a straightforward solution to the problem of binary methods.

BuilderPatternMultiMethodExample: For performance testing, the Runabout project generates various styles of test code - Visitor, Test Case, Multi Java, Runabout etc. In Java, this kind of generator code is often written using the BuilderPattern; in Nice, multimethods provide a straightforward solution.

VisitorPatternMultiMethodExample: We'd like to reuse and extend software without modification. There are two aspects: adding a new datatype, usable with existing operations; and adding new operations for existing datatypes. This example follows the discussion in "Synthesizing Object-Oriented and Functional Design to Promote Reuse" from Functional and OO (Composite Pattern) approaches, to the Visitor Pattern and Extensible Visitor Pattern; with the addition of a straightforward implementation using multimethods and open classes.

AspectOrientedMultiMethodExample: Nice multimethods provide capabilities similar to AOP static crosscutting. Here's the Nice version of the Email example listings in "AOP banishes the tight-coupling blues".

Parametric Type Examples

NumberFiveParametricTypeExample: Subtype constraints on type parameters < T | T <: double, int <: T >

RecursiveParametricTypeExample: Shapes within Shapes.

GraphParametricTypeExample: Generic implementations of graph algorithms from the Boost Graph Library - Breadth First Search, Dijkstra Shortest Paths, Prim's Minimum Spanning Tree, Bellman Ford Shortest Paths, Johnson All-Pairs Shortest Paths. Compare with C++, ML, Haskell, Eiffel, Java Generics, Generic C# implementations in "A Comparative Study of Language Support for Generic Programming".

Java Reuse Examples

MethcallIntermediateExample: Define a Java class JavaToggleExample and subclass it in Nice, compile Nice using classes in a Java jar, setup a Nice executable archive classpath to find a Java jar - compare with MethcallBeginnerExample.

MethcallIntermediateTwoExample: Define a Nice class NiceToggleExample and subclass it in Java - compare with MethcallBeginnerExample.

User Interface Examples

HelloSwtUserInterfaceExample: Simple SWT UI event handling (requires swt.jar).

HelloSwingWorld : Shows how to write a graphical helloworld program

CSP Concurrency Examples

SimpleProducerConsumerCspExample: Simple multithreaded programming using CSP primitives from the JCSP library.

PowerSeriesCspExample: Normally JCSP processes are defined, created; and then they are all started at the same time. In this case, we spawn new processes as needed while the other processes are running. See "Squinting at Power Series".

Benchmark Examples

TreeVisitorIntermediateExample: Benchmark comparison between the Java Extensible Visitor pattern and modular extension in Nice. Simple generic binary tree TreeVisitorClassesIntermediateExample extended with a subclass representing n-ary trees, and with 3 different external methods.

DispatchIntermediateExample: Benchmark comparison between typecase and double-dispatch in Java, and multiple dispatch in Nice.

BenchIntermediateExample: Martin Richards systems language benchmark Bench, written in an ordinary OO style. PacketBenchExample declares enums, TcbBenchExample uses a class initializer, SchedulerBenchExample misuses enum.hashCode, TaskBenchExample declares an interface. "Benchmarking Java with the Richards benchmark" provides some background information.

Functional Programming Examples

HaskellPreludeExample: Selected parts of the Haskell prelude, lots of functions which are useful when programming in functional style.

LazyVectorExample: A Vector subclass which computes its elements as they are they requested.

化工泵 净化设备 稳压电源 初级会计师 留学签证 珠海生活 波峰焊 晶振 移动PC 视频点播 聊天室 消毒 越野车 电容器 电磁阀 类风湿 留学专家 首饰 晶体 内存 东莞生活 拓展训练 股票证券 留学中介 广告 电教 液晶屏 超声波 桌面 黑客帝国 挤出机 汽车租赁 消毒液 博天堂 投影仪 黄历 液晶显示器 温控器 动画 屏幕保护 白癜风 垫片 证券 电热膜 主机 户外 扑克 防火墙 肝硬化 注册税务师 广东生活 逆变电源 北京现代汽车 枫叶卡 资源库 风湿 脉管炎 汇款 电脑报价 西联 工作站 监控 广州生活 空间租用 信息化 螺丝 套管 外语 强直性脊柱炎 邮件系统 办公楼 胶粘剂 压力变送器 电线 铃声 皮具 星座 扣件 印花 工商注册 温度计 实验台 歌曲下载 文化 工业控制 雨伞 管理咨询公司 证卡打印机 液压件 注册 助剂 豆粕 胰岛素泵 电子元件 链条 流水线 防爆电机 水处理公司 水产品 紧固件 铸件 保健品 粉末涂料 文件柜 工装 隔离器 中药 手推车 光通信 喷涂设备 铸造 绿茶 宽带接入 计算机学校 工控 激光测距仪 清洗机 尖锐湿疣 网络布线 手电筒 读卡器 网络维护 数码管 栈板 蜂胶 打码机 思科 托盘 免费下载 野营用品 护肤 絮凝剂 色织布 护肤品 儿童玩具 人才招聘 旅游用品 减速电机 金属材料 不锈钢制品 癫痫 电视 电视剧 电工工具 电动摩托车 客车 抛光 黄页 磨床 洗地机 木门 圆珠笔 铜门 调节阀 搜索引擎 环境实验设备 塑料管材 呼吸机 节能 电解电容 网页 医疗 司法考试 结婚 防腐涂料 玻璃仪器 书店 光盘制作 医药 音乐网站 臭氧 网球 铁柜 医院管理 洗衣 致富信息 冠心病 保姆 报关 法语 散热片 毛巾 形象设计

Topic CodeExamples . { Edit | Attach | Ref-By | Printable | Diffs | r1.57 | > | r1.56 | > | r1.55 | More }
Revision r1.54 - 27 Jan 2005 - 06:26 GMT - LiYan
Parents: WebHome
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.