首页 \ 问答 \ 如何处理一些使用频繁的库的逐步重构?(How to handle step-by-step refactory of some heavily used libraries?)

如何处理一些使用频繁的库的逐步重构?(How to handle step-by-step refactory of some heavily used libraries?)

我有几个针对多个平台的库,其中一些是实时/不具备STL支持的实时库,更不用说tr1或C ++ 11了。 这意味着一切都使用库自己的字符串/数组/列表/ younameit类。 现在这些平台已经被抛弃,转而支持'纯'C ++ 11和STL(我非常高兴:我做的最新的lib是第一个带有新标准的开发时间,开发时间缩短了很多,而代码质量上升)。

现在我希望新项目不依赖于自定义字符串/数组/ ...类,我打算一步一步地重构:每当我需要一些类时,创建一个副本(不是完整的)重复;仍然有点痛,但有另一种选择吗?)而是使用STL。 在一开始,这可能意味着整个类树可能需要立即更改。 同时原始代码应该在接下来的4年左右继续工作。

实际上我现在面临的主要问题是:我在哪里放这些新课程? 例如

A\A.h depends on B\B.h and string.h

应该成为

a new A.h depending on a new B.h and <string>

我是否新建了NewA课并加入了Ah? 或者在新的命名空间中创建一个A类并将其存储在A\newA.h ? 或者我创建一个全新的子目录结构,如new\A\Ahnew\B\bh

我知道已经有几个类似的问题,有很好的答案,但我想要一些更实用的建议,而不是“阅读有效使用遗留代码”。 虽然这是理智的答案,但我对在类似情况下的实际行动更感兴趣?

编辑一些说明:

  • 大多数当前应用程序也将被移植到及时使用STL,因为它们都将在新平台上运行(仍然对RTX或InTime有疑问,但其中之一)。
  • 我确实使用了VCS,git,而且几乎所有重要的东西都被单元测试所覆盖。 否则这将是疯狂的。
  • 没有真正的团队,而且我自己(不幸的是,当涉及到这样的事情时,我无法将我的同事视为团队成员,虽然我的年龄几乎是我的两倍,他的编程水平不到我的一半,而且我是甚至不熟练。

I have a couple of libraries that were targetting multiple platforms, of which some realtime ones that did/do not have decent STL support, let alone tr1 or C++11. This means everything uses the library's own string/array/list/younameit classes. Now these platforms are getting abandoned in favour of 'pure' C++11 and STL (which I am very very glad for: the latest lib I did is the first one with the new standard and development time has shortened a lot, while code quality went up).

Now I want new projects to not depend on the custom string/array/... classes, and I'm planning to go for a step-by-step refactory: whenever I need some class, create a duplicate (well not a complete duplicate; still that hurts, but is there another option?) that uses STL instead. In the beginning that might mean a whole tree of classes might need changing at once. At the same time the original code should keep working for the next 4 years or so.

Practically the main question I'm facing now is: where do I put these new classes? For example

A\A.h depends on B\B.h and string.h

should become

a new A.h depending on a new B.h and <string>

Do I make a new class NewA and put in in A.h? Or make a class A in a new namespace and store it in A\newA.h? Or do I make a whole new subdirectory structure like new\A\A.h and new\B\b.h?

I know there are already a couple of similar questions, with great answers, but I'd like some more practical advice, not "read Working Effectively with Legacy Code". Though that is, with reason, a good answer, I'm more interested in what you practically did in a similar situation?

edit some clarification:

  • The majority of the current applications will also be ported to use STL in time as they will all run on the new platform (still in doubt about RTX or InTime, but one of those).
  • I do use a VCS, git, and pretty much everything that matters is covered by unit tests. Else this would be madness.
  • There's no real team and I'm on my own (unfortunately I cannot count my collegue as a team member when it comes to things like this, though being almost twice my age his programming level is less then half of mine, and I'm not even that skilled.

原文:https://stackoverflow.com/questions/7244471
更新时间:2023-10-02 07:10

最满意答案

Go插件当前使用术语Go Libraries来表示不同的GOPATH值。 如果您要为所有项目使用单个GOPATH,则可以将其添加到“全局库”中。 例如,我的$ GOPATH是/ home / florin / golang,在插件中,我从Go Libraries设置中设置了全局库以反映这一点(参见此截图)。

单GOPATH手动设置

如果插件可以自动检测到GOPATH,并且你勾选了复选框,那么插件会尝试使用该值作为GOPATH值,请参阅下一个屏幕截图

自动检测GOPATH

此外,该插件现在有三种不同类型的GOPATH值:

  • 全局库 - >你应该在这里为你想要在不同项目之间共享的GOPATH值设置GOPATH条目(大多数用例)
  • 项目库 - >您应该在此处设置GOPATH条目,以获取仅适用于当前项目的GOPATH值(当您希望每个项目方法具有单个GOPATH时)
  • 模块库 - >这是一个非常具体的设置,它仅用于项目中有不同的模块,并且您希望为每个模块配置不同的GOPATH。 在这种情况下,模块是IDE中源代码的特定逻辑分组,而不是Go项目使用的包(想想在同一个项目中有Python模块,Go模块和Android模块的能力) )。

有一张票据计划进一步简化,您的输入将被包括在内。

希望能帮助到你。


the Go plugin currently uses the term Go Libraries for different GOPATH values. If you have a single GOPATH that you'd like to use for all the projects, then you can add it to the "Global Libraries". For example, my $GOPATH is /home/florin/golang and in the plugin I've set the Global Libraries from the Go Libraries setting to reflect that (see this screenshot).

Single GOPATH manual setting

If the plugin can automatically detect the GOPATH, and you have the check box ticked for that, then the plugin will try and use that value as the GOPATH value, see the next screenshot

Automaticaly detected GOPATH

Also, the plugin has three different types of GOPATH values right now:

  • the Global Libraries -> you should set GOPATH entries here for GOPATH values that you want to share between different projects (most use-cases)
  • Project Libraries -> you should set the GOPATH entries here for GOPATH values that are specific to the current project only (when you want to have a single GOPATH per project approach)
  • Module Libraries -> this is a very specific setting, it's only used in case you have different modules in your project and you want to have a different GOPATH configuration for each of the modules. The module in this case is a specific logical grouping of the source code in the IDE, not in the packages that the Go project uses (think of the ability to have a Python module, a Go module and an Android module all in the same project).

There's a ticket that plans to simplify this further and your input will be included.

Hope it helps.

相关问答

更多
  • 插件的alpha版本不需要您编译它。 请按照自述文件https://github.com/go-lang-plugin-org/go-lang-idea-plugin/#pre-release-builds中的说明进行操作,您应该能够正确安装它。 1)按照https://www.jetbrains.com/idea/help/managing-enterprise-plugin-repositories.html上的说明进行操作 2)粘贴您想要的版本的网址: alpha: https : //plugins ...
  • 在没有警告的情况下构建我的项目 - >您需要使用完整的包名称(例如,您需要使用“github.com/dlsniper/demo”获取GOPATH /home/florin/go下的包和完整路径$GOPATH/src/github.com/dlsniper/demo 。或者,您可以使用Run Kind目录并将其指向目录,或者只需使用func main旁边的绿色箭头,单击它,选择Run ... ,然后选择Go Application 调试我的项目 - >一旦你得到你的Run Configuration类型的G ...
  • 这些是我们在C ++ 中的指针。 不同之处是: 而不是->调用指针上的方法,你总是使用. ,即pointer.method() 。 没有悬空指针。 返回指向局部变量的指针是完全有效的。 Golang将确保对象的生命周期,并在不再需要时对其进行垃圾收集。 可以使用new()或通过创建对象object{}并使用&获取其地址来创建指针。 Golang不允许指针算术(数组不会衰减到指针)和不安全的转换。 所有向下转换都将使用变量的运行时类型进行检查,并且当实例属于错误类型时,要么panic或返回false作为第二个 ...
  • 插件现在在插件的官方插件库中发布,所以除非你真的想要获得最新版本,我建议你使用这些版本。 the plugin is now released in the official plugin repository for plugins so unless you really want to get the bleeding edge versions, I'd recommend you to use those versions.
  • 谢谢@ CrazyCoder! 这绝对是。 事实证明,在系统重启后(不仅仅是IntelliJ重启),IntelliJ能够获取我放入/etc/enviornment的变量。 甚至不需要将它们添加到~/.profile 。 感谢您的研究! Thank you @CrazyCoder! That was definitely it. Turns out that after a system restart (not just an IntelliJ restart), IntelliJ was able to ...
  • 安装新golang IDEA插件的最新预发布版本 。 最近由两位Jetbrains员工进行了大量的工作,并且它比目前发布的版本好得多。 Install the latest pre-release build of the new golang IDEA plugin. There's been a lot of work recently on it by two Jetbrains employees and it's gotten much better than the currently rele ...
  • builtin.go中的代码用作文档。 代码未编译。 ...指定函数的最终参数是可变参数。 Go语言规范中记录了变量参数。 Type部件是任何Go类型的替身。 The code in builtin.go serves as documentation. The code is not compiled. The ... specifies that the final parameter of the function is variadic. Variadic parameters are docume ...
  • 目前这个功能没有在插件中实现,但我已经为它打开了一个问题。 如果您想跟踪它,请关注此问题 at the moment this feature is not implemented in the plugin but I've opened a issue for it. If you want to track it, the please follow this issue
  • 不确定我是否理解这个问题。 但是在sublime text build console中,有tskill命令可以杀死从控制台发起的活动任务。 因此,您可以键入Ctrl+B来调用控制台并键入tskill以tskill运行的web.go任务。 还有其他别名tskill , task replay or task go 。 参考在这里 。 之后,您可以运行其他命令,包括go run。 还有一个replay命令。 “这就像运行,但尝试在运行之前取消任何活动的执行”。 我觉得它看起来像你想要的。 此 ...
  • Go插件当前使用术语Go Libraries来表示不同的GOPATH值。 如果您要为所有项目使用单个GOPATH,则可以将其添加到“全局库”中。 例如,我的$ GOPATH是/ home / florin / golang,在插件中,我从Go Libraries设置中设置了全局库以反映这一点(参见此截图)。 如果插件可以自动检测到GOPATH,并且你勾选了复选框,那么插件会尝试使用该值作为GOPATH值,请参阅下一个屏幕截图 此外,该插件现在有三种不同类型的GOPATH值: 全局库 - >你应该在这里为你想 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。