生命周期函数的命名
有人对生命周期名称有建议吗?生命周期函数是那些控制软件工程构造的创建和终止的函数。
示例:
- new/delete
- init/finish
- create/destroy
- connect/disconnect 构造函数/析
- 构函数
考虑以下场景:
myObjectPtr = myObjectCreate();
myObjectDoSomething(myObjectPtr,1,2.34);
myObjectDoSomethingElse(myObjectPtr,"a string");
myObjectDestroy(myObjectPtr);
Does anyone have suggests for life-cycle names. Lifecyle functions are those that control the creation and termination of software engineering constructs.
Examples:
- new / delete
- init / finish
- create / destroy
- connect / disconnect
- constructor / destructor
Consider in the following scenario:
myObjectPtr = myObjectCreate();
myObjectDoSomething(myObjectPtr,1,2.34);
myObjectDoSomethingElse(myObjectPtr,"a string");
myObjectDestroy(myObjectPtr);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你列出的那些听起来不错。一般来说,我会坚持使用已经存在的范例,以使您的代码更易于阅读和维护。特别是,您正在开发的语言或框架可能已经有一个 - 我会同意。在罗马的时候...
The ones you have listed sound good. In general I'd stick with a paradigm that's already in place to make your code easier to read and maintain. In particular, the language or framework you're developing in likely has one already - I'd go with that. When in Rome...