来自相同代码库的命令行和UI工具? [英] Commandline and UI tool from the same codebase?

查看:64
本文介绍了来自相同代码库的命令行和UI工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决此问题的最佳(或通常)方法是什么?

我目前有一个可工作的代码库,带有一个UI前端.我受命创建同一工具的命令行版本.当然,这将需要进行一些代码更改,以允许使用命令行参数等,但是如何在两个版本的程序中使用相同的后端类呢?
我应该以某种方式使用条件编译吗?

这将在Visual Studio Express 2008(或2010)中完成,而无需任何形式的源代码控制(是的,我知道我应该使用它,但是不幸的是,由于安全问题,我现在不能选择这样做)我自己的机器,以及我对颠覆之类的免费软件工具的要求均被拒绝,因为免费软件很糟糕",而Express版本无法与TFS配合使用,并且我也无法获得VS的完整版本)

感谢您的任何建议...

What is the best (or usual) way to tackle this?

I currently have a working codebase, with a UI frontend. I have been tasked to create a commandline version of the same tool. This will of course require some codechanges to allow for commandline parameters and such, but how can I work with the same backend classes in both versions of the program?
Should I use conditional compilation somehow?

This is to be done in Visual Studio Express 2008 (or 2010) without any form of source control (yeah, I know I should use it, but unfortunately that is not an option right now, because of security issues, I cannot install anything on my machine myself, and my request for a freeware tool like subversion has been turned down because ''freeware is bad'', and the Express versions don''t work with TFS, and I don''t get a full version of VS)

Thanks for any advice...

推荐答案

希望您的项目已经正确编写,并且Presentation层与Business层分离.如果不是,那将成为一场噩梦-现在就将它们分开.

理想情况下,您需要在DLL项目中进行业务放置,该项目可通过引用"从Presentation层(在单独的WinForms项目中)访问.在这种情况下,创建一个同时访问业务层DLL的新CommandLine项目是相对简单的事情.

如果您没有将它们很好地分开,那么您将痛苦不堪!
Hopefully, your project is already written properly, with the Presentation layer separate from the Business Layer. If it isn''t then it will become a nightmare - so separate them now.

Ideally, you want the Business Lay in a DLL project, which is accessed from the Presentation layer (in a separate WinForms project) via a Reference. In this case it is a relatively simple matter to create a new CommandLine project which also accesses the Business Layer DLL.

If you don''t have them well separated, then you are in for a world of pain!


首先,您似乎在混淆两个不同的概念:控制台应用程序和命令行.您始终可以在不使用控制台的情况下使用命令行,事件.您甚至可以使用完全相同的代码处理命令行参数来开发控制台和窗口应用程序.

当然,您可以使用条件编译,但这不是最佳选择,也不是以易于维护的形式组织软件的最佳方法.

我建议抽象出用户界面,以便您的应用程序可以将两个不同的前端用作两个(或更多)不同的应用程序;其中一个可以是控制台应用程序,另一个可以是WPF或System.Windows.Forms应用程序.您需要将它们全部放在一个解决方案中.大多数代码应位于两个或多个应用程序使用的类库中.

顺便说一句,您可以使用我易于使用的库来处理命令行参数:基于枚举的命令行实用程序 [ ^ ].

对于修订控制:即使没有修订控制,即使是最简单的工作也很愚蠢. 我将使用修订控制系统停止所有操作并实施适当的开发程序.

请参阅:
http://www.joelonsoftware.com/articles/fog0000000043.html [版本控制系统,有哪些可供选择? [ ^ ].

另请参阅我过去关于该主题的答案:
需要一些单词设置和/或使用服务器的明智之举 [制作不可点击的表单 [如何结构化安排源代码当我创建新解决方案时 [这是开源的,这是完全不同的.有人会告诉你开源不好"吗?甚至他们不会告诉您,仅基于他们已经告诉您的事实:丑陋的事实是:您与极端白痴一起工作.

因此,我不知道该如何帮助您.某些事情无法治愈.如果您愿意,请向他们显示我的帖子.他们可以通过CodeProject轻松与我联系并讨论此问题,但是我怀疑他们会这样做. :-)

—SA
First of all, it looks like you are mixing up two different notions: console application and command line. You can always use command line, event without console. You can even develop console and windowed application using exact same code processing command line parameters.

You can use conditional compilation, of course, but this is not the best option, and not the best way to organize software in a form good for maintenance.

I would advise to abstract out user interface so your application could use two different front ends as two (or more) different applications; one of them could be a console application, another one a WPF or System.Windows.Forms application. You need to put them all in one solution. Most of the code should be in the class libraries used by two or more applications.

By the way, you can use my easy-to-use library for processing command line parameters: Enumeration-based Command Line Utility[^].

As to the Revision Control: doing even the simplest work without Revision Control is just silly. I would stop everything and implement proper development procedures with Revision Control system.

Please see:
http://www.joelonsoftware.com/articles/fog0000000043.html[^].

See also this discussion: Revision control systems, which to choose from?[^].

Please also see my past answers on this topic:
Needs some words of wisedom to set up and/or use a server[^],
Make an unclickable form[^],
How can i structured to arrange source code when i create a new solution[^].

If you read these answers, you will probably understand my point of view I going to tell you below.

Subversion is not "freeware", not at all. It is Open Source, which is absolutely different thing. Will somebody tell you that "Open Source is bad"? Even it they won''t tell you than, based just on the fact they already told you: the ugly truth is this: you are working with extreme idiots.

Therefore, I don''t know how to help you. Certain things are not curable. If you want, show them my post. They can easily contact me through CodeProject and discuss this problem, but I doubt they will. :-)

—SA


这篇关于来自相同代码库的命令行和UI工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆