官术网_书友最值得收藏!

Understanding UML class diagrams

Software developers have their own form of blueprints as well, but they look different from what you may be used to. In order to create them, developers use a format called Unified Markup Language, or UML for short. This simple diagramming style was primarily created by Jim Rumbaugh, Grady Booch, and Ivar Jacobson and has become a standard in software development due to the fact that it works with any programming language. We will be using them when we need to display details or concepts to you via diagrams.

Design patterns are usually best explained through the use of class diagrams, as you're able to give a demonstration of the idea while remaining abstracted. Let's consider the following class:

class Enemy  
{
public:
void GetHealth(void) const;
void SetHealth(int);
private:
int currentHealth;
int maxHealth;
};

Converted to UML, it would look something like this:

Basic UML diagrams consist of three boxes that represent classes and the data that they contain. The top box is the name of the class. Going down, you'll see the properties or variables the class will have (also referred to as the data members) and then in the bottom box you'll see the functions that it will have. A plus symbol (+) to the left of the property means that it is going to be public, while a minus symbol (-) means it'll be private. For functions, you'll see that whatever is to the right of the colon symbol (:) is the return type of the function. It can also include parentheses, which will show the input parameters for the functions. Some functions don't need them, so we don't need to place them. Also, note in this case I did add void as the return type for both functions, but that is optional.

主站蜘蛛池模板: 朝阳区| 义乌市| 连州市| 宜宾县| 铜梁县| 呼玛县| 怀化市| 澳门| 五常市| 阿城市| 成安县| 曲阜市| 手机| 贺州市| 徐州市| 柘荣县| 饶河县| 唐河县| 邯郸市| 昆山市| 宿州市| 义马市| 嘉鱼县| 清镇市| 久治县| 浑源县| 天门市| 铜鼓县| 淮南市| 绥滨县| 台北县| 邵阳县| 三河市| 收藏| 清原| 定安县| 竹山县| 顺昌县| 库尔勒市| 丹巴县| 巴楚县|