有时我必须在课堂上编写大代码,所以我所做的是这样的,
Class ABC //it's a web service class
{
Public void Method-1() //used "-" for easy to read
{
//DoSomething and get something from database
Method-2(pass parameters that i got from database);
}
Public void Method-2(parameters)
{
DoSomething again and get data from another database. and some other source
do some processing by calling web services (just as example)
Method-3(parameter);
}
Public void Method-3(parameters)
{
DoSomething again and get data from another database. and some other source
do some processing by calling web services (just as example)
Method-4(parameter);
}
// and it keeps going
}
另一种方式
Class ABC //it's a web service class
{
Public void Method-1() //used "-" for easy to read
{
Method-2();
Method-3();
Method-4();
// so on....
}
}
这是正确的做法吗?如果不是,那么最好的做法是什么?
编辑
@Sayse我正在尝试从不同来源获取信息并尝试构建一个大的XML文件,这使我可以使用4、5个foreach循环从sql等中获取数据。所以使用嵌套方法