I like using SQLDeveloper. To make it a more powerful tool I’d like to see some enhancement to the tools automatic refactoring capabilities.
“Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior.” - Martin Fowler https://martinfowler.com/bliki/DefinitionOfRefactoring.html
The value of automatic refactoring is that it is automated and so low risk. As a result a developer can have high confidence that she will not change program behaviour as a result of careful changes.
Refactoring is useful when looking to improve a programs structure to make it more readable; separating out dependencies to reduce cognitive load; and when moving an implementation towards a more loosely coupled, highly cohesive technical architecture.
Personally, I also find I regularly restructure and re-organise my automated test suites - moving tests between packages and renaming functions and procedures. I use a programmatic test framework called utPLSQL (http://utplsql.org) so test and treated as just more PLSQL code that automatic refactoring rules could be applied to.
Automated refactoring can also be useful when dealing with existing code that has no automated tests. A first step to introduce a test suite can sometimes be to apply refactoring steps to the code to expose testable pieces. Without automated refactoring this can be a risky manual task. It’s better to rely on an IDE with good automated refactoring support and significantly reduced regression risk.
For all refactoring, I’d like SQLDeveloper to understand my project (all types of database objects with DDL capture in files held in a local filesystem based workspace, with each files revision history stored in configuration control e.g. subversion or git ) and make any refactoring change consistent throughout my project.
Here are the refactoring last I have come up with - I’m sure there are more, but these are the one I think the SQLDeveloper community might find most useful;
- Extract selected functions and procedures to new package, or type
- Move selected functions and procedures to an existing package, or type
- Create a new type from selected text
- Rename procedure or function (and have all references in project updated)
- Change procedure/ function signature to enable adding of additional parameters with default value and addressiall call sites across project
- Introduce Indirection - creates a new function/ procedure that delegates to the highlighted procedure/ function and amends all call sites in project
What does the community think? Would they find the above useful? Does the SQLDeveloper team have appetite to support extending this capability?
Hi thatJeffSmith-Oracle - this follows a brief twitter exchange we had. Please let me know if there's any more clarification needed and I’ll come back and update.
Thanks in advance for any responses. Also thanks to the SQLDeveloper team for producing such a great tool, and having such a great focus on the developer user community.