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

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.

主站蜘蛛池模板: 尚义县| 綦江县| 巨野县| 和林格尔县| 始兴县| 平乐县| 永善县| 台南市| 沛县| 长宁县| 吴旗县| 西安市| 中宁县| 赤城县| 辽中县| 东丽区| 辛集市| 兴化市| 汶上县| 黄山市| 海原县| 南阳市| 江都市| 桃园市| 安丘市| 阿坝| 个旧市| 南岸区| 阳信县| 扶风县| 靖江市| 沙坪坝区| 万源市| 久治县| 陵水| 奉化市| 阳江市| 平罗县| 军事| 芦溪县| 秭归县|