当前位置: 首页 > news >正文

青岛网站设计哪家便宜建筑公司取名参考

青岛网站设计哪家便宜,建筑公司取名参考,直播软件有哪些平台,手机 网站开发软件有哪些课程目标 理解松耦合设计思想掌握面向对象设计原则掌握重构技法改善设计掌握GOF核心设计模式 什么是设计模式 目标:复用,以不变应万变 GOF设计模式 从面向对象谈起 深入理解面向对象 向下:深入理解三大面向对象机制 封装:隐藏…

课程目标

  • 理解松耦合设计思想
  • 掌握面向对象设计原则
  • 掌握重构技法改善设计
  • 掌握GOF核心设计模式

什么是设计模式

在这里插入图片描述
目标复用,以不变应万变

GOF设计模式

在这里插入图片描述

从面向对象谈起

在这里插入图片描述

深入理解面向对象

  • 向下:深入理解三大面向对象机制
    • 封装:隐藏内部实现
    • 继承:复用现有代码
    • 多态:改写对象行为
  • 向上:深刻把握面向对象机制所带来的抽象意义,理解如何使用这些机制来表达现实世界,掌握什么是“好的面向对象设计”

软件设计固有的复杂性

在这里插入图片描述

软件设计复杂的根本原因

  • 变化
    • 客户需求的变化
    • 技术平台的变化
    • 开发团队的变化
    • 市场环境的变化

如何解决复杂性

  • 分解
    • 人们面对复杂性有一个常见的做法:即分而治之,将大问题分解为多个小问题,将复杂问题分解为多个简单问题。
  • 抽象
    • 更高层次来讲,人们处理复杂性有一个通用的技术,即抽象。由于不能掌握全部的复杂对象,我们选择忽视它的非本质细节,而去处理泛化和理想化了的对象模型。

结构化 VS. 面向对象

  • 分解:将问题具体化
/*
* @file: Shape1.h
*/class Point {
public:int x;int y;
};class Line {
public:Point start;Point end;Line(const Point& start, const Point& end) {this->start = start;this->end = end;}
};class Rect {
public:Point leftUp;int width;int height;Rect(const Point& leftUp, int width, int height) {this->leftUp = leftUp;this->width = width;this->height = height;}
};// 增加
// 新图形
class Circle {};
/*
* @file: MainForm1.cpp
*/class MainForm : public Form {
private:Point p1;Point p2;vector<Line> lineVector;	// 直线vector<Rect> rectVector;	// 矩形// 改变// 增加一个vector专门存储圆vector<Circle> circleVector;	// 圆public:MainForm() {// ...}
protected:virtual void OnMouseDown(const MouseEventArgs& e);virtual void OnMouseUp(const MouseEventArgs& e);virtual void OnPaint(const PaintEventArgs& e);
};void MainForm::OnMouseDown(const MouseEventArgs& e) {p1.x = e.X;p1.y = e.Y;// ...Form::OnMouseDown(e);
}void MainForm::OnMouseUp(const MouseEventArgs& e) {p2.x = e.X;p2.y = e.Y;if (rdoLine.Checked) {	// 如果是要画线Line line(p1, p2);lineVector.push_back(line);}else if (rdoRect.Checked){	// 如果是要画矩形int width = abs(p2.x - p1.x);int height = abs(p2.y - p1.y);Rect rect(p1, width, height);rectVector.push_back(rect);}// 改变else if (...) {	// 如果是要画圆// ...circleVector.push_back(circle);}// ...this->Refresh();Form::OnMouseUp(e);
}void MainForm::OnPaint(const PaintEventArgs& e) {// 针对直线for (int i = 0; i < lineVector.size(); i++) {e.Graphics.DrawLine(Pens.Red,lineVector[i].start.x, lineVector[i].start.y,lineVector[i].end.x,lineVector[i].end.y);}// 针对矩形for (int i = 0; i < rectVector.size(); i++) {e.Graphics.DrawRectangle(Pens.Red,rectVector[i].leftUp,rectVector[i].width,rectVector[i].height);}// 改变// 针对圆形for (int i = 0; i < circleVector.size(); i++) {e.Graphics.DrawCircle(Pens.Red,circleVector[i]);}// ...Form::OnPaint(e);
}
  • 抽象:运用面向对象的继承多态特性,使用统一的处理方式,来提高代码的复用性
/*
* @file: Shape2.h
*/// 基类
class Shape {
public:// 虚函数,由子类overridevirtual void Draw(const Graphics& g) = 0;// 析构函数也要是virtualvirtual ~Shape() { }
};class Point {
public:int x;int y;
};// 派生类:继承Shape
class Line: public Shape {
public:Point start;Point end;Line(const Point& start, const Point& end) {this->start = start;this->end = end;}// 实现自己的Draw,负责画自己virtual void Draw(const Graphics& g) {g.DrawLine(Pens.Red, start.x, start.y, end.x, end.y);}
};// 派生类:继承Shape
class Rect: public Shape {
public:Point leftUp;int width;int height;Rect(const Point& leftUp, int width, int height) {this->leftUp = leftUp;this->width = width;this->height = height;}// 实现自己的Draw,负责画自己virtual void Draw(const Graphics& g){g.DrawRectangle(Pens.Red,leftUp, width, height);}
};//增加
class Circle : public Shape{
public://实现自己的Draw,负责画自己virtual void Draw(const Graphics& g) {g.DrawCircle(Pens.Red,...);}
};
/*
* @file: MainForm2.cpp
*/class MainForm : public Form {
private:Point p1;Point p2;// 针对所有形状,注意:这里是基类指针Shape*,而非基类对象;// 目的是利用多态,用父类指针指向子类对象,vector中可以存储所有子类对象的指针vector<Shape*> shapeVector;public:MainForm() {//...}
protected:virtual void OnMouseDown(const MouseEventArgs& e);virtual void OnMouseUp(const MouseEventArgs& e);virtual void OnPaint(const PaintEventArgs& e);
};void MainForm::OnMouseDown(const MouseEventArgs& e) {p1.x = e.X;p1.y = e.Y;// ...Form::OnMouseDown(e);
}void MainForm::OnMouseUp(const MouseEventArgs& e) {p2.x = e.X;p2.y = e.Y;if (rdoLine.Checked) {shapeVector.push_back(new Line(p1,p2));	// 将Line*指针放入shapeVector中}else if (rdoRect.Checked) {int width = abs(p2.x - p1.x);int height = abs(p2.y - p1.y);shapeVector.push_back(new Rect(p1, width, height));	// 将Rect*指针放入shapeVector中}// 改变else if (...){// ...shapeVector.push_back(circle);	// 将Circle*指针放入shapeVector中}// ...this->Refresh();Form::OnMouseUp(e);
}void MainForm::OnPaint(const PaintEventArgs& e) {// 针对所有形状for (int i = 0; i < shapeVector.size(); i++) {shapeVector[i]->Draw(e.Graphics); //多态调用,各负其责}// ...Form::OnPaint(e);
}

软件设计的目标

什么是好的软件设计?软件设计的金科玉律:复用

http://www.yayakq.cn/news/308643/

相关文章:

  • 吉林省电力建设总公司网站外贸网站做流量
  • 网站建设费用个人网站代码模板
  • 建个什么网站吗局域网里做网站
  • 澄迈网站新闻建设网站建设起到计划和指导作用
  • 手机电脑网站排名营销方案ppt模板
  • 安全的合肥网站建设邯郸市瑞荣网络科技有限公司
  • 学校网站做网页飘窗怎么做百度seo按天计费
  • 网站建站工具租网站服务器一个月多少钱
  • 做暖暖视频网站gps建站步骤视频
  • 网站接口设置炒币做合约哪个网站最好
  • 企业vi设计的几大特点做seo的网站有那些
  • 公司网站首页设计有什么平台可以推广
  • 手机端h5网站模板下载建设一个网站大概需要多久
  • 乐陵seo网站wordpress utc时间设置
  • 专业的营销型网站百度口碑官网
  • 怎样免费建立自己的网站台州市知名专业做网站
  • 泉州建设网站制作seo优化方案案例
  • copyright技术支持 东莞网站建设网站建设规划模板
  • 响应式网站开发周期网站域名注册流程
  • 手机网站翻译成中文最稳定的免费的资源共享网站
  • 网站跟客户端推广怎么做保定网站制作推广
  • 潍坊网站模板在哪网站访问次数受限
  • 潍坊网站建设wf3wordpress安装第二步
  • 网站中主色调网站设计计费
  • 机顶盒视频网站建设手机前端开发软件工具
  • 如何查看网站的建设方式做seo推广网站
  • 服装网站建设网网站制作报价
  • 网站后台维护月薪多少WordPress如何去掉文章时间
  • 网站如何排名中国建筑装饰网设计师联盟
  • 佛山网站建设科技有限公司网页建站软件