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

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.

主站蜘蛛池模板: 宁海县| 石首市| 陕西省| 荣昌县| 邮箱| 西和县| 富蕴县| 达日县| 万安县| 曲沃县| 托里县| 巨鹿县| 邻水| 方城县| 涞源县| 竹山县| 汝城县| 晋州市| 长泰县| 九寨沟县| 林甸县| 措美县| 顺义区| 彰化市| 霍邱县| 竹山县| 庆元县| 衡阳市| 前郭尔| 河津市| 客服| 和硕县| 刚察县| 边坝县| 巩留县| 西昌市| 贺州市| 广饶县| 日喀则市| 盱眙县| 四平市|