- VisualStudio2022插件的安装及使用-编程手把手系列文章
- pprof-在现网场景怎么用
- C#实现的下拉多选框,下拉多选树,多级节点
- 【学习笔记】基础数据结构:猫树
OOP 和 UML 类图 OOP 与 Java 。
Superclass and subclass 超类和子类 。
Encapsulation – Hiding parts of an object’s states and behaviors from others, and exposing a limited set of interfaces – public, private, and protected – Interfaces and abstract classes 封装 — 隐藏对象的部分内容和来自他人的状态和行为,并公开一组有限的接口 – 公共、私有和受保护 – 接口和抽象类 。
Inheritance – Main benefit: code reuse 继承 — 主要好处:代码重用 。
Polymorphism – Performing an action in many forms – A mechanism for detecting the real class of an object and call its implementation 多态性 多种形式执行一个动作 一种检测对象的真实类并调用其实现方法的机制 。
Class declaration 类声明 。
Creating objects 创建对象 。
Classes can be derived from other classes, inheriting fields and methods 类可以从其他类派生,继承字段和方法 。
Definitions 定义 – Subclass (derived class/extended class/child class) – Superclass (base class/parent class) – 子类(派生类/扩展类/子类) – 超类(基类/父类) 。
Every class has one and only one direct superclass (single inheritance) 每个类都有一个且仅有一个直接超类(单继承) – Excepting Object, which has no superclass 除了Object,它没有超类 。
A subclass inherits all the members (fields, methods, and nested classes) from its superclass 子类继承其超类的所有成员(字段、方法和嵌套类) 。
Use the inherited members as is, replace them, hide them, or supplement them 按原样使用继承的成员、替换它们、隐藏它们或补充它们 。
How about private members in a superclass?
Consider using abstract classes when 考虑使用抽象类 – You want to share code among several closely related classes – 您希望在几个紧密相关的类之间共享代码 – You expect that classes extending the abstract class have many common methods or fields, or require access modifiers other than public – 您希望扩展抽象类的类具有许多通用方法或字段,或者需要除 public 之外的访问修饰符 – You want to declare non-static or non-final fields — 您想要声明非静态或非最终字段 。
Consider using interfaces when 考虑使用接口 – You expect that unrelated classes would implement your interface – 您希望不相关的类实现您的接口 – You want to specify the behavior of a particular data type, but not concerned about who implements its behavior – 您想要指定特定数据类型的行为,但不关心谁实现其行为 – You want to take advantage of multiple inheritance – 您想要利用多重继承 。
最后此篇关于学习高校课程-软件设计模式-OOP和UML类图OOP与Java(lec1)的文章就讲到这里了,如果你想了解更多关于学习高校课程-软件设计模式-OOP和UML类图OOP与Java(lec1)的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 4年前关闭。 Improve t
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
在面向对象的编程中,“基类”是派生其他类的类(http://en.wikipedia.org/wiki/Base_class)。 但是,基类的反面是什么?换句话说,什么是没有任何子类的类? 编辑:我正
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 8年前关闭。 Improve this questi
据我了解,OOP 是大型项目最常用的范式。我也知道大系统的一些较小的子集使用其他范式(例如 SQL,它是声明性的),并且我也意识到在较低级别的计算 OOP 并不真正可行。但在我看来,通常更高级别的解决
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
最近听说OOP(Java)有9条规则。我只知道四种:抽象、多态、继承和封装。 OOP 还有更多规则吗? 最佳答案 看来您正在寻找的是 Principles of Object-Oriented Des
我曾经在一次采访中被问到“OOP 的 3 个主要概念是什么?”。我回答说,我认为有4个,如下: 继承 封装 抽象 多态性 我说得对吗? 最佳答案 语言要成为面向对象有3个要求: 仅支持封装(对象)的语
我有一个关于特定 OOP 问题的组织的简单问题。 假设我有一个地形类,里面充满了瓷砖。 Tile 类有多个派生类,即 Door。 Door 类有一个名为 open() 的方法,用于打开门,还有一个名为
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
我是 Go 的新手,然后我通过示例搜索了很多如何拥有带有静态函数/变量的静态类,例如 C#。但是,我找不到任何可以很好地回答它的东西。也许这个问题看起来很愚蠢,但我不喜欢不确定或不完全理解某事。 假设
我曾尝试搜索此问题的答案,但很难用语言表达,而且许多问题要么是关于如何创建类,要么是关于如何做非常具体的事情。我需要更多的实用概述 - 我是自学成才的,我了解对象是什么(以及如何创建它们),但我从未见
在开始编码之前,我通常会尝试在没有太多分析(没有图表)的情况下进行 TDD。通常我发现自己将一个类拆分为其他类以分离关注点。我想知道更深入的分析是否会阻止这种情况。我认为大部分面向对象分析无法预测其中
在阅读单例时,我发现这个解释是使用单例的原因: since these object methods are not changing the internal class state, we can
如这里所述 https://standardofnorms.wordpress.com/2012/09/02/4-pillars-of-object-oriented-programming/ 并作为
我是这个网站的新手,所以如果我在发布问题时做错了什么,请告诉我,以便我下次修复。 我很好奇从单个基类继承多个类是否是糟糕的 OOP 实践。这可能不太合理,所以我要详细说明一下。 例如,假设您正在设计一
我对“工厂相关”设计模式及其 OOP 实现的理解一直很简单。 一个 《工厂法》是类内部的一个方法,它有一个接口(interface)(或抽象类)作为返回类型,并根据一些内部逻辑构造实现该接口(inte
C# 中的“密封”关键字,Java 中的 Final。 因为我几乎从不创建任何图表并且我只使用已经完成的类(来自框架)我多年后仍然不知道为什么有人会“锁定”一个类所以它永远不会被扩展/继承。 它是有益
我正在研究面向对象的概念,抽象概念基本上被描述为对用户隐藏实现。因此,如果类中有一个成员函数并且我们为某些任务调用该函数,抽象表示用户不应该关心事情是如何完成的,而应该只知道正在完成什么。但即使在非面
我是一名优秀的程序员,十分优秀!