Beauty Is in the Eye of the Beholder
Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.
The content has been bookmarked!
There was an error bookmarking this content! Please retry.
Posted by Werner Schuster on Oct 30, 2007
If you're unfamiliar with EclipseMonkey, it is a set of plugins for Eclipse that allows users to interact with and script the IDE using languages other than Java (initially just Javascript). For more details you may want to take a peek at http://www.eclipse.org/dash/monkey-help.php?key=writing.The design of Eclipse Monkey is an exercise in simplicity - for a reason: one of the project's creators and designers was Ward Cunningham, who - among other things - came up with Wikis in the 1990s. Scripts are text files in a project; any kind of metadata is included in the file itself. Metadata can be dependencies, or a declaration of a shortcut that will run the script. This can go as far as hooking a script up to any event in Eclipse, for instance a file change, file save or the launch of a program.
The EclipseMonkey Ruby extension opens up the ability to script the IDE in Ruby code.
This initial version exposes an Editor DOM, that allows you to manipulate editors with your scripts. We already have some Help pages up on the wiki that describe the details and give more information about the API of the Editor DOM. We've also included some sample scripts that show how to use this feature.
=beginThe other concept of Eclipse Monkey is the DOM, not to be confused with the HTML or XML DOM, which stands for Domain Object Model. It is an object that provides a simpler interface to some functionality for a particular domain.
Menu: Ruby > String to Symbol
Kudos: Christopher Williams
Key: M1+Shift+;
License: EPL 1.0
DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.ruby
=end
# If the current token is a string containing alnums, change it to
# a symbol
editor = $editors.get_active_editor
selection = editor.selection_range
selected_src = editor.source[selection]
# if entire selection is a string with no dynamic content, then
# convert the string to a symbol
match = selected_src.match(/(['"])([_a-zA-Z][_\w]*)\1/)
return if match.nil? || match.size != 3
symbol = ":" + match[2]
editor.apply_edit(selection.first, selection.size - 1, symbol)
$editors variable points to a DOM for handling everything to do with Editors. DOMs are necessary to make scripting an IDE such as Eclipse easy. It would be possible to do the same things by directly accessing Eclipse objects, systems and APIs, but the scripts would often be more complicated. This stems from the fact that the Eclipse design is very flexible, and has various concepts that make it as extensible as it is - but this means that a call such as $editors.get_active_editor would be 2-3 lines of code instead of a single expression.org.eclipse.eclipsemonkey.dom, so writing a simplified interface to functionality is very easy, given Eclipse's Plugin Development Environment (PDE). Eclipse Monkey metadata also helps with configuration management for DOMs: a script's metadata section can specify the update site for the required DOM(s), which are fetched by the system when the script runs.A Guide to Branching and Merging Patterns
Using Drools? See what you're missing! Get the Power of Drools with the Assurance of Red Hat
agility@scale eKit: 10 Principles, Scaling Model, Metrics, Collaboration
Agile Development: A Manager's Roadmap for Success
Improve Java Garbage Collection, Runtime Execution, and JVM visibility with Zing
Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.
John Davies examines Visa’s architecture and shows how enterprises have architected complex integrations incorporating Hadoop, memcached, Ruby on Rails, and others to deliver innovative solutions.
Sean Comerford unveils ESPN.com’s architecture, what components are used and why, and the current changes the website goes through.
Are there repeated patterns of failure on Enterprise Agile Enablement efforts? Sanjiv and Arlen discuss Seven Deadly Sins to avoid when adopting Agile in an enterprise.
Erik Dörnenburg answers: What is Enterprise and Evolutionary Architecture?, discussing 4 issues: Turning strategy into execution, Ensuring conformance, Where do the architects sit? Buying or building?
Sean Cribbs explains what Map-Reduce and Riak are, why and how to use Map-Reduce with Riak, and how to convert SQL queries into their Map-Reduce equivalents.
Chris Richardson shows how he ported a relational database to three NoSQL data stores: Redis, Cassandra and MongoDB.
Jean Tabaka challenges the audience to reflect on what Agile practices they are employing, how they are using them, ending with the questions “Why have their organization chosen to go Agile?
2 comments
Watch Thread Reply