- 浏览: 13219 次
- 性别:
- 来自: 南京
文章分类
最新评论
package com.linewell.modeldesgin.command
import scala.collection.mutable.ArrayBuffer
/**
* 加法类,请求接收者
* Created by ctao on 2015/8/30.
*/
class Adder {
/**
* 计算器初始值
*/
private var num = 0
/**
* 加法操作
* @param value 传入值
* @return 计算结果
*/
def add(value: Int) = {
num += value
num
}
}
/**
* 抽象命令类
*/
abstract class AbstractCommand {
/**
* 命令执行方法
* @param value 数值
* @return
*/
def execute(value: Int): Int
/**
* 命令撤销方法
* @return 撤消后数值
*/
def undo(): Int
/**
* 二次撤销方法
* @return 二次撤销后数值
*/
def redo(): Int
}
/**
* 具体命令类
*/
class AddCommand extends AbstractCommand {
/**
* 值栈存放传入数值,用于进行undo
*/
private val values = new ArrayBuffer[Int]()
/**
* 值栈存放undo数值,用于redo
*/
private val valuesRedo = new ArrayBuffer[Int]()
/**
* 请求接收者
*/
val adder = new Adder
/**
* 执行过程中将操作数放入值栈
* @param value 数值
* @return
*/
override def execute(value: Int) = {
values += value
adder.add(value)
}
/**
* 如果是栈底,则不可undo,返回初始的num
* 否则进行撤销,从值栈取最后一个值并加上相反数,并设置temp用于后续的redo
* @return 撤消后数值
*/
override def undo() = {
values.length match {
case 0 => println("不可undo"); adder.add(0)
case _ => val temp = values.remove(values.length - 1)
valuesRedo += temp
adder.add(-temp)
}
}
/**
* 如果是redo值栈为0,返回原值+0的方式获取原值,因为原值是私有对象,并不需要加入值栈
* 否则取redo队列最后一个,加入值栈队列并执行加法
* @return 二次撤销后数值
*/
override def redo() = {
valuesRedo.length match {
case 0 => println("不可redo"); adder.add(0)
case _ => val temp = valuesRedo.remove(valuesRedo.length -1)
values += temp
adder.add(temp)
}
}
}
class CalculatorForm(command: AbstractCommand) {
def compute(value: Int): Unit = {
val i = command.execute(value)
println(s"执行运算,运算结果为: $i")
}
def undo(): Unit = {
val i = command.undo()
println(s"执行undo,运算结果为: $i")
}
def redo(): Unit = {
val i = command.redo()
println(s"执行redo,运算结果为: $i")
}
}
object ClientAdd extends App {
val command: AbstractCommand = new AddCommand
val form = new CalculatorForm(command)
form.compute(10)
form.compute(5)
form.undo()
form.undo()
form.redo()
form.redo()
form.redo()
form.undo()
form.undo()
form.undo()
form.redo()
form.compute(100)
}
package com.linewell.modeldesgin.command
import scala.collection.mutable.ArrayBuffer
/**
* 命令队列模式
* Created by ctao on 2015/8/30.
*/
class CommandQueue {
/**
* 存放抽象命令类
*/
private val commands: ArrayBuffer[CommandByQueue] = new ArrayBuffer[CommandByQueue]()
def addCommand(commandByQueue: CommandByQueue) = commands += commandByQueue
def removeCommand(commandByQueue: CommandByQueue) = commands -= commandByQueue
/**
* 批处理
*/
def execute() = commands.foreach(_.execute())
}
/**
* 抽象命令类
*/
abstract class CommandByQueue {
def execute(): Unit
}
/**
* 帮助命令类,具体命令类,维持对请求接收者的调用
*/
object HelpCommandByQueue extends CommandByQueue {
/**
* 其实本来可以直接使用单例对象,但这样可以把请求接受者表示更加清晰
*/
val helpHandler = HelpHandlerByQueue
override def execute() = helpHandler.display()
}
/**
* 最小化命令类,具体命令类,维持对请求接收者的调用
*/
object MinimizeCommandByQueue extends CommandByQueue {
val windowHandler = WindowHandlerByQueue
override def execute() = windowHandler.minimize()
}
/**
* 窗口处理对象,请求的接收者
*/
object WindowHandlerByQueue {
def minimize() = println("将窗口最小化到托盘")
}
/**
* 帮助文档处理对象,请求的接收者
*/
object HelpHandlerByQueue {
def display() = println("显示帮助文档")
}
/**
* 请求发送类
* @param commandQueue 命令队列
*/
case class Invoker(commandQueue: CommandQueue) {
/**
* call方法,批处理
*/
def call() = commandQueue.execute()
}
package com.linewell.modeldesgin.command
/**
* 批处理测试客户端
* Created by ctao on 2015/8/30.
*/
object ClientByQueue extends App {
/**
* 通过设置抽象命令类对应的具体命令类
*/
val command1: CommandByQueue = HelpCommandByQueue
val command2: CommandByQueue = MinimizeCommandByQueue
/**
* 加入命令队列
*/
val commandQueue = new CommandQueue
commandQueue.addCommand(command1)
commandQueue.addCommand(command2)
/**
* 请求发送者
*/
val invoker = Invoker(commandQueue)
/**
* 批处理
*/
invoker.call()
}
package com.linewell.modeldesgin.command
import scala.collection.mutable.ArrayBuffer
/**
* 功能键设置窗口
* Created by ctao on 2015/8/30.
*/
case class FBSettingWindow(title: String) {
/**
* 用来存储按钮
*/
private val functionButtons: ArrayBuffer[FunctionButton] = new ArrayBuffer[FunctionButton]()
def addFunctionButton(functionButton: FunctionButton): Unit = functionButtons += functionButton
def removeFunctionButton(functionButton: FunctionButton): Unit = functionButtons -= functionButton
/**
* 显示窗口和功能键
*/
def display() = {
println(s"显示窗口:$title")
println("显示功能键:")
functionButtons.foreach(fb => println(fb.name))
println("----------------")
}
}
/**
* 功能键类:请求发送者
* @param name 功能键名称
* @param command 维持一个抽象命令对象的引用
*/
case class FunctionButton(name: String, command: Command) {
/**
* 发送请求的方法
*/
def onClick(): Unit = {
print("点击功能键:")
command.execute()
}
}
/**
*抽象命令类
*/
abstract class Command {
def execute(): Unit
}
/**
* 帮助命令类,具体命令类,维持对请求接收者的调用
*/
object HelpCommand extends Command {
/**
* 其实本来可以直接使用单例对象,但这样可以把请求接受者表示更加清晰
*/
val helpHandler = HelpHandler
override def execute() = helpHandler.display()
}
/**
*最小化命令类,具体命令类,维持对请求接收者的调用
*/
object MinimizeCommand extends Command {
val windowHandler = WindowHandler
override def execute() = windowHandler.minimize()
}
/**
* 窗口处理对象,请求的接收者
*/
object WindowHandler {
def minimize() = println("将窗口最小化到托盘")
}
/**
* 帮助文档处理对象,请求的接收者
*/
object HelpHandler {
def display() = println("显示帮助文档")
}
package com.linewell.modeldesgin.command
/**
* 测试客户端
* Created by ctao on 2015/8/30.
*/
object Client extends App {
val fbWindow = FBSettingWindow("功能键设置")
/**
* 通过设置抽象命令类对应的具体命令类
*/
val command1: Command = HelpCommand
val command2: Command = MinimizeCommand
/**
* 实现对功能键的注入
*/
val fb1 = FunctionButton("功能键1", command1)
val fb2 = FunctionButton("功能键2", command2)
/**
* 加入到窗口
*/
fbWindow.addFunctionButton(fb1)
fbWindow.addFunctionButton(fb2)
// fbWindow.removeFunctionButton(fb1)
fbWindow.display()
/**
* 调用功能键的业务方法
*/
fb1.onClick()
fb2.onClick()
}
package com.linewell.modeldesgin.command
import java.io._
import scala.collection.mutable.ArrayBuffer
/**
* 配置文件操作类,请求的接收者,因为需要和command一起写文件,所以需要实现序列化接口
* Created by ctao on 2015/8/31.
*/
class ConfigOperator extends Serializable {
/**
* 插入
* @param args 参数
*/
def insert(args: String) = println(s"add node:$args")
/**
* 修改
* @param args 参数
*/
def modify(args: String) = println(s"alter node:$args")
/**
* 删除
* @param args 参数
*/
def delete(args: String) = println(s"delete node:$args")
}
/**
* 文件操作类
*/
object FileUtil {
/**
* 写日志文件
* @param commands 参数集合
*/
def writeCommands(commands: ArrayBuffer[LoggerCommand]): Unit = {
var file: FileOutputStream = null
var objOut: ObjectOutputStream = null
try {
file = new FileOutputStream("config.log")
objOut = new ObjectOutputStream(new BufferedOutputStream(file))
objOut.writeObject(commands)
} catch {
case e: Exception => println("fail write commands"); e.printStackTrace()
} finally {
objOut.close()
file.close()
}
}
/**
* 读日志文件
* @return 参数集合
*/
def readCommands(): ArrayBuffer[LoggerCommand] = {
var file: FileInputStream = null
var commands = new ArrayBuffer[LoggerCommand]()
var objIn: ObjectInputStream = null
try {
file = new FileInputStream("config.log")
objIn = new ObjectInputStream(new BufferedInputStream(file))
commands = objIn.readObject().asInstanceOf[ArrayBuffer[LoggerCommand]]
} catch {
case e: Exception => println("fail read commands"); e.printStackTrace()
} finally {
objIn.close()
file.close()
}
commands
}
}
/**
*抽象命令类,实现序列化接口将命令对象写文件
* @param name 命令名称
*/
abstract class LoggerCommand(var name: String) extends Serializable {
/**
* 参数
*/
protected var args: String = _
/**
* 文件操作类
*/
protected var configOperator: ConfigOperator = _
/**
* 设置文件操作类
* @param config 文件操作类
*/
def setConfigOperator(config: ConfigOperator) = configOperator = config
/**
* 带参数的执行方法
* @param args 参数
*/
def execute(args: String): Unit
/**
* 不带参数的执行方法
*/
def execute(): Unit
}
/**
* 插入命令
* @param name 命令名称
*/
class InsertCommand(name: String) extends LoggerCommand(name) {
override def execute(args: String) = {
this.args = args
configOperator.insert(args)
}
override def execute() = configOperator.insert(args)
}
/**
* 修改命令
* @param name 命令名称
*/
class ModifyCommand(name: String) extends LoggerCommand(name) {
override def execute(args: String) = {
this.args = args
configOperator.modify(args)
}
override def execute() = configOperator.modify(args)
}
/**
* 删除命令
* @param name 命令名称
*/
class DeleteCommand(name: String) extends LoggerCommand(name) {
override def execute(args: String) = {
this.args = args
configOperator.delete(args)
}
override def execute() = configOperator.delete(args)
}
/**
* 配置文件设置窗口类,请求的发送者
*/
class ConfigSettingWindow {
private var loggerCommand: LoggerCommand = _
/**
* 存放命令操作对象的集合
*/
private var commands = new ArrayBuffer[LoggerCommand]()
/**
* 设置命令
* @param command 命令对象
*/
def setCommand(command: LoggerCommand) = loggerCommand = command
/**
* 执行方法,发送敏力请求
* @param args 参数
*/
def call(args: String): Unit = {
loggerCommand.execute(args)
commands += loggerCommand
}
/**
* 保存配置文件
*/
def save() = FileUtil.writeCommands(commands)
/**
* 对配置文件中的命令对象依次调用
*/
def recover() = FileUtil.readCommands().foreach(_.execute())
}
package com.linewell.modeldesgin.command
/**
* 测试客户端
* Created by ctao on 2015/8/31.
*/
object ConfigClient extends App {
var co = new ConfigOperator
var loggerCommand: LoggerCommand = null
loggerCommand = new InsertCommand("add")
loggerCommand.setConfigOperator(co)
var csw = new ConfigSettingWindow
csw.setCommand(loggerCommand)
csw.call("index")
loggerCommand = new InsertCommand("add")
loggerCommand.setConfigOperator(co)
csw.setCommand(loggerCommand)
csw.call("post")
loggerCommand = new ModifyCommand("alter")
loggerCommand.setConfigOperator(co)
csw.setCommand(loggerCommand)
csw.call("index")
loggerCommand = new ModifyCommand("alter")
loggerCommand.setConfigOperator(co)
csw.setCommand(loggerCommand)
csw.call("post")
println("--------------------")
println("save config")
csw.save()
println("--------------------")
println("recover config")
println("--------------------")
csw.recover()
}
import scala.collection.mutable.ArrayBuffer
/**
* 加法类,请求接收者
* Created by ctao on 2015/8/30.
*/
class Adder {
/**
* 计算器初始值
*/
private var num = 0
/**
* 加法操作
* @param value 传入值
* @return 计算结果
*/
def add(value: Int) = {
num += value
num
}
}
/**
* 抽象命令类
*/
abstract class AbstractCommand {
/**
* 命令执行方法
* @param value 数值
* @return
*/
def execute(value: Int): Int
/**
* 命令撤销方法
* @return 撤消后数值
*/
def undo(): Int
/**
* 二次撤销方法
* @return 二次撤销后数值
*/
def redo(): Int
}
/**
* 具体命令类
*/
class AddCommand extends AbstractCommand {
/**
* 值栈存放传入数值,用于进行undo
*/
private val values = new ArrayBuffer[Int]()
/**
* 值栈存放undo数值,用于redo
*/
private val valuesRedo = new ArrayBuffer[Int]()
/**
* 请求接收者
*/
val adder = new Adder
/**
* 执行过程中将操作数放入值栈
* @param value 数值
* @return
*/
override def execute(value: Int) = {
values += value
adder.add(value)
}
/**
* 如果是栈底,则不可undo,返回初始的num
* 否则进行撤销,从值栈取最后一个值并加上相反数,并设置temp用于后续的redo
* @return 撤消后数值
*/
override def undo() = {
values.length match {
case 0 => println("不可undo"); adder.add(0)
case _ => val temp = values.remove(values.length - 1)
valuesRedo += temp
adder.add(-temp)
}
}
/**
* 如果是redo值栈为0,返回原值+0的方式获取原值,因为原值是私有对象,并不需要加入值栈
* 否则取redo队列最后一个,加入值栈队列并执行加法
* @return 二次撤销后数值
*/
override def redo() = {
valuesRedo.length match {
case 0 => println("不可redo"); adder.add(0)
case _ => val temp = valuesRedo.remove(valuesRedo.length -1)
values += temp
adder.add(temp)
}
}
}
class CalculatorForm(command: AbstractCommand) {
def compute(value: Int): Unit = {
val i = command.execute(value)
println(s"执行运算,运算结果为: $i")
}
def undo(): Unit = {
val i = command.undo()
println(s"执行undo,运算结果为: $i")
}
def redo(): Unit = {
val i = command.redo()
println(s"执行redo,运算结果为: $i")
}
}
object ClientAdd extends App {
val command: AbstractCommand = new AddCommand
val form = new CalculatorForm(command)
form.compute(10)
form.compute(5)
form.undo()
form.undo()
form.redo()
form.redo()
form.redo()
form.undo()
form.undo()
form.undo()
form.redo()
form.compute(100)
}
package com.linewell.modeldesgin.command
import scala.collection.mutable.ArrayBuffer
/**
* 命令队列模式
* Created by ctao on 2015/8/30.
*/
class CommandQueue {
/**
* 存放抽象命令类
*/
private val commands: ArrayBuffer[CommandByQueue] = new ArrayBuffer[CommandByQueue]()
def addCommand(commandByQueue: CommandByQueue) = commands += commandByQueue
def removeCommand(commandByQueue: CommandByQueue) = commands -= commandByQueue
/**
* 批处理
*/
def execute() = commands.foreach(_.execute())
}
/**
* 抽象命令类
*/
abstract class CommandByQueue {
def execute(): Unit
}
/**
* 帮助命令类,具体命令类,维持对请求接收者的调用
*/
object HelpCommandByQueue extends CommandByQueue {
/**
* 其实本来可以直接使用单例对象,但这样可以把请求接受者表示更加清晰
*/
val helpHandler = HelpHandlerByQueue
override def execute() = helpHandler.display()
}
/**
* 最小化命令类,具体命令类,维持对请求接收者的调用
*/
object MinimizeCommandByQueue extends CommandByQueue {
val windowHandler = WindowHandlerByQueue
override def execute() = windowHandler.minimize()
}
/**
* 窗口处理对象,请求的接收者
*/
object WindowHandlerByQueue {
def minimize() = println("将窗口最小化到托盘")
}
/**
* 帮助文档处理对象,请求的接收者
*/
object HelpHandlerByQueue {
def display() = println("显示帮助文档")
}
/**
* 请求发送类
* @param commandQueue 命令队列
*/
case class Invoker(commandQueue: CommandQueue) {
/**
* call方法,批处理
*/
def call() = commandQueue.execute()
}
package com.linewell.modeldesgin.command
/**
* 批处理测试客户端
* Created by ctao on 2015/8/30.
*/
object ClientByQueue extends App {
/**
* 通过设置抽象命令类对应的具体命令类
*/
val command1: CommandByQueue = HelpCommandByQueue
val command2: CommandByQueue = MinimizeCommandByQueue
/**
* 加入命令队列
*/
val commandQueue = new CommandQueue
commandQueue.addCommand(command1)
commandQueue.addCommand(command2)
/**
* 请求发送者
*/
val invoker = Invoker(commandQueue)
/**
* 批处理
*/
invoker.call()
}
package com.linewell.modeldesgin.command
import scala.collection.mutable.ArrayBuffer
/**
* 功能键设置窗口
* Created by ctao on 2015/8/30.
*/
case class FBSettingWindow(title: String) {
/**
* 用来存储按钮
*/
private val functionButtons: ArrayBuffer[FunctionButton] = new ArrayBuffer[FunctionButton]()
def addFunctionButton(functionButton: FunctionButton): Unit = functionButtons += functionButton
def removeFunctionButton(functionButton: FunctionButton): Unit = functionButtons -= functionButton
/**
* 显示窗口和功能键
*/
def display() = {
println(s"显示窗口:$title")
println("显示功能键:")
functionButtons.foreach(fb => println(fb.name))
println("----------------")
}
}
/**
* 功能键类:请求发送者
* @param name 功能键名称
* @param command 维持一个抽象命令对象的引用
*/
case class FunctionButton(name: String, command: Command) {
/**
* 发送请求的方法
*/
def onClick(): Unit = {
print("点击功能键:")
command.execute()
}
}
/**
*抽象命令类
*/
abstract class Command {
def execute(): Unit
}
/**
* 帮助命令类,具体命令类,维持对请求接收者的调用
*/
object HelpCommand extends Command {
/**
* 其实本来可以直接使用单例对象,但这样可以把请求接受者表示更加清晰
*/
val helpHandler = HelpHandler
override def execute() = helpHandler.display()
}
/**
*最小化命令类,具体命令类,维持对请求接收者的调用
*/
object MinimizeCommand extends Command {
val windowHandler = WindowHandler
override def execute() = windowHandler.minimize()
}
/**
* 窗口处理对象,请求的接收者
*/
object WindowHandler {
def minimize() = println("将窗口最小化到托盘")
}
/**
* 帮助文档处理对象,请求的接收者
*/
object HelpHandler {
def display() = println("显示帮助文档")
}
package com.linewell.modeldesgin.command
/**
* 测试客户端
* Created by ctao on 2015/8/30.
*/
object Client extends App {
val fbWindow = FBSettingWindow("功能键设置")
/**
* 通过设置抽象命令类对应的具体命令类
*/
val command1: Command = HelpCommand
val command2: Command = MinimizeCommand
/**
* 实现对功能键的注入
*/
val fb1 = FunctionButton("功能键1", command1)
val fb2 = FunctionButton("功能键2", command2)
/**
* 加入到窗口
*/
fbWindow.addFunctionButton(fb1)
fbWindow.addFunctionButton(fb2)
// fbWindow.removeFunctionButton(fb1)
fbWindow.display()
/**
* 调用功能键的业务方法
*/
fb1.onClick()
fb2.onClick()
}
package com.linewell.modeldesgin.command
import java.io._
import scala.collection.mutable.ArrayBuffer
/**
* 配置文件操作类,请求的接收者,因为需要和command一起写文件,所以需要实现序列化接口
* Created by ctao on 2015/8/31.
*/
class ConfigOperator extends Serializable {
/**
* 插入
* @param args 参数
*/
def insert(args: String) = println(s"add node:$args")
/**
* 修改
* @param args 参数
*/
def modify(args: String) = println(s"alter node:$args")
/**
* 删除
* @param args 参数
*/
def delete(args: String) = println(s"delete node:$args")
}
/**
* 文件操作类
*/
object FileUtil {
/**
* 写日志文件
* @param commands 参数集合
*/
def writeCommands(commands: ArrayBuffer[LoggerCommand]): Unit = {
var file: FileOutputStream = null
var objOut: ObjectOutputStream = null
try {
file = new FileOutputStream("config.log")
objOut = new ObjectOutputStream(new BufferedOutputStream(file))
objOut.writeObject(commands)
} catch {
case e: Exception => println("fail write commands"); e.printStackTrace()
} finally {
objOut.close()
file.close()
}
}
/**
* 读日志文件
* @return 参数集合
*/
def readCommands(): ArrayBuffer[LoggerCommand] = {
var file: FileInputStream = null
var commands = new ArrayBuffer[LoggerCommand]()
var objIn: ObjectInputStream = null
try {
file = new FileInputStream("config.log")
objIn = new ObjectInputStream(new BufferedInputStream(file))
commands = objIn.readObject().asInstanceOf[ArrayBuffer[LoggerCommand]]
} catch {
case e: Exception => println("fail read commands"); e.printStackTrace()
} finally {
objIn.close()
file.close()
}
commands
}
}
/**
*抽象命令类,实现序列化接口将命令对象写文件
* @param name 命令名称
*/
abstract class LoggerCommand(var name: String) extends Serializable {
/**
* 参数
*/
protected var args: String = _
/**
* 文件操作类
*/
protected var configOperator: ConfigOperator = _
/**
* 设置文件操作类
* @param config 文件操作类
*/
def setConfigOperator(config: ConfigOperator) = configOperator = config
/**
* 带参数的执行方法
* @param args 参数
*/
def execute(args: String): Unit
/**
* 不带参数的执行方法
*/
def execute(): Unit
}
/**
* 插入命令
* @param name 命令名称
*/
class InsertCommand(name: String) extends LoggerCommand(name) {
override def execute(args: String) = {
this.args = args
configOperator.insert(args)
}
override def execute() = configOperator.insert(args)
}
/**
* 修改命令
* @param name 命令名称
*/
class ModifyCommand(name: String) extends LoggerCommand(name) {
override def execute(args: String) = {
this.args = args
configOperator.modify(args)
}
override def execute() = configOperator.modify(args)
}
/**
* 删除命令
* @param name 命令名称
*/
class DeleteCommand(name: String) extends LoggerCommand(name) {
override def execute(args: String) = {
this.args = args
configOperator.delete(args)
}
override def execute() = configOperator.delete(args)
}
/**
* 配置文件设置窗口类,请求的发送者
*/
class ConfigSettingWindow {
private var loggerCommand: LoggerCommand = _
/**
* 存放命令操作对象的集合
*/
private var commands = new ArrayBuffer[LoggerCommand]()
/**
* 设置命令
* @param command 命令对象
*/
def setCommand(command: LoggerCommand) = loggerCommand = command
/**
* 执行方法,发送敏力请求
* @param args 参数
*/
def call(args: String): Unit = {
loggerCommand.execute(args)
commands += loggerCommand
}
/**
* 保存配置文件
*/
def save() = FileUtil.writeCommands(commands)
/**
* 对配置文件中的命令对象依次调用
*/
def recover() = FileUtil.readCommands().foreach(_.execute())
}
package com.linewell.modeldesgin.command
/**
* 测试客户端
* Created by ctao on 2015/8/31.
*/
object ConfigClient extends App {
var co = new ConfigOperator
var loggerCommand: LoggerCommand = null
loggerCommand = new InsertCommand("add")
loggerCommand.setConfigOperator(co)
var csw = new ConfigSettingWindow
csw.setCommand(loggerCommand)
csw.call("index")
loggerCommand = new InsertCommand("add")
loggerCommand.setConfigOperator(co)
csw.setCommand(loggerCommand)
csw.call("post")
loggerCommand = new ModifyCommand("alter")
loggerCommand.setConfigOperator(co)
csw.setCommand(loggerCommand)
csw.call("index")
loggerCommand = new ModifyCommand("alter")
loggerCommand.setConfigOperator(co)
csw.setCommand(loggerCommand)
csw.call("post")
println("--------------------")
println("save config")
csw.save()
println("--------------------")
println("recover config")
println("--------------------")
csw.recover()
}
发表评论
-
linux mongodb3安装
2015-10-29 15:33 261http://blog.csdn.net/cjuexuan/a ... -
scala代码重构(用递归代替var和while)
2015-09-07 19:47 382原有代码,其中使用了while循环和var /** ... -
再探设计模式之观察者模式(股票通知系统)
2015-09-05 10:28 498package com.linewell.modeldesig ... -
再探设计模式之状态模式(纸牌游戏的开发)
2015-09-04 13:52 537状态模式主要用于检测和切换状态,在状态模式下状态的转化对于客户 ... -
再探设计模式之访问者模式
2015-09-03 14:44 481访问者模式的使用条件比较苛刻主要可以以用于新增访问者时只需要 ... -
scala实现访问者模式
2015-09-02 20:54 376package com.linewell.modeldesgi ... -
scala实现模版方法模式
2015-09-02 20:54 416package com.linewell.modeldesgi ... -
scala实现状态模式
2015-09-02 16:37 386package com.linewell.modeldesgi ... -
scala实现观察者模式
2015-09-02 16:35 589package com.linewell.modeldesgi ... -
scala实现迭代器模式
2015-09-01 22:56 466package com.linewell.modeldesgi ... -
scala实现备忘录模式
2015-09-01 22:54 341package com.linewell.modeldesgi ... -
scala实现中介者模式
2015-09-01 14:48 286package com.linewell.modeldesgi ... -
scala实现解释器模式
2015-08-31 20:20 316本来是看解释器模式,但感觉scala的实现的流利接口可以更优雅 ... -
scala实现职责链模式
2015-08-30 13:38 304package com.linewell.modeldesgi ... -
scala实现享元模式
2015-08-30 00:17 336package com.linewell.modeldesgi ... -
scala实现代理模式
2015-08-30 00:16 488package com.linewell.modeldesgi ... -
scala实现外观模式
2015-08-28 21:41 311package com.linewell.modeldesgi ... -
scala实现装饰者模式
2015-08-16 19:52 395package com.linewell.modeldesgi ... -
scala实现组合模式
2015-08-16 11:14 834package com.linewell.modeldesgi ... -
scala实现桥接模式
2015-08-16 11:13 311package com.linewell.modeldesgi ...
相关推荐
scala:Scala和设计模式 ...在当前软件Software设计中最流行要算GoF这本书...用方便性也很重要不妨让我们来看看Scala(种类似Ruby/Lisp的类语言它定程度上降低了模式实现繁琐)中常用 些模式 ; ; ; ; 1.Singleton(单体模式) ;
响应式架构 消息模式Actor实现与Scala.Akka应用集成 响应式架构 消息模式Actor实现与Scala.Akka应用集成
自己用scala实现的朴素贝叶斯算法。最近学习machine learning,由于之前学习了spark,于是使用scala尝试写写代码
差分进化算法的Scala实现_Scala_代码_下载
Scala设计模式,Scala高阶参考书。
消息模式Actor实现与Scala、Akka应用集成
scala 设计模式,详细讲述scala设计模式
不到一百行的代码教你在spark平台中使用scala实现kmeans算法。简单易懂,大量注释。适合初学者参考理解。本程序在intelliJ IDEA2016.1.1 中编程,运行在spark1.6.1 scala2.10.4本地模式下运行成功。 数据集:(其实...
[Manning Publications] Play 框架开发 (Scala 实现) (英文版) [出版日期] 2013年10月11日[图书页数] 328页 [图书语言] 英语[图书格式] PDF 格式
scala语言和python一样都是交互式的语言,操作简单。这是wordcount的scala实现,简单明了,比java实现简单很多,希望对大家有所帮助
scala for循环中的模式匹配:1)变量模式匹配2)常量模式匹配3)变量绑定模式匹配4)类型模式匹配5)构造函数模式匹配6)序列模式匹配
scala连接redis哨兵模式 demo 使用scala的redis库(csdn)————程序
scala正则表达式在模式匹配中的应用:提取模式的分组值,通过代码理解正则表达式与模式匹配的原理。
响应式架构++消息模式Actor实现与Scala.Akka应用集成+,沃恩·弗农+
[Packt Publishing] SBT 入门教程 (Scala 实现) (英文版) [Packt Publishing] Getting Started with SBT for Scala (E-Book) ☆ 图书概要:☆ Equip yourself with a high-productivity work environment using ...
响应式架构 消息模式Actor实现与Scala.Akka应用集成 高清扫描版
基于spark-ml,scala实现gbdt 算法,附带libsvm训练集和普通训练集实现,GBDT (Gradient Boosting Decision Tree) 梯度提升迭代决策树。GBDT 也是 Boosting 算法的一种,但是和 AdaBoost 算法不同(AdaBoost 算法...
使用scala实现dvd系统的管理,新增dvd,删除dvd,外借,归还等模块