tlyons
New Member
United Kingdom
2 Posts |
Posted - Apr 23 2017 : 03:58:03 AM
|
I have been using this software for years, and have always regarded "extract method" as one of the most useful features - as it allowed one to see at a glance, through the signature of the proposed method, the dependencies of a block of code. Often this was all that was needed to rewrite the code better.
Recently this really does not seem to be the case, and your software cannot be relied on to produce code that works after the extraction.
Here is a simple example:
// OrderedTreeTest.cpp : Defines the entry point for the console application. //
#include "stdafx.h" #include <iostream> #include <initializer_list> #include "OrderedTreeLib/Tree.h"
typedef basic_tree<trivial, std::vector> BodyPart;
size_t myTree[] = { 123 , 54, 32, 53, 44, 66, 21, 5 }; int main() { for (auto& x : myTree) { std::cout << x << " "; } std::cout << std::endl; BodyPart t1(std::begin(myTree), std::end(myTree)); std::cout << t1 << "\n";
auto&& heap = t1.max_heap(); for (auto& x : heap) { std::cout << x << " "; } std::cout << std::endl; BodyPart t2(std::begin(heap), std::end(heap)); std::cout << t2 << "\n";
return 0; }
I wanted to extract the duplicated code:
for (auto& x : myTree) { std::cout << x << " "; } std::cout << std::endl; BodyPart t1(std::begin(myTree), std::end(myTree)); std::cout << t1 << "\n";
and it offered to create a method with no arguments! Clearly this cannot work.
A reference to myTree is required and returning t1 in some form to the main code is also required. A signature such as
BodyPart Method(const size_t* myTree)
and embedding in the code:
auto&& t1 = Method(myTree);
seem about right. I appreciate that with the rapidly changing language this must be quite a challenge to keep up with. But it is a functionality that was impressive and if you can no longer deliver it I think it would be helpful to have warnings and clarity as to what you cannot do. |
|