답변 : "실제 코드 구현으로 변환하는 방법은 무엇입니까?" 보통 포인터 또는 shared_ptr의-의 의미
- 화살표,
- 흰색 :
노트와이 UML과 낙타 표기법 자바처럼 보인다는
그러나 여기에는 다이어그램에서 일부 C++ 패턴입니다 머리글 화살표 평균 공개 상속,
<<interface>>
은 Java의 인터페이스 인 C++의 추상 클래스를 의미하며,
- 흰 점선 화살표은 메모입니다. 이 경우 구현 세부 정보가 제공되며 문자 그대로 입력 할 수도 있습니다.
코드를 살펴보기 전에 낙타의 경우를 싫어한다고 말하면서 STL과 부스트와 같은 C++ 라이브러리가 언더 코어 _notation을하도록 권장합니다. 따라서 모든 클래스를 밑줄 표기법으로 변경했습니다. 구현 의 따라서 일부 다음과 같이 보일 수 있습니다 :
class Abstract_platform {
public:
virtual ~Abstract_platform()=0; // this UML does not specify any functions but we make this class abstract.
};
class Platform_one : public Abstract_platform {
};
class Platform_two : public Abstract_platform {
public:
/// you should implement this make function with shared_ptr, OR NO POINTERS AT ALL but I go according to the notes
Product_one_platform_two* make_product_one();
Product_two_platform_two* make_product_two();
// I provide you with a better_make. It is better than the former make functions
// due to RVO (Return value optimization see wikipedia)
// so this is again a hint that this UML was originally for Java.
Product_one_platform_two better_make_product_one();
};
class Class1 {
private:
Abstract_platform* platform; // OR shared_ptr<Abstract_platform>, OR Abstract_platform&
Abstract_product_two* product_two;
};
/// **Implementation file**
Product_one_platform_two* Platform_two::make_product_one()
{
return new Product_one_platform_two();
}
Product_two_platform_two* Platform_two::make_product_two()
{
return new Product_two_platform_two();
}
Product_one_platform_two Platform_two::better_make_product_one()
{
return Product_one_platform_two();
}
은 또한 대신 Abstract_platform
명 "나는" "인터페이스"의 약자 IPlatform
헝가리어 표기법을 선호 있습니다.
[UML] (http://en.wikipedia.org/wiki/Unified_Modeling_Language)을 검색하고 싶습니다. –