{"id":554,"date":"2009-08-27T17:52:30","date_gmt":"2009-08-27T07:52:30","guid":{"rendered":"http:\/\/www.malcolmgroves.com\/blog\/?p=554"},"modified":"2015-03-13T11:04:37","modified_gmt":"2015-03-13T00:04:37","slug":"refactoring-support-for-attributes-in-delphi-2010","status":"publish","type":"post","link":"http:\/\/www.malcolmgroves.com\/blog\/?p=554","title":{"rendered":"Refactoring Support for Attributes in Delphi 2010"},"content":{"rendered":"<p>I <a href=\"http:\/\/www.malcolmgroves.com\/blog\/?p=500\">mentioned<\/a> earlier that a lot of work in this release had gone into smaller features and feature tweaks. One of the results is that the IDE keeps giving me pleasant surprises. I\u2019ll try to do something without even really thinking about whether it should work or not, and find that it not only works, but that it goes a little further than I might have thought.<\/p>\n<p>One example is around Refactoring support for Attributes. If you look at my first<a href=\"http:\/\/www.malcolmgroves.com\/blog\/?p=476\">, simple example of Attributes<\/a>, one of the many things wrong with it is that the Attribute name is terrible. Unless I never plan on writing more than one Attribute, MyAttribute is probably not the best choice.<\/p>\n<p><!--more-->No problem, Delphi has supported a rename refactoring for awhile now, I\u2019ll just use that. Right-click on the identifier, select Refactoring | Rename, give it a great new name like, oh, NameAgeAttribute (much better ;-)) and press OK.<\/p>\n<p>At this point I expected it to rename all the actual occurrences of the class name in code, but I half expected it to not deal with the actual [MyAttribute\u2026] occurrences. I definitely didn\u2019t expect it to handle the places where I\u2019d left off the Attribute suffix.<\/p>\n<p>Well, look at the screenshot below and you\u2019ll see that I underestimated it greatly. As a refactoring should, it handled every one of my cases, and left my code in a state that compiles and runs exactly as it did before.<\/p>\n<p>Nice one guys!<\/p>\n<p><a href=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2009\/08\/renameattribute.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px 10px 0px 0px; display: inline; border-width: 0px;\" title=\"RenameAttribute\" src=\"http:\/\/www.malcolmgroves.com\/blog\/wp-content\/uploads\/2009\/08\/renameattribute-thumb.jpg\" alt=\"RenameAttribute\" width=\"442\" height=\"412\" border=\"0\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I mentioned earlier that a lot of work in this release had gone into smaller features and feature tweaks. One of the results is that the IDE keeps giving me pleasant surprises. I\u2019ll try to do something without even really thinking about whether it should work or not, and find that it not only works, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[98],"tags":[50,19,48,56],"class_list":["post-554","post","type-post","status-publish","format-standard","hentry","category-coding","tag-attributes","tag-delphi","tag-embarcadero","tag-refactoring"],"_links":{"self":[{"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/554","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=554"}],"version-history":[{"count":2,"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/554\/revisions"}],"predecessor-version":[{"id":1796,"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/554\/revisions\/1796"}],"wp:attachment":[{"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=554"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}