学习 - 可扩展性:动态加载和任何其他无需重新编译的软件更新
我正计划编写一个程序,但我陷入了一个难题。我不想开始写一些东西,然后当我发现我的程序不可扩展时必须全部重写。另一个问题是我没有足够的编程知识来知道从哪里开始设计我的程序以使其可扩展。
我已经阅读了一些有关 DLL(或 unix 的延迟加载)、动态加载、运行时库加载/卸载等的内容,但我仍然不太明白我需要做什么。我将给出一个示例程序示例,如果有人可以引导我朝着正确的方向学习,以便我的更大的程序可以开始,我将非常感激!
假设我创建了一个控制台程序“iAmDog”,您可以在其中输入命令,狗将相应地响应并输出到控制台。现在假设当我创建这个程序时,狗只有 1 个命令“bark”,它会生成输出“roof heaven!”。我将如何编写这个程序,以便当用户仍在运行该程序时,我可以编辑库或在其他地方编写代码,以向狗的指令添加“坐”命令。
同样,理想情况下,我的计划是没有停机时间或尽可能减少停机时间,同时能够对始终运行的程序的功能进行代码更新。
感谢您的阅读!
拉塞尔又名普基中士
I'm planning on writing a program but I am stuck in a conundrum. I don't want to start writing something and then have to rewrite it all when I find out that my program is not extensible. The other problem, is I do not have enough programming knowledge to know where to begin designing my program so that it is extensible.
I have done some reading on DLLs (or delayed loading for unix), dynamic loading, run-time library loading/deloading, etc.. but I still cannot quite comprehend what I need to do. I will give a sample program example, and if someone could lead me in the right direction for what to learn so my bigger program can begin, I will be extremely grateful!
Let's say I create a console program 'iAmDog' where you can type in commands, and the dog will respond accordingly with output to the console. Now let's assume when I create this program, the dog only has 1 command, 'bark' which produces the output 'roof roof!'. How would I go about writing this program so that while the user is still running the program, I can edit a library, or code somewhere else, to add a 'sit' command to the dogs repertoire.
Again, Ideally my plan is to have no downtime or as minimal downtime as possible, all while being able to code updates to functionality of the always running program.
Thank you for reading!
Russell aka SgtPooki
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用 .NET 吗?那么 MEF(托管可扩展性框架)可能非常适合您。
Hanselmillions 上有一个关于 MEF 的播客。您可以找到 mp3 和 PDF 文字记录,以便您搜索该节目。他们甚至讨论了持续监视文件夹更新的可能性,以实现您所描述的目的,尽管他们不鼓励这样做。
Are you using .NET? Then MEF, Managed Extensibility Framework, is probably suited well for you.
There is a podcast on Hanselminutes about MEF. You find an mp3 as well as a PDF transcript, that lets you search the show. They even discuss the possibility to continuously watch a folder for updates, to achieve what you descripbe, although they discourage to do this.