您是否使用目录在大源代码文件的开头列出类的所有函数(可能还有变量)?我知道这种列表的替代方法是将大文件拆分为较小的类/文件,这样它们的类声明就足够不言自明了。但是一些复杂的任务需要大量代码。我不确定花时间将实现细分为多个文件真的值得吗?或者可以在类/接口声明之外创建一个索引列表吗?
编辑:
为了更好地说明我如何使用目录,这是我的爱好项目中的一个示例。它实际上不是列出函数,而是函数内部的代码块..但无论如何你可能会明白..
/*
CONTENTS
Order_mouse_from_to_points
Lines_intersecting_with_upper_point
Lines_intersecting_with_both_points
Lines_not_intersecting
Lines_intersecting_bottom_points
Update_intersection_range_indices
Rough_method
Normal_method
First_selected_item
Last_selected_item
Other_selected_item
*/
void SelectionManager::FindSelection()
{
// Order_mouse_from_to_points
...
// Lines_intersecting_with_upper_point
...
// Lines_intersecting_with_both_points
...
// Lines_not_intersecting
...
// Lines_intersecting_bottom_points
...
// Update_intersection_range_indices
for(...)
{
// Rough_method
....
// Normal_method
if(...)
{
// First_selected_item
...
// Last_selected_item
...
// Other_selected_item
...
}
}
}
请注意,索引项没有空格。因此,我可以单击其中一个并按 F4 跳转到项目用法,然后按 F2 跳回(简单的 Visual Studio 查找下一个/上一个快捷方式)。
编辑:
此索引的另一种替代解决方案是使用折叠的 c# 区域。您可以将 Visual Studio 配置为仅显示区域名称并隐藏所有代码。当然,对源代码导航的键盘支持非常麻烦……