Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: modelSkeleton #38

Merged
merged 4 commits into from
Sep 18, 2023
Merged

feat: modelSkeleton #38

merged 4 commits into from
Sep 18, 2023

Conversation

akastercomcom
Copy link
Collaborator

  • model class생성
  • modelController skeleton생성. ainetwork와 통신하는 ain skeleton 구현 완료 후 작업 이어 하겠습니다.
  • ainize에 model명령어 추가

Copy link
Collaborator

@yoojinko yoojinko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

model controller를 Global Instance로 관리할지 model마다 새 instance를 할당할지 명확히 결정되어야 할 것 같습니다.

@@ -0,0 +1,65 @@
export default class ModelController {
instance: ModelController | undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private static instance ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

적용했습니다. 추가로 코드 수정했습니다.

src/model.ts Outdated

constructor(modelName: string) {
this.modelName = modelName;
this.modelController = new ModelController();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 방식으로 호출하면 ModelController 안에 instance가 없어도 될 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new를 하면 modelController에서 instance를 넘깁니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modelController의 constructor에서 instance가 이미 생성되었다면, if를 통해 instance를 넘깁니다.

private static instance: ModelController | undefined;
constructor() {
if(ModelController.instance) return ModelController.instance;
ModelController.instance = this;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

첫 생성 시에 this가 정상적으로 할당될 수 있는지 잘 모르겠습니다.
static인 instance는 constructor로 초기화하지 않고 static getInstance() 함수를 통해서 받아올 수 있도록 할 수 있을 것 같습니다.

class ModelController {
  private static instance: ModelController;
  static getInstance() {
    if (!ModelController.instance)
      ModelController.instance = new ModelContoller();
    return ModelController.instance;
  }
  ...
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 경우에 instance는 ModelController.getInstance() 로 가져올 수 있습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 좋은 것 같습니다.
수정했습니다.

Copy link
Collaborator

@yoojinko yoojinko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@akastercomcom
Copy link
Collaborator Author

Thanks! now merged

@akastercomcom akastercomcom merged commit a4a9ba5 into develop Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants