关于设计模式

Mac本地部署OpenClaw+MLX+飞书:零数据出域的AI工作流 本地大模型推理是AI工程化落地的关键环节,其核心在于框架适配、内存效率与协议解耦。MLX作为苹果原生机器学习框架,通过统一内存池与ANE硬件协同,显著降低Apple Silicon设备的推理延迟与功耗;OpenClaw则以轻量级Agent架构实现模型、工具、记忆与协议的模块化分离,支持飞书等平台的事件驱动式集成。该组合规避了PyTorch+Metal在M系列芯片上的Flash Attention兼容性问题和双拷贝内存瓶颈,同时绕开Claude/Codex等闭源方案的硬件限制与隐私风险。典型应用场景包括周报生 阅读详情

OOD(面向对象设计)的原则(solid):


单一相关的法则:

这是一个通用原则。 如:方法的设计,类的设计,数据库接口的设计,网络请求接口的设计等都用到此原则。



单一职责原则(SingleResponsibility Principle):功能要单一。

通过方法功能的单一来实现。

接口隔离原则(Interface Segregation Principle):接口功能细分(接口精简单一)

通过接口定义的细分来实现。



抽象相关的法则:

Liscov替换原则(Liscov Substitution Principle):子类功能不能退化(不要破环继承体系)。

通过重写父类方法时不清空方法体的内容来实现。

开放闭合原则(Open ClosedPrinciple):对修改关闭,对扩展开放。

通过抽象接口实现可扩展。

依赖倒置原则(DependencyInversion Principle):上层下层都依赖抽象(要面向接口编程)

通过依赖底层工具类抽象出的接口来实现。



解耦相关的法则:

迪米特原则(Least Knowledge Principle):最少知识(降低耦合)

通过控制类的访问权限和增加中间类来实现。




面向对象最大的能耐:

抽象,各个层次的抽象。哪里变化抽象哪里。哪里可扩展抽象哪里

抽象的好处:

1.解耦、增加可扩展性

2.统一类型(变量的类型),使用方便

3.抽象更符合人得逻辑使问题简化。

软件模块之间调用分类(从调用方式上分):

概念:

设计模式是被反复使用的软件代码设计经验的总结。是设计方法,不是编程技术


不错的文章:

http://stackoverflow.com/questions/1673841/examples-of-gof-design-patterns

【v4l2】在Android SDK中交叉编译v4l2-ctl 为调试Android设备中camera的相关功能,需要引入v4l2-ctl工具。由于厂商提供的Android SDK源码中未集成v4l2-utils(包含v4l2-ctl以及其它组件的工具包),故需要下载v4l2-utils源码,并在Android SDK中交叉编译生成v4l2-ctl可执行文件。本文讲述其过程步骤。 阅读详情

相关推荐

STM32实战:电容触摸屏I2C转USB HID设备全解析

本文详细解析了基于STM32的电容触摸屏I2C转USB HID设备实现方案。通过硬件选型、协议分析和代码实现,展示了如何将GT911触摸屏数据转换为标准USB HID协议,并提供了关键调试经验与性能优化技巧,为智能家居控制面板等应用提供高性价比解决方案。

weixin_42548829的博客 320

什么是高内聚,低耦合

高内聚: 一个功能模块的各个部分。

JavaLive09的专栏 1580

PCout(n) -- STM32F103RCT6 位带操作

位带操作,sys.h,PCout,PAout,PAout

weixin_50212044的博客 4021

UML(图形化的语言表示)

一些概念 OO(Object-Orientation) 面向对象,一种系统建模技术 OOP(Object-OrientationProgramming) 面向对象编程,按照OO的方法来开发程序的过程 OOAD(Object-OrientationAnalysis and Design) 面向对象的分析与设计 UML图分类: 静态模型(static model) 用例图(use c

JavaLive09的专栏 1186

在Wincc8.0的Wincc 3D Control控件中使用3D模型

如果之前没有在Blender中自定义光照,EnableBackground属性选择“是”,Wincc 3D Control会按一个均匀的光照强度渲染。Wincc8.0更新后提供了一个Wincc 3D Control控件来显示3D图像,但是该控件实际体验下来现阶段还存在功能不足、运行不稳定的问题。再把导出的dae文件复制进Wincc项目的GraCS文件夹中,文件名称复制进控件的SceneFile属性里。选择编辑模式,全选模型,点击网格→分离→按材质,分离出不同的部件(不同的部件最好使用不同的材质)。

ghoring的博客 7129

保姆级教程:5分钟搞定微信小程序live-player组件接入监控视频流

本文提供了一份详细的微信小程序接入实时监控视频流的实战指南。文章对比了live-player与video组件的核心差异,重点解析了如何申请并开通live-player组件的严格权限,并提供了播放RTMP流(低延迟)的完整配置、状态监听与错误处理代码。同时,也介绍了使用video组件播放HLS流的备选方案,帮助开发者根据项目需求快速选择并实现稳定可靠的监控视频播放功能。

open4的博客 296

Static Factory(静态工厂、简单工厂)

产品是多样的、变化的,抽象产品。 实例化一个对象之前有很多的前期和后期操作 例如: JDK中的java包装类的valueOf(); JDK中的java.text.DateFormat的getDateInstance(); JDK中的java.util.Calendar的getInstance(); Android中的PhoneFactory 类图:

JavaLive09的专栏 951

RK3588内核崩溃日志捕获:pstore与ramoops的实战配置指南

本文详细介绍了在RK3588嵌入式设备上配置pstore与ramoops以捕获内核崩溃日志的实战指南。通过内核配置调整、设备树设置及高级调试技巧,帮助开发者有效定位系统崩溃原因,特别适合户外智能设备等无法长期连接调试器的场景。文章还提供了生产环境优化建议,确保日志捕获的可靠性与安全性。

weixin_29189363的博客 407

Protoype(原型模式)

另外一种高效创建对象的方法 浅Clone:JDK支持 深Clone:序列化、反序列化 序列化:本质是流(byte流),对象流不序列化static、transient 。序列化的目的是搬运对象。 反序列化:不调用构造器 类图:

JavaLive09的专栏 862

FPGA 学习笔记:Vivado 工程更改FPGA 型号

FPGA 学习笔记:Vivado 工程更改FPGA 型号

坚韧与专注 1万+

深入理解 ABAP 中的 Fast Data Access:从 @itab 到 FOR ALL ENTRIES 的性能关键路径

ABAP性能优化的关键在于理解Fast Data Access(FDA)机制,它连接了应用服务器的内表与数据库运算。FDA允许将内表数据推送到数据库进行筛选、聚合等操作,是SELECT...FROM@itab语法的基础。开发者需注意:1)该语法可能在内置引擎或数据库执行;2)仅当SQL能力超出ABAP范围时才建议使用;3)需通过CL_ABAP_DBFEATURES检查数据库支持情况。合理使用FDA可优化批量数据处理,但滥用可能导致性能下降。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1269

Flyweight(享元模式)

有什么用? 一共享的方式

JavaLive09的专栏 849

【学习系列】SAP RAP 7:行为定义-Draft

本文介绍了RAP框架中的草稿表(Draft)功能及其应用。草稿表允许用户临时保存数据,在激活前不影响业务逻辑,支持保存继续、暂存和设备切换功能。草稿分为独占草稿(仅限同一用户编辑)和协作草稿(允许多用户协同编辑)。启用草稿需在行为定义和投影中包含标准action,并创建包含TotalETag等管理字段的草稿表。TotalETag确保草稿转换时活动数据未被修改,而ETagmaster则防止并发修改。文章通过OData调用示例详细说明了ETag验证过程,强调草稿功能由RAP框架自动处理,开发者只需关注定义和配置

DeveloperMrMeng的博客 441

Decorator(装饰器模式)

有什么用?

JavaLive09的专栏 845

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Adapter(适配器模式)

有什么用?

JavaLive09的专栏 835

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Memento(备忘录模式)

有什么用?

JavaLive09的专栏 824

Iterator(迭代子)

有什么用?

JavaLive09的专栏 811

Composite(组合模式)

有什么用?

JavaLive09的专栏 789

用反射设计框架的好处?

1.如 MVC 中的controller     反射:用字符串作为参数来生成对象。如果类不存在,编译不出错。    工厂类:如果new 对象的类不存在,会编译出错。 2.如 unitTest 中对象的控制     通过过滤class名字来控制对象。非常灵活。

JavaLive09的专栏 786

Proxy(代理模式)

有什么用?

JavaLive09的专栏 782

Command(命令模式)

有什么用?

JavaLive09的专栏 730

TemplateMethod(模版方法)

有什么用?

JavaLive09的专栏 728

Chain of Responsibility(责任链)

有什么用?

JavaLive09的专栏 725

设计模式与生活⑰:空腹体检,单子领着人走

一年一度的体检,约在了周二。早上打完卡,没开电脑,先去体检机构——公司指定的那家。空腹,早饭留着查完再吃。前台登记,递身份证,领回一张指引单:姓名、条码,今天要查的项目按房间号排成一列。抽血、心电图、视力……单子一到手,人就被单子领着走了。先查哪项看哪边排队人少,但单子上的项目,一项落不下。去年也是这套流程。单子上的项目换了几样,走的科室还是那几个。身体还是这副身体,单子年年换。这事儿跟代码里的一种结构,是一回事。单子一到手,人就被单子领着走了今天聊的:元素稳定,操作多变;

工一木子 68

怎样设计一个好架构:八个评价维度、四层思考深度,以及 23 种设计模式各自解决什么问题

架构要解决的是变化、理解、故障和协作的成本。本文从耦合、可迁移、可适配、复杂度等八个维度讲怎么评价架构,讲维度之间怎么取舍、架构思考可以分几层,再用可编译的 C 代码过一遍 23 种设计模式。

weixin_52400878的博客 321

设计模式 - 访问者模式

概述 访问者模式(Visitor Pattern)是一种行为型设计模式,它通过为对象结构中的每个元素添加一个访问操作,使得可以在不改变元素类的前提下定义作用于这些元素的新操作。

2601_96797912的博客 183

工作流 vs 自主 Agent:5 种设计模式与 3 种建模方式详解

本文基于 Anthropic《Building Effective Agents》指南,系统梳理了AI应用中的两类核心架构:Workflow(编排式)与Agent(自主智能体)。强调“能画流程图就不上Agent”,提出从简单提示链到复杂自主决策的5种可组合工作流模式,并给出选型口诀与工程实践建议。核心观点:优先用确定性、可审计的Workflow,仅在任务路径未知时启用Agent,避免盲目复杂化。

分享大数据、java相关的技术 157
上一篇: UML(图形化的语言表示)
下一篇: Singleton(单例模式)
javalive09
博客等级 码龄16年 43粉丝 281原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值