<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Gpascar</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Gpascar"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Gpascar"/>
	<updated>2026-05-07T14:06:57Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch7_7e_GP&amp;diff=42767</id>
		<title>CSC/ECE 517 Fall 2010/ch7 7e GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch7_7e_GP&amp;diff=42767"/>
		<updated>2010-11-28T06:32:09Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Protected Variations Pattern =&lt;br /&gt;
GRASP stands for General Responsibility Assignment Software Patterns and defines nine patterns, of which '''protected variations ''' is one [1].&lt;br /&gt;
&amp;lt;blockquote&amp;gt;The protected variations pattern protects elements from the variations on other elements (objects, systems, subsystems) by wrapping the focus of instability with an interface and using polymorphism to create various implementations of this interface.[1]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
What this means is that any points where one system (A) touches another (B) where the implementation of that other system (B) contains variations in it's implementation.  A good example of this is a standard plugin system.  For example, an author may develop a plugin for Microsoft Outlook (a popular enterprise mail application).  The '''protected variations pattern''' means that plugin should be wrapped within some kind of protection that would insulate Outlook from errant behaviors of that plugin.  It may be disastrous if the plugin generated some sort of error that caused the entire application to crash.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
The solution to these problems is very dependent on the system being analyzed.  The first step is to identify all of the points of predicted variation of instability.  Then a developer needs to create a stable ''interface'' around those points [2].  This solution has many potential problems in and of itself.  It assumes a developer is intimately familiar with the entire system and all potential points of variation or instability.  Second, it assumes a developer knows the perfect way to insulate the system from the variation.  Finally, it employs the word ''interface'' in a very broad sense.  It may be a single component, like a very simple object or an external system, like a web server.&lt;br /&gt;
&lt;br /&gt;
=== Insulation ===&lt;br /&gt;
Protecting a system from variations requires a thorough understanding of how the system may be exploited by the variation and what potential problems may arise from such a variation.  For example, a database driver subsystem within the Java language may be insulated by catching ''SQLException'' exceptions.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
try {&lt;br /&gt;
  variant_method();&lt;br /&gt;
} catch ( SQLException e ) {&lt;br /&gt;
  // Handle exception&lt;br /&gt;
}&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, what happens if the variant method generates an ''Exception'' that is not a subclass of ''SQLException''?  In this scenario the ''Exception'' would bubble up out of the protected area.  The obvious solution is to catch all ''Exception''s.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
try {&lt;br /&gt;
  variant_method();&lt;br /&gt;
} catch ( Throwable e ) {&lt;br /&gt;
  // Handle exception&lt;br /&gt;
}&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, this has potentially undesirable effects also.  What happens if there is a system-level exception, such as the system runs out of memory?  This seems like an exception that would need to be communicated to a higher level and not consumed in the protection scheme.&lt;br /&gt;
&lt;br /&gt;
The answer is, it depends.  Generally there will be a documented contract within the ''interface'' of the variant.  The protection then checks that these error conditions don't violate the contract.  This is good design and should be part of a system's design regardless.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Before discussing a specific example, it is important to understand that the '''protected variations''' pattern is present in almost every aspect of design.  Consider virtual machines, plugin containers, sandboxes, configuration files and operating systems as specializations of the this pattern [3].  Generally examples are classified by the type of mechanisms that have motivated the '''protected variations''' pattern in the first place.  The following sections have followed those first described by Larman, but with updated examples.&lt;br /&gt;
&lt;br /&gt;
=== Data-Driven Designs ===&lt;br /&gt;
Any piece of data that is read into a system in order to affect the system's behavior in some manner.  For example, in a Ruby on Rails application the ''database.yml'' file defines database drivers to load and configuration parameters for these drivers.  Some drivers require the definition of a username and password, while others require the definition of a file path, it is up to the driver as to which parameters to require.&lt;br /&gt;
&lt;br /&gt;
=== Service Lookup ===&lt;br /&gt;
This specialization uses a lookup service as a stable interface that is used to find a particular implementation of a component through the use of something like a naming service.  The classic example of this is the Java Naming and Directory Interface (JNDI), another example is the Ruby Gem system.  Using standard commands through the stable gem tool allows a developer to lookup and install gems to perform potentially unstable operations.&lt;br /&gt;
&lt;br /&gt;
=== Interpreter-Driven Designs ===&lt;br /&gt;
The premise behind interpreter-driven designs is an interpreter loads a particular file and executes the commands within that file to affect some result.  The stable interface being the interpreter and the variant the interpreted code file that is loaded.  The Ruby interpreter is a great example of this.&lt;br /&gt;
&lt;br /&gt;
=== Reflective or Meta-Level Designs ===&lt;br /&gt;
This specialization refers to not designing a stable system to a particular interface or implementation, but introspecting that interface at run-time.  For example, a Ruby class would have its methods introspected to find the correct implementation that would then be executed within another protection level.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
class Variant_1&lt;br /&gt;
  def vvv&lt;br /&gt;
    @very_very_verbose = true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
class Variant_2&lt;br /&gt;
  def vv&lt;br /&gt;
    @very_verbose = true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
v = Variant_1.new # or Variant_2.new&lt;br /&gt;
if ( v.methods.include? &amp;quot;vvv&amp;quot; )&lt;br /&gt;
  m = v.method :vvv&lt;br /&gt;
elsif ( v.methods.include? &amp;quot;vv&amp;quot; )&lt;br /&gt;
  m = v.method :vv&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
protect_method_call( m.call )&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
When implemented correctly the '''protected variations''' pattern can provide stability to a system that needs to open itself up to potentially unsafe or unstable variations.  The benefits include [3]&lt;br /&gt;
* Extensions required for new variations are easy to add.&lt;br /&gt;
* New implementations can be introduced without affecting clients.&lt;br /&gt;
* Coupling is lowered.&lt;br /&gt;
* The impact or cost of changes can be lowered.&lt;br /&gt;
&lt;br /&gt;
This pattern is the same as information hiding and the open-closed principal in almost every regard.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# [http://en.wikipedia.org/wiki/GRASP_%28object-oriented_design%29 Wikipedia - GRASP (object-oriented design)]&lt;br /&gt;
# [http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/ProtectedVariations.html Worcester Polytechnic Institute - CS4233: Class 4 Patterns - GRASP]&lt;br /&gt;
# Craig Larman (2004) ''Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, Third Edition'', ISBN : 0131489062&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch7_7e_GP&amp;diff=42766</id>
		<title>CSC/ECE 517 Fall 2010/ch7 7e GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch7_7e_GP&amp;diff=42766"/>
		<updated>2010-11-28T06:17:40Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Protected Variations Pattern =&lt;br /&gt;
GRASP stands for General Responsibility Assignment Software Patterns and defines nine patterns, of which '''protected variations ''' is one [1].&lt;br /&gt;
&amp;lt;blockquote&amp;gt;The protected variations pattern protects elements from the variations on other elements (objects, systems, subsystems) by wrapping the focus of instability with an interface and using polymorphism to create various implementations of this interface.[1]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
What this means is that any points where one system (A) touches another (B) where the implementation of that other system (B) contains variations in it's implementation.  A good example of this is a standard plugin system.  For example, an author may develop a plugin for Microsoft Outlook (a popular enterprise mail application).  The '''protected variations pattern''' means that plugin should be wrapped within some kind of protection that would insulate Outlook from errant behaviors of that plugin.  It may be disastrous if the plugin generated some sort of error that caused the entire application to crash.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
The solution to these problems is very dependent on the system being analyzed.  The first step is to identify all of the points of predicted variation of instability.  Then a developer needs to create a stable ''interface'' around those points [2].  This solution has many potential problems in and of itself.  It assumes a developer is intimately familiar with the entire system and all potential points of variation or instability.  Second, it assumes a developer knows the perfect way to insulate the system from the variation.  Finally, it employs the word ''interface'' in a very broad sense.  It may be a single component, like a very simple object or an external system, like a web server.&lt;br /&gt;
&lt;br /&gt;
=== Insulation ===&lt;br /&gt;
Protecting a system from variations requires a thorough understanding of how the system may be exploited by the variation and what potential problems may arise from such a variation.  For example, a database driver subsystem within the Java language may be insulated by catching ''SQLException'' exceptions.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
try {&lt;br /&gt;
  variant_method();&lt;br /&gt;
} catch ( SQLException e ) {&lt;br /&gt;
  // Handle exception&lt;br /&gt;
}&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, what happens if the variant method generates an ''Exception'' that is not a subclass of ''SQLException''?  In this scenario the ''Exception'' would bubble up out of the protected area.  The obvious solution is to catch all ''Exception''s.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
try {&lt;br /&gt;
  variant_method();&lt;br /&gt;
} catch ( Throwable e ) {&lt;br /&gt;
  // Handle exception&lt;br /&gt;
}&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, this has potentially undesirable effects also.  What happens if there is a system-level exception, such as the system runs out of memory?  This seems like an exception that would need to be communicated to a higher level and not consumed in the protection scheme.&lt;br /&gt;
&lt;br /&gt;
The answer is, it depends.  Generally there will be a documented contract within the ''interface'' of the variant.  The protection then checks that these error conditions don't violate the contract.  This is good design and should be part of a system's design regardless.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Before discussing a specific example, it is important to understand that the '''protected variations''' pattern is present in almost every aspect of design.  Consider virtual machines, plugin containers, sandboxes, configuration files and operating systems as specializations of the this pattern [3].  Generally examples are classified by the type of mechanisms that have motivated the '''protected variations''' pattern in the first place.  The following sections have followed those first described by Larman, but with updated examples.&lt;br /&gt;
&lt;br /&gt;
=== Data-Driven Designs ===&lt;br /&gt;
Any piece of data that is read into a system in order to affect the system's behavior in some manner.  For example, in a Ruby on Rails application the ''database.yml'' file defines database drivers to load and configuration parameters for these drivers.  Some drivers require the definition of a username and password, while others require the definition of a file path, it is up to the driver as to which parameters to require.&lt;br /&gt;
&lt;br /&gt;
=== Service Lookup ===&lt;br /&gt;
This specialization uses a lookup service as a stable interface that is used to find a particular implementation of a component through the use of something like a naming service.  The classic example of this is the Java Naming and Directory Interface (JNDI), another example is the Ruby Gem system.  Using standard commands through the stable gem tool allows a developer to lookup and install gems to perform potentially unstable operations.&lt;br /&gt;
&lt;br /&gt;
=== Interpreter-Driven Designs ===&lt;br /&gt;
The premise behind interpreter-driven designs is an interpreter loads a particular file and executes the commands within that file to affect some result.  The stable interface being the interpreter and the variant the interpreted code file that is loaded.  The Ruby interpreter is a great example of this.&lt;br /&gt;
&lt;br /&gt;
=== Reflective or Meta-Level Designs ===&lt;br /&gt;
This specialization refers to not designing a stable system to a particular interface or implementation, but introspecting that interface at run-time.  For example, a Ruby class would have its methods introspected to find the correct implementation that would then be executed within another protection level.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
class Variant_1&lt;br /&gt;
  def vvv&lt;br /&gt;
    @very_very_verbose = true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
class Variant_2&lt;br /&gt;
  def vv&lt;br /&gt;
    @very_verbose = true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
v = Variant_1.new # or Variant_2.new&lt;br /&gt;
if ( v.methods.include? &amp;quot;vvv&amp;quot; )&lt;br /&gt;
  m = v.method :vvv&lt;br /&gt;
elsif ( v.methods.include? &amp;quot;vv&amp;quot; )&lt;br /&gt;
  m = v.method :vv&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
protect_method_call( m.call )&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
When implemented correctly the '''protected variations''' pattern can provide stability to a system that needs to open itself up to potentially unsafe or unstable variations.  The benefits include [3]&lt;br /&gt;
* Extensions required for new variations are easy to add.&lt;br /&gt;
* New implementations can be introduced without affecting clients.&lt;br /&gt;
* Coupling is lowered.&lt;br /&gt;
* The impact or cost of changes can be lowered.&lt;br /&gt;
&lt;br /&gt;
This pattern is the same as information hiding and the open-closed principal in almost every regard.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[1] http://en.wikipedia.org/wiki/GRASP_%28object-oriented_design%29&lt;br /&gt;
&lt;br /&gt;
[2] http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/ProtectedVariations.html&lt;br /&gt;
&lt;br /&gt;
[3] Craig Larman, Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, Third Edition, Addison Wesley, 2004, Section 25.4.&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch7_7e_GP&amp;diff=42522</id>
		<title>CSC/ECE 517 Fall 2010/ch7 7e GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch7_7e_GP&amp;diff=42522"/>
		<updated>2010-11-24T01:48:05Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Protected Variations pattern =&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch1_S10_ms&amp;diff=42521</id>
		<title>CSC/ECE 517 Fall 2010/ch1 S10 ms</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch1_S10_ms&amp;diff=42521"/>
		<updated>2010-11-24T01:47:45Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[CSC/ECE 517 Fall 2010/ch1 1a vc]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1a br]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1b mg]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1c JF]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1e az]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1e bb]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1f vn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 25 ag]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 2b dg]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 2e RI]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S6 aa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S6 km]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 GP]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 MS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 MM]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 PH]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 2a CB]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 2a mw]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 2c ck]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S23 GP]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S24 NS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S23 SS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S23 NR]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S20 TT]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 2d AS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S24 rm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3a SN]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3b ka]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3e br]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3f lj]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3h az]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3h PW]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3i IC]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3i MM]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3j KS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 S30 SK]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 4b mt]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch4 4e ms]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch4 4f sv]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch4 4g HW]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch4 4g km]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch4 4h am]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5b mt]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5b jz]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5c ck]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5c IC]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5f SN]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5a KR]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5b RR]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5e ms]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/chd 6d isb]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6b SK]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6c AW]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6d bb]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6h AS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6f AZ]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6b AK]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6g ss]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6d NM]]&lt;br /&gt;
&lt;br /&gt;
*[[ CSC/ECE 517 Fall 2010/ch6 6a PC]]&lt;br /&gt;
&lt;br /&gt;
*[[ CSC/ECE 517 Fall 2010/ch2 4d RB]]&lt;br /&gt;
&lt;br /&gt;
*[[ CSC/ECE 517 Fall 2010/ch7 7e GP]]&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4h_GP&amp;diff=42520</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4h GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4h_GP&amp;diff=42520"/>
		<updated>2010-11-24T01:45:55Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4h_GP&amp;diff=42519</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4h GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4h_GP&amp;diff=42519"/>
		<updated>2010-11-24T01:33:38Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Static-analysis tools for Ruby =&lt;br /&gt;
TODO by gpascar&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch1_S10_ms&amp;diff=42518</id>
		<title>CSC/ECE 517 Fall 2010/ch1 S10 ms</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch1_S10_ms&amp;diff=42518"/>
		<updated>2010-11-24T01:32:31Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[CSC/ECE 517 Fall 2010/ch1 1a vc]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1a br]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1b mg]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1c JF]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1e az]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1e bb]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1f vn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 25 ag]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 2b dg]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 2e RI]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S6 aa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S6 km]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 GP]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 MS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 MM]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 PH]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 2a CB]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 2a mw]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 2c ck]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S23 GP]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S24 NS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S23 SS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S23 NR]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S20 TT]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 2d AS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S24 rm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3a SN]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3b ka]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3e br]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3f lj]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3h az]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3h PW]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3i IC]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3i MM]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 3j KS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 S30 SK]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch3 4b mt]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch4 4e ms]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch4 4f sv]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch4 4g HW]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch4 4g km]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch4 4h am]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch4 4h GP]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5b mt]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5b jz]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5c ck]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5c IC]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5f SN]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5a KR]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5b RR]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch5 5e ms]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/chd 6d isb]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6b SK]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6c AW]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6d bb]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6h AS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6f AZ]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6b AK]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6g ss]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch6 6d NM]]&lt;br /&gt;
&lt;br /&gt;
*[[ CSC/ECE 517 Fall 2010/ch6 6a PC]]&lt;br /&gt;
&lt;br /&gt;
*[[ CSC/ECE 517 Fall 2010/ch2 4d RB]]&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=36401</id>
		<title>CSC/ECE 517 Fall 2010/ch2 S23 GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=36401"/>
		<updated>2010-10-01T15:18:04Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: /* Internal vs. External */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Object-Oriented Domain-Specific Languages ==&lt;br /&gt;
Domain-specific Languages, or DSLs, are programming languages or a subset of other languages that are used to solve domain specific problems.  This is in opposition to general purpose programming languages that are used for all problems.  The advantage of DSLs over general purpose languages is they are more targeted to a specific set of problems that may be higher level than is necessary for a general purpose language.  Domain-specific languages are very ubiquitous, even though it may not be apparent.  Here are examples of some domain-specific languages:&lt;br /&gt;
* CSS&lt;br /&gt;
* SQL&lt;br /&gt;
* Regular Expressions&lt;br /&gt;
* UnrealScript &amp;lt;sup&amp;gt;[3]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
General purpose languages contain more functionality than DSLs and generally provide specific system level access.  Of course this may be a misnomer since a DSL may be developed specifically to handle system level APIs, like file systems.  Examples of general purpose languages include:&lt;br /&gt;
* Java&lt;br /&gt;
* C++&lt;br /&gt;
* C#&lt;br /&gt;
&lt;br /&gt;
Object-oriented Domain-specific Languages (OODSLs) differ from traditional DSLs in the same way that traditional languages differ from their object-oriented counterparts.  An OOP uses &amp;quot;objects&amp;quot;, which are data structures that contain both data members and methods.  Therefore, OODSLs are simply DSLs that employ and object-oriented paradigm.  Examples of OODSLs are:&lt;br /&gt;
* Scalable Vector Graphics (SVG) &amp;lt;sup&amp;gt;[7]&amp;lt;/sup&amp;gt;&lt;br /&gt;
* Extensible Application Markup Language (XAML) &amp;lt;sup&amp;gt;[6]&amp;lt;/sup&amp;gt;&lt;br /&gt;
* Kiddo&lt;br /&gt;
* Spring Configuration&lt;br /&gt;
&lt;br /&gt;
== Internal vs. External ==&lt;br /&gt;
Among OODSLs there is a distinction between internal OODSLs and external OODSLs &amp;lt;sup&amp;gt;[5]&amp;lt;/sup&amp;gt;.  Internal or embedded OODSLs give a &amp;quot;host&amp;quot; language domain-specific extensions or elements.  For example, an internal OODSL may extend a general purpose language to allow for easier implementation of generating graphics through the use of specific APIs.  An example of an embedded OODSL is JavaScript hosted within an HTML document.&lt;br /&gt;
&lt;br /&gt;
However, there is a fuzzy line between embedded OODSLs and 3rd party libraries.  For example, the drawing methods of a Graphics object within Java may be considered an embedded OODSL or just a series of library APIS that are used in a contractual way.&lt;br /&gt;
&lt;br /&gt;
External OODSLs are languages that are not hosted within another language, but are compiled or interpreted in a standalone manner.  These OODSLs usually have a complete tool set and development environment behind them.  It is up to the language implementer, but external OODSLs are generally interpreted instead of compiled.  However, an OODSL does not necessarily need to be compiled into executable code.  An OODSL may be a representation of something else.  The CSound OODSL compiles an Orchestra and Score markup files into audio.  Another example is compiling or converting SVG into a rasterized image, such as Portable Network Graphics (PNG).&lt;br /&gt;
&lt;br /&gt;
== Practical Example: Java Swing and SVG ==&lt;br /&gt;
One way to illustrate the benefits of OODSLs is to compare a OODSL and a general purpose language performing the same task.  The following practical example illustrates how a language like Java and an OODSL perform painting tasks.  Both examples will draw a square button with the word ''Button'' in the center.  The Java code is taken from a common [http://en.wikipedia.org/wiki/Java_Swing Swing] construct where a JButton overrides its paintComponent method to draw something more custom than the Swing default look and feel.  The Java Graphics API is used to perform both vector and raster drawing operations within a Java application.  These operations could be used for either drawing user interfaces or directly onto in-memory images for later display.  Here is an example of drawing a square button using a Java Graphics object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@Override&lt;br /&gt;
protected void paintComponent(Graphics g) {&lt;br /&gt;
	// Save the current context's color&lt;br /&gt;
	Color savedColor = g.getColor();&lt;br /&gt;
&lt;br /&gt;
	// Fill the shape&lt;br /&gt;
	g.setColor(Color.gray);&lt;br /&gt;
	g.fillRect(0, 0, getWidth(), getHeight());&lt;br /&gt;
&lt;br /&gt;
	// Draw the text&lt;br /&gt;
	g.setColor(Bolor.black);&lt;br /&gt;
	g.drawString(&amp;quot;Button&amp;quot;, 2, getHeight()-3);&lt;br /&gt;
&lt;br /&gt;
	// Draw the border&lt;br /&gt;
	g.setColor(Color.black);&lt;br /&gt;
	g.drawRect(0, 0, getWidth()-1, getHeight()-1);&lt;br /&gt;
&lt;br /&gt;
	// Restore the context's color&lt;br /&gt;
	g.setColor(savedColor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is quite procedural despite it being a methodology within an object-oriented language.  Using a general purpose language like Java to perform something as domain-specific as graphics generation can lead to a lot of redundant overhead that is taken care of in a specialized language.  This example illustrated the saving and restoring of the Graphic object's ''Color'' attribute, but could have required the saving and subsequent restoration of multiple properties, such as the current ''Transform'', ''Stroke'' or ''Font''.  An OODSL would provide a more robust and flexible set of drawing and graphics APIs that would ideally perform the redundant tasks like saving and restoring the graphics state attributes, as is the case with SVG.  Here is the same example written in using this OODSL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot;&lt;br /&gt;
 &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;lt;svg width=&amp;quot;10%&amp;quot; height=&amp;quot;10%&amp;quot; version=&amp;quot;1.1&amp;quot; xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot;&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;rect width=&amp;quot;100%&amp;quot; height=&amp;quot;100%&amp;quot;&lt;br /&gt;
	      style=&amp;quot;fill:rgb(128,128,128);stroke-width:1;stroke:rgb(0,0,0)&amp;quot; /&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;text x=&amp;quot;35%&amp;quot; y=&amp;quot;50%&amp;quot;&amp;amp;gt;Button&amp;amp;lt;/text&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/svg&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code is more declarative, object-oriented and much less procedural.  Instead of using a method to draw a rectangle the rectangle itself is an object with many data members used to define how the rectangle is rendered.  Ironically, the style attribute of the rectangle is a subset of CSS, another OODSL.  Since SVG is a language specific to the vector and imagery domain it provides capabilities (like opacity and gradients) that may be difficult to perform in general purpose languages without specialized libraries or an internal OODSL.&lt;br /&gt;
&lt;br /&gt;
The SVG declaration could be &amp;quot;compiled&amp;quot; into an image format (such as JPG) as opposed to the Java code, which can only paint on the Graphics context passed into it.  The point is the SVG implementation is more versatile within the image domain in performing the same or similar methods as a general purpose language like Java.&lt;br /&gt;
&lt;br /&gt;
== When should OODSLs be used? ==&lt;br /&gt;
In order to determine if a OODSL should be used or created you must first examine the advantages of OODSLs.  If the problem domain is a well-known domain that already has an OODSL defined for it then it may be useful to use this OODSL, after all it was created for a reason.  If the selected OODSL does not fully support the operations needed for the problem domain then maybe a different OODSL is needed or the OODSL needs to be extended.&lt;br /&gt;
&lt;br /&gt;
If, however, there is no existing OODSL defined then creating a new OODSL may be the answer.  This usually happens when there is a well-defined or at least well-understood domain where certain operations are performed over and over again.  For example, a good candidate for an OODSL is robotics.  Consider a robotic arm in a factory that needs to perform repetitive tasks such as picking up an object from one conveyor belt and moving it to another.  If there is a OODSL that defines the movements of the arm then new behaviors could be easily added to the armature and existing actions can be easily changed.  These changes in behavior may even be performed by a technician or subject matter expert (SME) instead of a developer.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Object-oriented Domain-specific Languages provide a level of abstraction to a given domain.  This abstraction may result in enhanced capabilities (such as rapid prototyping) or a greater control or understanding of that domain.  It may also enable non-developers, like SMEs, to write &amp;quot;code&amp;quot; that utilizes the OODSL to affect a system or generate some sort of output.  OODSLs are classified as either internal or external where internal is an OODSL that &amp;quot;lives&amp;quot; within a host language and external is a standalone language in its own right.  General purpose languages are good for just that, general purpose development.  OODSLs are very focused and are prevalent in almost every niche of computing.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [1] Mernik, M., Heering, J., and Sloane, A. M. 2005. When and how to develop domain-specific languages. ACM Comput. Surv. 37, 4 (Dec. 2005), 316-344. DOI= http://doi.acm.org/10.1145/1118890.1118892&lt;br /&gt;
* [2] &amp;quot;Domain-specific Language.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/Domain-specific_language.&lt;br /&gt;
* [3] &amp;quot;UnrealScript.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/UnrealScript.&lt;br /&gt;
* [4] &amp;quot;InfoQ: What's a Ruby DSL and What Isn't?&amp;quot; ''InfoQ: Tracking Change and Innovation in the Enterprise Software Development Community.'' Web. 08 Sept. 2010. http://www.infoq.com/news/2007/06/dsl-or-not.&lt;br /&gt;
* [5] &amp;quot;MF Bliki: DomainSpecificLanguage.&amp;quot; ''Martin Fowler.'' Web. 08 Sept. 2010. http://www.martinfowler.com/bliki/DomainSpecificLanguage.html.&lt;br /&gt;
* [6] &amp;quot;Extensible Application Markup Language.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/XAML.&lt;br /&gt;
* [7] &amp;quot;Scalable Vector Graphics.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/SVG.&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=36400</id>
		<title>CSC/ECE 517 Fall 2010/ch2 S23 GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=36400"/>
		<updated>2010-10-01T15:17:25Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: /* Introduction to Object-Oriented Domain-Specific Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Object-Oriented Domain-Specific Languages ==&lt;br /&gt;
Domain-specific Languages, or DSLs, are programming languages or a subset of other languages that are used to solve domain specific problems.  This is in opposition to general purpose programming languages that are used for all problems.  The advantage of DSLs over general purpose languages is they are more targeted to a specific set of problems that may be higher level than is necessary for a general purpose language.  Domain-specific languages are very ubiquitous, even though it may not be apparent.  Here are examples of some domain-specific languages:&lt;br /&gt;
* CSS&lt;br /&gt;
* SQL&lt;br /&gt;
* Regular Expressions&lt;br /&gt;
* UnrealScript &amp;lt;sup&amp;gt;[3]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
General purpose languages contain more functionality than DSLs and generally provide specific system level access.  Of course this may be a misnomer since a DSL may be developed specifically to handle system level APIs, like file systems.  Examples of general purpose languages include:&lt;br /&gt;
* Java&lt;br /&gt;
* C++&lt;br /&gt;
* C#&lt;br /&gt;
&lt;br /&gt;
Object-oriented Domain-specific Languages (OODSLs) differ from traditional DSLs in the same way that traditional languages differ from their object-oriented counterparts.  An OOP uses &amp;quot;objects&amp;quot;, which are data structures that contain both data members and methods.  Therefore, OODSLs are simply DSLs that employ and object-oriented paradigm.  Examples of OODSLs are:&lt;br /&gt;
* Scalable Vector Graphics (SVG) &amp;lt;sup&amp;gt;[7]&amp;lt;/sup&amp;gt;&lt;br /&gt;
* Extensible Application Markup Language (XAML) &amp;lt;sup&amp;gt;[6]&amp;lt;/sup&amp;gt;&lt;br /&gt;
* Kiddo&lt;br /&gt;
* Spring Configuration&lt;br /&gt;
&lt;br /&gt;
== Internal vs. External ==&lt;br /&gt;
Among OODSLs there is a distinction between internal OODSLs and external OODSLs.  Internal or embedded OODSLs give a &amp;quot;host&amp;quot; language domain-specific extensions or elements.  For example, an internal OODSL may extend a general purpose language to allow for easier implementation of generating graphics through the use of specific APIs.  An example of an embedded OODSL is JavaScript hosted within an HTML document.&lt;br /&gt;
&lt;br /&gt;
However, there is a fuzzy line between embedded OODSLs and 3rd party libraries.  For example, the drawing methods of a Graphics object within Java may be considered an embedded OODSL or just a series of library APIS that are used in a contractual way.&lt;br /&gt;
&lt;br /&gt;
External OODSLs are languages that are not hosted within another language, but are compiled or interpreted in a standalone manner.  These OODSLs usually have a complete tool set and development environment behind them.  It is up to the language implementer, but external OODSLs are generally interpreted instead of compiled.  However, an OODSL does not necessarily need to be compiled into executable code.  An OODSL may be a representation of something else.  The CSound OODSL compiles an Orchestra and Score markup files into audio.  Another example is compiling or converting SVG into a rasterized image, such as Portable Network Graphics (PNG).&lt;br /&gt;
&lt;br /&gt;
== Practical Example: Java Swing and SVG ==&lt;br /&gt;
One way to illustrate the benefits of OODSLs is to compare a OODSL and a general purpose language performing the same task.  The following practical example illustrates how a language like Java and an OODSL perform painting tasks.  Both examples will draw a square button with the word ''Button'' in the center.  The Java code is taken from a common [http://en.wikipedia.org/wiki/Java_Swing Swing] construct where a JButton overrides its paintComponent method to draw something more custom than the Swing default look and feel.  The Java Graphics API is used to perform both vector and raster drawing operations within a Java application.  These operations could be used for either drawing user interfaces or directly onto in-memory images for later display.  Here is an example of drawing a square button using a Java Graphics object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@Override&lt;br /&gt;
protected void paintComponent(Graphics g) {&lt;br /&gt;
	// Save the current context's color&lt;br /&gt;
	Color savedColor = g.getColor();&lt;br /&gt;
&lt;br /&gt;
	// Fill the shape&lt;br /&gt;
	g.setColor(Color.gray);&lt;br /&gt;
	g.fillRect(0, 0, getWidth(), getHeight());&lt;br /&gt;
&lt;br /&gt;
	// Draw the text&lt;br /&gt;
	g.setColor(Bolor.black);&lt;br /&gt;
	g.drawString(&amp;quot;Button&amp;quot;, 2, getHeight()-3);&lt;br /&gt;
&lt;br /&gt;
	// Draw the border&lt;br /&gt;
	g.setColor(Color.black);&lt;br /&gt;
	g.drawRect(0, 0, getWidth()-1, getHeight()-1);&lt;br /&gt;
&lt;br /&gt;
	// Restore the context's color&lt;br /&gt;
	g.setColor(savedColor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is quite procedural despite it being a methodology within an object-oriented language.  Using a general purpose language like Java to perform something as domain-specific as graphics generation can lead to a lot of redundant overhead that is taken care of in a specialized language.  This example illustrated the saving and restoring of the Graphic object's ''Color'' attribute, but could have required the saving and subsequent restoration of multiple properties, such as the current ''Transform'', ''Stroke'' or ''Font''.  An OODSL would provide a more robust and flexible set of drawing and graphics APIs that would ideally perform the redundant tasks like saving and restoring the graphics state attributes, as is the case with SVG.  Here is the same example written in using this OODSL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot;&lt;br /&gt;
 &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;lt;svg width=&amp;quot;10%&amp;quot; height=&amp;quot;10%&amp;quot; version=&amp;quot;1.1&amp;quot; xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot;&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;rect width=&amp;quot;100%&amp;quot; height=&amp;quot;100%&amp;quot;&lt;br /&gt;
	      style=&amp;quot;fill:rgb(128,128,128);stroke-width:1;stroke:rgb(0,0,0)&amp;quot; /&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;text x=&amp;quot;35%&amp;quot; y=&amp;quot;50%&amp;quot;&amp;amp;gt;Button&amp;amp;lt;/text&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/svg&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code is more declarative, object-oriented and much less procedural.  Instead of using a method to draw a rectangle the rectangle itself is an object with many data members used to define how the rectangle is rendered.  Ironically, the style attribute of the rectangle is a subset of CSS, another OODSL.  Since SVG is a language specific to the vector and imagery domain it provides capabilities (like opacity and gradients) that may be difficult to perform in general purpose languages without specialized libraries or an internal OODSL.&lt;br /&gt;
&lt;br /&gt;
The SVG declaration could be &amp;quot;compiled&amp;quot; into an image format (such as JPG) as opposed to the Java code, which can only paint on the Graphics context passed into it.  The point is the SVG implementation is more versatile within the image domain in performing the same or similar methods as a general purpose language like Java.&lt;br /&gt;
&lt;br /&gt;
== When should OODSLs be used? ==&lt;br /&gt;
In order to determine if a OODSL should be used or created you must first examine the advantages of OODSLs.  If the problem domain is a well-known domain that already has an OODSL defined for it then it may be useful to use this OODSL, after all it was created for a reason.  If the selected OODSL does not fully support the operations needed for the problem domain then maybe a different OODSL is needed or the OODSL needs to be extended.&lt;br /&gt;
&lt;br /&gt;
If, however, there is no existing OODSL defined then creating a new OODSL may be the answer.  This usually happens when there is a well-defined or at least well-understood domain where certain operations are performed over and over again.  For example, a good candidate for an OODSL is robotics.  Consider a robotic arm in a factory that needs to perform repetitive tasks such as picking up an object from one conveyor belt and moving it to another.  If there is a OODSL that defines the movements of the arm then new behaviors could be easily added to the armature and existing actions can be easily changed.  These changes in behavior may even be performed by a technician or subject matter expert (SME) instead of a developer.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Object-oriented Domain-specific Languages provide a level of abstraction to a given domain.  This abstraction may result in enhanced capabilities (such as rapid prototyping) or a greater control or understanding of that domain.  It may also enable non-developers, like SMEs, to write &amp;quot;code&amp;quot; that utilizes the OODSL to affect a system or generate some sort of output.  OODSLs are classified as either internal or external where internal is an OODSL that &amp;quot;lives&amp;quot; within a host language and external is a standalone language in its own right.  General purpose languages are good for just that, general purpose development.  OODSLs are very focused and are prevalent in almost every niche of computing.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [1] Mernik, M., Heering, J., and Sloane, A. M. 2005. When and how to develop domain-specific languages. ACM Comput. Surv. 37, 4 (Dec. 2005), 316-344. DOI= http://doi.acm.org/10.1145/1118890.1118892&lt;br /&gt;
* [2] &amp;quot;Domain-specific Language.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/Domain-specific_language.&lt;br /&gt;
* [3] &amp;quot;UnrealScript.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/UnrealScript.&lt;br /&gt;
* [4] &amp;quot;InfoQ: What's a Ruby DSL and What Isn't?&amp;quot; ''InfoQ: Tracking Change and Innovation in the Enterprise Software Development Community.'' Web. 08 Sept. 2010. http://www.infoq.com/news/2007/06/dsl-or-not.&lt;br /&gt;
* [5] &amp;quot;MF Bliki: DomainSpecificLanguage.&amp;quot; ''Martin Fowler.'' Web. 08 Sept. 2010. http://www.martinfowler.com/bliki/DomainSpecificLanguage.html.&lt;br /&gt;
* [6] &amp;quot;Extensible Application Markup Language.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/XAML.&lt;br /&gt;
* [7] &amp;quot;Scalable Vector Graphics.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/SVG.&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=36391</id>
		<title>CSC/ECE 517 Fall 2010/ch2 S23 GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=36391"/>
		<updated>2010-10-01T14:50:54Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Object-Oriented Domain-Specific Languages ==&lt;br /&gt;
Domain-specific Languages, or DSLs, are programming languages or a subset of other languages that are used to solve domain specific problems.  This is in opposition to general purpose programming languages that are used for all problems.  The advantage of DSLs over general purpose languages is they are more targeted to a specific set of problems that may be higher level than is necessary for a general purpose language.  Domain-specific languages are very ubiquitous, even though it may not be apparent.  Here are examples of some domain-specific languages:&lt;br /&gt;
* CSS&lt;br /&gt;
* SQL&lt;br /&gt;
* Regular Expressions&lt;br /&gt;
* UnrealScript &amp;lt;sup&amp;gt;[3]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
General purpose languages contain more functionality than DSLs and generally provide specific system level access.  Of course this may be a misnomer since a DSL may be developed specifically to handle system level APIs, like file systems.  Examples of general purpose languages include:&lt;br /&gt;
* Java&lt;br /&gt;
* C++&lt;br /&gt;
* C#&lt;br /&gt;
&lt;br /&gt;
Object-oriented Domain-specific Languages (OODSLs) differ from traditional DSLs in the same way that traditional languages differ from their object-oriented counterparts.  An OOP uses &amp;quot;objects&amp;quot;, which are data structures that contain both data members and methods.  Therefore, OODSLs are simply DSLs that employ and object-oriented paradigm.  Examples of OODSLs are:&lt;br /&gt;
* Scalable Vector Graphics (SVG)&lt;br /&gt;
* Extensible Application Markup Language (XAML) &amp;lt;sup&amp;gt;[6]&amp;lt;/sup&amp;gt;&lt;br /&gt;
* Kiddo&lt;br /&gt;
* Spring Configuration&lt;br /&gt;
&lt;br /&gt;
== Internal vs. External ==&lt;br /&gt;
Among OODSLs there is a distinction between internal OODSLs and external OODSLs.  Internal or embedded OODSLs give a &amp;quot;host&amp;quot; language domain-specific extensions or elements.  For example, an internal OODSL may extend a general purpose language to allow for easier implementation of generating graphics through the use of specific APIs.  An example of an embedded OODSL is JavaScript hosted within an HTML document.&lt;br /&gt;
&lt;br /&gt;
However, there is a fuzzy line between embedded OODSLs and 3rd party libraries.  For example, the drawing methods of a Graphics object within Java may be considered an embedded OODSL or just a series of library APIS that are used in a contractual way.&lt;br /&gt;
&lt;br /&gt;
External OODSLs are languages that are not hosted within another language, but are compiled or interpreted in a standalone manner.  These OODSLs usually have a complete tool set and development environment behind them.  It is up to the language implementer, but external OODSLs are generally interpreted instead of compiled.  However, an OODSL does not necessarily need to be compiled into executable code.  An OODSL may be a representation of something else.  The CSound OODSL compiles an Orchestra and Score markup files into audio.  Another example is compiling or converting SVG into a rasterized image, such as Portable Network Graphics (PNG).&lt;br /&gt;
&lt;br /&gt;
== Practical Example: Java Swing and SVG ==&lt;br /&gt;
One way to illustrate the benefits of OODSLs is to compare a OODSL and a general purpose language performing the same task.  The following practical example illustrates how a language like Java and an OODSL perform painting tasks.  Both examples will draw a square button with the word ''Button'' in the center.  The Java code is taken from a common [http://en.wikipedia.org/wiki/Java_Swing Swing] construct where a JButton overrides its paintComponent method to draw something more custom than the Swing default look and feel.  The Java Graphics API is used to perform both vector and raster drawing operations within a Java application.  These operations could be used for either drawing user interfaces or directly onto in-memory images for later display.  Here is an example of drawing a square button using a Java Graphics object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@Override&lt;br /&gt;
protected void paintComponent(Graphics g) {&lt;br /&gt;
	// Save the current context's color&lt;br /&gt;
	Color savedColor = g.getColor();&lt;br /&gt;
&lt;br /&gt;
	// Fill the shape&lt;br /&gt;
	g.setColor(Color.gray);&lt;br /&gt;
	g.fillRect(0, 0, getWidth(), getHeight());&lt;br /&gt;
&lt;br /&gt;
	// Draw the text&lt;br /&gt;
	g.setColor(Bolor.black);&lt;br /&gt;
	g.drawString(&amp;quot;Button&amp;quot;, 2, getHeight()-3);&lt;br /&gt;
&lt;br /&gt;
	// Draw the border&lt;br /&gt;
	g.setColor(Color.black);&lt;br /&gt;
	g.drawRect(0, 0, getWidth()-1, getHeight()-1);&lt;br /&gt;
&lt;br /&gt;
	// Restore the context's color&lt;br /&gt;
	g.setColor(savedColor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is quite procedural despite it being a methodology within an object-oriented language.  Using a general purpose language like Java to perform something as domain-specific as graphics generation can lead to a lot of redundant overhead that is taken care of in a specialized language.  This example illustrated the saving and restoring of the Graphic object's ''Color'' attribute, but could have required the saving and subsequent restoration of multiple properties, such as the current ''Transform'', ''Stroke'' or ''Font''.  An OODSL would provide a more robust and flexible set of drawing and graphics APIs that would ideally perform the redundant tasks like saving and restoring the graphics state attributes, as is the case with SVG.  Here is the same example written in using this OODSL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot;&lt;br /&gt;
 &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;lt;svg width=&amp;quot;10%&amp;quot; height=&amp;quot;10%&amp;quot; version=&amp;quot;1.1&amp;quot; xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot;&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;rect width=&amp;quot;100%&amp;quot; height=&amp;quot;100%&amp;quot;&lt;br /&gt;
	      style=&amp;quot;fill:rgb(128,128,128);stroke-width:1;stroke:rgb(0,0,0)&amp;quot; /&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;text x=&amp;quot;35%&amp;quot; y=&amp;quot;50%&amp;quot;&amp;amp;gt;Button&amp;amp;lt;/text&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/svg&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code is more declarative, object-oriented and much less procedural.  Instead of using a method to draw a rectangle the rectangle itself is an object with many data members used to define how the rectangle is rendered.  Ironically, the style attribute of the rectangle is a subset of CSS, another OODSL.  Since SVG is a language specific to the vector and imagery domain it provides capabilities (like opacity and gradients) that may be difficult to perform in general purpose languages without specialized libraries or an internal OODSL.&lt;br /&gt;
&lt;br /&gt;
The SVG declaration could be &amp;quot;compiled&amp;quot; into an image format (such as JPG) as opposed to the Java code, which can only paint on the Graphics context passed into it.  The point is the SVG implementation is more versatile within the image domain in performing the same or similar methods as a general purpose language like Java.&lt;br /&gt;
&lt;br /&gt;
== When should OODSLs be used? ==&lt;br /&gt;
In order to determine if a OODSL should be used or created you must first examine the advantages of OODSLs.  If the problem domain is a well-known domain that already has an OODSL defined for it then it may be useful to use this OODSL, after all it was created for a reason.  If the selected OODSL does not fully support the operations needed for the problem domain then maybe a different OODSL is needed or the OODSL needs to be extended.&lt;br /&gt;
&lt;br /&gt;
If, however, there is no existing OODSL defined then creating a new OODSL may be the answer.  This usually happens when there is a well-defined or at least well-understood domain where certain operations are performed over and over again.  For example, a good candidate for an OODSL is robotics.  Consider a robotic arm in a factory that needs to perform repetitive tasks such as picking up an object from one conveyor belt and moving it to another.  If there is a OODSL that defines the movements of the arm then new behaviors could be easily added to the armature and existing actions can be easily changed.  These changes in behavior may even be performed by a technician or subject matter expert (SME) instead of a developer.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Object-oriented Domain-specific Languages provide a level of abstraction to a given domain.  This abstraction may result in enhanced capabilities (such as rapid prototyping) or a greater control or understanding of that domain.  It may also enable non-developers, like SMEs, to write &amp;quot;code&amp;quot; that utilizes the OODSL to affect a system or generate some sort of output.  OODSLs are classified as either internal or external where internal is an OODSL that &amp;quot;lives&amp;quot; within a host language and external is a standalone language in its own right.  General purpose languages are good for just that, general purpose development.  OODSLs are very focused and are prevalent in almost every niche of computing.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [1] Mernik, M., Heering, J., and Sloane, A. M. 2005. When and how to develop domain-specific languages. ACM Comput. Surv. 37, 4 (Dec. 2005), 316-344. DOI= http://doi.acm.org/10.1145/1118890.1118892&lt;br /&gt;
* [2] &amp;quot;Domain-specific Language.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/Domain-specific_language.&lt;br /&gt;
* [3] &amp;quot;UnrealScript.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/UnrealScript.&lt;br /&gt;
* [4] &amp;quot;InfoQ: What's a Ruby DSL and What Isn't?&amp;quot; ''InfoQ: Tracking Change and Innovation in the Enterprise Software Development Community.'' Web. 08 Sept. 2010. http://www.infoq.com/news/2007/06/dsl-or-not.&lt;br /&gt;
* [5] &amp;quot;MF Bliki: DomainSpecificLanguage.&amp;quot; ''Martin Fowler.'' Web. 08 Sept. 2010. http://www.martinfowler.com/bliki/DomainSpecificLanguage.html.&lt;br /&gt;
* [6] &amp;quot;Extensible Application Markup Language.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/XAML.&lt;br /&gt;
* [7] &amp;quot;Scalable Vector Graphics.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/SVG.&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S20_st&amp;diff=35684</id>
		<title>CSC/ECE 517 Fall 2010/ch2 S20 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S20_st&amp;diff=35684"/>
		<updated>2010-09-18T20:07:07Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[CSC/ECE 517 Fall 2010/ch1 1a vc]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 MS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1a br]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 MM]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S6 aa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1e bb]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1b mg]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1c JF]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 GP]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1f vn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S6 km]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 PH]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 1e az]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 2c ck]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch2 S23 GP]]&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch1_S23_GP&amp;diff=35683</id>
		<title>CSC/ECE 517 Fall 2010/ch1 S23 GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch1_S23_GP&amp;diff=35683"/>
		<updated>2010-09-18T20:05:58Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: CSC/ECE 517 Fall 2010/ch1 S23 GP moved to CSC/ECE 517 Fall 2010/ch2 S23 GP: I was mistaken when I thought I was chapter 1.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[CSC/ECE 517 Fall 2010/ch2 S23 GP]]&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=35682</id>
		<title>CSC/ECE 517 Fall 2010/ch2 S23 GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=35682"/>
		<updated>2010-09-18T20:05:58Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: CSC/ECE 517 Fall 2010/ch1 S23 GP moved to CSC/ECE 517 Fall 2010/ch2 S23 GP: I was mistaken when I thought I was chapter 1.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Object-Oriented Domain-Specific Languages ==&lt;br /&gt;
Domain-specific Languages, or DSLs, are programming languages or a subset of other languages that are used to solve domain specific problems.  This is in opposition to general purpose programming languages that are used for all problems.  The advantage of DSLs over general purpose languages are they are more targeted to a specific set of problems that may be higher level than is necessary for a general purpose language.  Domain-specific languages are is use everyday, even though it may not be apparent.  Here are examples of some domain-specific languages:&lt;br /&gt;
* CSS&lt;br /&gt;
* SQL&lt;br /&gt;
* Regular Expressions&lt;br /&gt;
* UnrealScript&lt;br /&gt;
&lt;br /&gt;
General purpose languages contain more functionality than DSLs and generally provide specific system level access.  Of course this may be a misnomer since a DSL may be developed specifically to handle system level APIs, like file systems.  Examples of general purpose languages include:&lt;br /&gt;
* Java&lt;br /&gt;
* C++&lt;br /&gt;
* C#&lt;br /&gt;
&lt;br /&gt;
Object-oriented Domain-specific Languages (OODSLs) differ from traditional DSLs in the same way that traditional languages differ from their object-oriented counterparts.  An OOP uses &amp;quot;objects&amp;quot;, which are data structures that contain both data members and methods.  Therefore, OODSLs are simply DSLs that exmploy and object-oriented paradigm.  Examples of OODSLs are:&lt;br /&gt;
* Scalable Vector Graphics (SVG)&lt;br /&gt;
* Extensible Application Markup Language (XAML)&lt;br /&gt;
* Kiddo&lt;br /&gt;
* Spring Configuration&lt;br /&gt;
&lt;br /&gt;
== Internal vs. External ==&lt;br /&gt;
Among OODSLs there is a distinction between internal OODSLs and external OODSLs.  Internal or embedded OODSLs give a &amp;quot;host&amp;quot; language domain-specific extensions or elements.  For example, an internal OODSL may extend a general purpose language to allow for easier implementation of generating graphics through the use of specific APIs.  An example of an embedded OODSL is Javascript hosted within an HTML document.&lt;br /&gt;
&lt;br /&gt;
However, there is a fuzzy line between embedded OODSLs and 3rd party libraries.  For example, the drawing methods of a Graphics object within Java may be considered an embedded OODSL or just a series of library APIS that are used in a contractual way.&lt;br /&gt;
&lt;br /&gt;
External OODSLs are languages that are not hosted within another language, but are compiled or interpreted in a standalone manner.  These OODSLs usually have a complete toolset and development environment behind them.  It is up to the language implementor, but external OODSLs are generally interpreted instead of compiled.  However, a OODSL does not necessarily need to be compiled into executable code.  A OODSL may be a representation of something else.  The CSound OODSL compiles a an Orchestra and Score markup files into audio.  Another example is compiling or converting SVG into a rasterized image, such as Portable Networg Graphics (PNG).&lt;br /&gt;
&lt;br /&gt;
== Practical Example: Java Swing and SVG ==&lt;br /&gt;
One way to illustrate the benefits of OODSLs is to compare a OODSL and a general purpose language performing the same task.  The following practical example illustrates how a language like Java and an OODSL perform painting tasks.  Both examples will draw a square button with the word ''Button'' in the center.  The Java code is taken from a common [http://en.wikipedia.org/wiki/Java_Swing Swing] construct where a JButton overrides it's paintComponent method to draw something more custom than the Swing default look and feel.  The Java Graphics API is used to perform both vector and raster drawing operations within a Java application.  These operations could be used for either drawing user interfaces or directly onto in-memory images for later display.  Here is an example of drawing a square button using a Java Graphics object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@Override&lt;br /&gt;
protected void paintComponent(Graphics g) {&lt;br /&gt;
	// Save the current context's color&lt;br /&gt;
	Color savedColor = g.getColor();&lt;br /&gt;
&lt;br /&gt;
	// Fill the shape&lt;br /&gt;
	g.setColor(Color.gray);&lt;br /&gt;
	g.fillRect(0, 0, getWidth(), getHeight());&lt;br /&gt;
&lt;br /&gt;
	// Draw the text&lt;br /&gt;
	g.setColor(Bolor.black);&lt;br /&gt;
	g.drawString(&amp;quot;Button&amp;quot;, 2, getHeight()-3);&lt;br /&gt;
&lt;br /&gt;
	// Draw the border&lt;br /&gt;
	g.setColor(Color.black);&lt;br /&gt;
	g.drawRect(0, 0, getWidth()-1, getHeight()-1);&lt;br /&gt;
&lt;br /&gt;
	// Restore the context's color&lt;br /&gt;
	g.setColor(savedColor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is quite procedural despite it being a methodology within an object-oriented language.  Using a general purpose language like Java to perform something as domain-specific as graphics generation can lead to a lot of redundant overhead that is taken care of in a specialized language.  This example illustrated the saving and restoring of the Graphic object's ''Color'' attribute, but could have required the saving and subsequent restoration of multiple properties, such as the current ''Transform'', ''Stroke'' or ''Font''.  An OODSL would provide a more robust and flexible set of drawing and graphics APIs that would ideally perform the redundant tasks like saving and restoring the graphics state attributes, as is the case with SVG.  Here is the same example written in using this OODSL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot;&lt;br /&gt;
 &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;lt;svg width=&amp;quot;10%&amp;quot; height=&amp;quot;10%&amp;quot; version=&amp;quot;1.1&amp;quot; xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot;&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;rect width=&amp;quot;100%&amp;quot; height=&amp;quot;100%&amp;quot;&lt;br /&gt;
	      style=&amp;quot;fill:rgb(128,128,128);stroke-width:1;stroke:rgb(0,0,0)&amp;quot; /&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;text x=&amp;quot;35%&amp;quot; y=&amp;quot;50%&amp;quot;&amp;amp;gt;Button&amp;amp;lt;/text&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/svg&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code is more declarative, object-oriented and much less procedural.  Instead of using a method to draw a rectangle the rectangle itself is an object with many data members used to define how the rectangle is rendered.  Ironically, the style attribute of the rectangle is a subset of CSS, another OODSL.  Since SVG is a language specific to the vector and imagery domain it provides capabilities (like opacity and gradients) that may be difficult to perform in general purpose languages without specialized libraries or an internal OODSL.&lt;br /&gt;
&lt;br /&gt;
The SVG declaration could be &amp;quot;compiled&amp;quot; into an image format (such as JPG) as opposed to the Java code, which can only paint on the Graphics context passed into it.  The point is, the SVG implementation is more versatile within the image domain in performing the same or similar methods as a general purpose language like Java.&lt;br /&gt;
&lt;br /&gt;
== When should OODSLs be used? ==&lt;br /&gt;
In order to determine if a OODSL should be used or created you must first examine the advantages of OODSLs.  If the problem domain is a well-known domain that already has an OODSL defined for it then it may be useful to use this OODSL, after all it was created for a reason.  If the selected OODSL does not fully support the operations needed for the problem domain then maybe a different OODSL is needed or the OODSL needs to be extended.&lt;br /&gt;
&lt;br /&gt;
If, however, there is no existing OODSL defined then creating a new OODSL may be the answer.  This usually happens when there is a well-defined or at least well-understood domain where certain operations are performed over and over again.  For example, a good candidate for an OODSL is robotics.  Consider a robotic arm in a factory that needs to perform repetetive tasks such as picking up an object from one conveyor belt and moving it to another.  If there is a OODSL that defines the movements of the arm then new behaviors could be easily added to the armature and existing actions can be easily changed.  These changes in behavior may even be performed by a technician or subject matter expert (SME) instead of a developer.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Object-oriented Domain-specific Languages provide a level of abstraction to a given domain.  This abstraction may result in enhanced capabilities (such as rapid prototyping) or a greater control or understanding of that domain.  It may also enable non-developers, like SMEs, to write &amp;quot;code&amp;quot; that utilizes the OODSL to affect a system or generate some sort of output.  OODSLs are classified as either internal or external where internal is an OODSL that &amp;quot;lives&amp;quot; within a host language and external is a standalone language in its own right.  General purpose languages are good for just that, general purpose development.  OODSLs are very focused and are prevalent in almost every niche of computing.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
*Mernik, M., Heering, J., and Sloane, A. M. 2005. When and how to develop domain-specific languages. ACM Comput. Surv. 37, 4 (Dec. 2005), 316-344. DOI= http://doi.acm.org/10.1145/1118890.1118892&lt;br /&gt;
*&amp;quot;Domain-specific Language.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/Domain-specific_language.&lt;br /&gt;
*&amp;quot;UnrealScript.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/UnrealScript.&lt;br /&gt;
*&amp;quot;InfoQ: What's a Ruby DSL and What Isn't?&amp;quot; ''InfoQ: Tracking Change and Innovation in the Enterprise Software Development Community.'' Web. 08 Sept. 2010. http://www.infoq.com/news/2007/06/dsl-or-not.&lt;br /&gt;
*&amp;quot;MF Bliki: DomainSpecificLanguage.&amp;quot; ''Martin Fowler.'' Web. 08 Sept. 2010. http://www.martinfowler.com/bliki/DomainSpecificLanguage.html.&lt;br /&gt;
*&amp;quot;Extensible Application Markup Language.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/XAML.&lt;br /&gt;
*&amp;quot;Scalable Vector Graphics.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/SVG.&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=34587</id>
		<title>CSC/ECE 517 Fall 2010/ch2 S23 GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=34587"/>
		<updated>2010-09-09T02:49:41Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Object-Oriented Domain-Specific Languages ==&lt;br /&gt;
Domain-specific Languages, or DSLs, are programming languages or a subset of other languages that are used to solve domain specific problems.  This is in opposition to general purpose programming languages that are used for all problems.  The advantage of DSLs over general purpose languages are they are more targeted to a specific set of problems that may be higher level than is necessary for a general purpose language.  Domain-specific languages are is use everyday, even though it may not be apparent.  Here are examples of some domain-specific languages:&lt;br /&gt;
* CSS&lt;br /&gt;
* SQL&lt;br /&gt;
* Regular Expressions&lt;br /&gt;
* UnrealScript&lt;br /&gt;
&lt;br /&gt;
General purpose languages contain more functionality than DSLs and generally provide specific system level access.  Of course this may be a misnomer since a DSL may be developed specifically to handle system level APIs, like file systems.  Examples of general purpose languages include:&lt;br /&gt;
* Java&lt;br /&gt;
* C++&lt;br /&gt;
* C#&lt;br /&gt;
&lt;br /&gt;
Object-oriented Domain-specific Languages (OODSLs) differ from traditional DSLs in the same way that traditional languages differ from their object-oriented counterparts.  An OOP uses &amp;quot;objects&amp;quot;, which are data structures that contain both data members and methods.  Therefore, OODSLs are simply DSLs that exmploy and object-oriented paradigm.  Examples of OODSLs are:&lt;br /&gt;
* Scalable Vector Graphics (SVG)&lt;br /&gt;
* Extensible Application Markup Language (XAML)&lt;br /&gt;
* Kiddo&lt;br /&gt;
* Spring Configuration&lt;br /&gt;
&lt;br /&gt;
== Internal vs. External ==&lt;br /&gt;
Among OODSLs there is a distinction between internal OODSLs and external OODSLs.  Internal or embedded OODSLs give a &amp;quot;host&amp;quot; language domain-specific extensions or elements.  For example, an internal OODSL may extend a general purpose language to allow for easier implementation of generating graphics through the use of specific APIs.  An example of an embedded OODSL is Javascript hosted within an HTML document.&lt;br /&gt;
&lt;br /&gt;
However, there is a fuzzy line between embedded OODSLs and 3rd party libraries.  For example, the drawing methods of a Graphics object within Java may be considered an embedded OODSL or just a series of library APIS that are used in a contractual way.&lt;br /&gt;
&lt;br /&gt;
External OODSLs are languages that are not hosted within another language, but are compiled or interpreted in a standalone manner.  These OODSLs usually have a complete toolset and development environment behind them.  It is up to the language implementor, but external OODSLs are generally interpreted instead of compiled.  However, a OODSL does not necessarily need to be compiled into executable code.  A OODSL may be a representation of something else.  The CSound OODSL compiles a an Orchestra and Score markup files into audio.  Another example is compiling or converting SVG into a rasterized image, such as Portable Networg Graphics (PNG).&lt;br /&gt;
&lt;br /&gt;
== Practical Example: Java Swing and SVG ==&lt;br /&gt;
One way to illustrate the benefits of OODSLs is to compare a OODSL and a general purpose language performing the same task.  The following practical example illustrates how a language like Java and an OODSL perform painting tasks.  Both examples will draw a square button with the word ''Button'' in the center.  The Java code is taken from a common [http://en.wikipedia.org/wiki/Java_Swing Swing] construct where a JButton overrides it's paintComponent method to draw something more custom than the Swing default look and feel.  The Java Graphics API is used to perform both vector and raster drawing operations within a Java application.  These operations could be used for either drawing user interfaces or directly onto in-memory images for later display.  Here is an example of drawing a square button using a Java Graphics object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@Override&lt;br /&gt;
protected void paintComponent(Graphics g) {&lt;br /&gt;
	// Save the current context's color&lt;br /&gt;
	Color savedColor = g.getColor();&lt;br /&gt;
&lt;br /&gt;
	// Fill the shape&lt;br /&gt;
	g.setColor(Color.gray);&lt;br /&gt;
	g.fillRect(0, 0, getWidth(), getHeight());&lt;br /&gt;
&lt;br /&gt;
	// Draw the text&lt;br /&gt;
	g.setColor(Bolor.black);&lt;br /&gt;
	g.drawString(&amp;quot;Button&amp;quot;, 2, getHeight()-3);&lt;br /&gt;
&lt;br /&gt;
	// Draw the border&lt;br /&gt;
	g.setColor(Color.black);&lt;br /&gt;
	g.drawRect(0, 0, getWidth()-1, getHeight()-1);&lt;br /&gt;
&lt;br /&gt;
	// Restore the context's color&lt;br /&gt;
	g.setColor(savedColor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is quite procedural despite it being a methodology within an object-oriented language.  Using a general purpose language like Java to perform something as domain-specific as graphics generation can lead to a lot of redundant overhead that is taken care of in a specialized language.  This example illustrated the saving and restoring of the Graphic object's ''Color'' attribute, but could have required the saving and subsequent restoration of multiple properties, such as the current ''Transform'', ''Stroke'' or ''Font''.  An OODSL would provide a more robust and flexible set of drawing and graphics APIs that would ideally perform the redundant tasks like saving and restoring the graphics state attributes, as is the case with SVG.  Here is the same example written in using this OODSL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot;&lt;br /&gt;
 &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;lt;svg width=&amp;quot;10%&amp;quot; height=&amp;quot;10%&amp;quot; version=&amp;quot;1.1&amp;quot; xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot;&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;rect width=&amp;quot;100%&amp;quot; height=&amp;quot;100%&amp;quot;&lt;br /&gt;
	      style=&amp;quot;fill:rgb(128,128,128);stroke-width:1;stroke:rgb(0,0,0)&amp;quot; /&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;text x=&amp;quot;35%&amp;quot; y=&amp;quot;50%&amp;quot;&amp;amp;gt;Button&amp;amp;lt;/text&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/svg&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code is more declarative, object-oriented and much less procedural.  Instead of using a method to draw a rectangle the rectangle itself is an object with many data members used to define how the rectangle is rendered.  Ironically, the style attribute of the rectangle is a subset of CSS, another OODSL.  Since SVG is a language specific to the vector and imagery domain it provides capabilities (like opacity and gradients) that may be difficult to perform in general purpose languages without specialized libraries or an internal OODSL.&lt;br /&gt;
&lt;br /&gt;
The SVG declaration could be &amp;quot;compiled&amp;quot; into an image format (such as JPG) as opposed to the Java code, which can only paint on the Graphics context passed into it.  The point is, the SVG implementation is more versatile within the image domain in performing the same or similar methods as a general purpose language like Java.&lt;br /&gt;
&lt;br /&gt;
== When should OODSLs be used? ==&lt;br /&gt;
In order to determine if a OODSL should be used or created you must first examine the advantages of OODSLs.  If the problem domain is a well-known domain that already has an OODSL defined for it then it may be useful to use this OODSL, after all it was created for a reason.  If the selected OODSL does not fully support the operations needed for the problem domain then maybe a different OODSL is needed or the OODSL needs to be extended.&lt;br /&gt;
&lt;br /&gt;
If, however, there is no existing OODSL defined then creating a new OODSL may be the answer.  This usually happens when there is a well-defined or at least well-understood domain where certain operations are performed over and over again.  For example, a good candidate for an OODSL is robotics.  Consider a robotic arm in a factory that needs to perform repetetive tasks such as picking up an object from one conveyor belt and moving it to another.  If there is a OODSL that defines the movements of the arm then new behaviors could be easily added to the armature and existing actions can be easily changed.  These changes in behavior may even be performed by a technician or subject matter expert (SME) instead of a developer.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Object-oriented Domain-specific Languages provide a level of abstraction to a given domain.  This abstraction may result in enhanced capabilities (such as rapid prototyping) or a greater control or understanding of that domain.  It may also enable non-developers, like SMEs, to write &amp;quot;code&amp;quot; that utilizes the OODSL to affect a system or generate some sort of output.  OODSLs are classified as either internal or external where internal is an OODSL that &amp;quot;lives&amp;quot; within a host language and external is a standalone language in its own right.  General purpose languages are good for just that, general purpose development.  OODSLs are very focused and are prevalent in almost every niche of computing.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
*Mernik, M., Heering, J., and Sloane, A. M. 2005. When and how to develop domain-specific languages. ACM Comput. Surv. 37, 4 (Dec. 2005), 316-344. DOI= http://doi.acm.org/10.1145/1118890.1118892&lt;br /&gt;
*&amp;quot;Domain-specific Language.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/Domain-specific_language.&lt;br /&gt;
*&amp;quot;UnrealScript.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/UnrealScript.&lt;br /&gt;
*&amp;quot;InfoQ: What's a Ruby DSL and What Isn't?&amp;quot; ''InfoQ: Tracking Change and Innovation in the Enterprise Software Development Community.'' Web. 08 Sept. 2010. http://www.infoq.com/news/2007/06/dsl-or-not.&lt;br /&gt;
*&amp;quot;MF Bliki: DomainSpecificLanguage.&amp;quot; ''Martin Fowler.'' Web. 08 Sept. 2010. http://www.martinfowler.com/bliki/DomainSpecificLanguage.html.&lt;br /&gt;
*&amp;quot;Extensible Application Markup Language.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/XAML.&lt;br /&gt;
*&amp;quot;Scalable Vector Graphics.&amp;quot; ''Wikipedia, the Free Encyclopedia.'' Web. 08 Sept. 2010. http://en.wikipedia.org/wiki/SVG.&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=34077</id>
		<title>CSC/ECE 517 Fall 2010/ch2 S23 GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=34077"/>
		<updated>2010-09-08T23:16:01Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Object-Oriented Domain-Specific Languages ==&lt;br /&gt;
Domain-specific Languages, or DSLs, are programming languages or a subset of other languages that are used to solve domain specific problems.  This is in opposition to general purpose programming languages that are used for all problems.  The advantage of DSLs over general purpose languages are they are more targeted to a specific set of problems that may be higher level than is necessary for a general purpose language.  Domain-specific languages are is use everyday, even though it may not be apparent.  Here are examples of some domain-specific languages:&lt;br /&gt;
* CSS&lt;br /&gt;
* SQL&lt;br /&gt;
* Regular Expressions&lt;br /&gt;
* UnrealScript&lt;br /&gt;
&lt;br /&gt;
General purpose languages contain more functionality than DSLs and generally provide specific system level access.  Of course this may be a misnomer since a DSL may be developed specifically to handle system level APIs, like file systems.  Examples of general purpose languages include:&lt;br /&gt;
* Java&lt;br /&gt;
* C++&lt;br /&gt;
* C#&lt;br /&gt;
&lt;br /&gt;
Object-oriented Domain-specific Languages (OODSLs) differ from traditional DSLs in the same way that traditional languages differ from their object-oriented counterparts.  An OOP uses &amp;quot;objects&amp;quot;, which are data structures that contain both data members and methods.  Therefore, OODSLs are simply DSLs that exmploy and object-oriented paradigm.  Examples of OODSLs are:&lt;br /&gt;
* Scalable Vector Graphics (SVG)&lt;br /&gt;
* Extensible Application Markup Language (XAML)&lt;br /&gt;
* Kiddo&lt;br /&gt;
* Spring Configuration&lt;br /&gt;
&lt;br /&gt;
== Internal vs. External ==&lt;br /&gt;
Among OODSLs there is a distinction between internal OODSLs and external OODSLs.  Internal or embedded OODSLs give a &amp;quot;host&amp;quot; language domain-specific extensions or elements.  For example, an internal OODSL may extend a general purpose language to allow for easier implementation of generating graphics through the use of specific APIs.  An example of an embedded OODSL is Javascript hosted within an HTML document.&lt;br /&gt;
&lt;br /&gt;
However, there is a fuzzy line between embedded OODSLs and 3rd party libraries.  For example, the drawing methods of a Graphics object within Java may be considered an embedded OODSL or just a series of library APIS that are used in a contractual way.&lt;br /&gt;
&lt;br /&gt;
External OODSLs are languages that are not hosted within another language, but are compiled or interpreted in a standalone manner.  These OODSLs usually have a complete toolset and development environment behind them.  It is up to the language implementor, but external OODSLs are generally interpreted instead of compiled.  However, a OODSL does not necessarily need to be compiled into executable code.  A OODSL may be a representation of something else.  The CSound OODSL compiles a an Orchestra and Score markup files into audio.  Another example is compiling or converting SVG into a rasterized image, such as Portable Networg Graphics (PNG).&lt;br /&gt;
&lt;br /&gt;
== Practical Example: Java Swing and SVG ==&lt;br /&gt;
One way to illustrate the benefits of OODSLs is to compare a OODSL and a general purpose language performing the same task.  The following practical example illustrates how a language like Java and an OODSL perform painting tasks.  Both examples will draw a square button with the word ''Button'' in the center.  The Java code is taken from a common [http://en.wikipedia.org/wiki/Java_Swing Swing] construct where a JButton overrides it's paintComponent method to draw something more custom than the Swing default look and feel.  The Java Graphics API is used to perform both vector and raster drawing operations within a Java application.  These operations could be used for either drawing user interfaces or directly onto in-memory images for later display.  Here is an example of drawing a square button using a Java Graphics object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@Override&lt;br /&gt;
protected void paintComponent(Graphics g) {&lt;br /&gt;
	// Save the current context's color&lt;br /&gt;
	Color savedColor = g.getColor();&lt;br /&gt;
&lt;br /&gt;
	// Fill the shape&lt;br /&gt;
	g.setColor(Color.gray);&lt;br /&gt;
	g.fillRect(0, 0, getWidth(), getHeight());&lt;br /&gt;
&lt;br /&gt;
	// Draw the text&lt;br /&gt;
	g.setColor(Bolor.black);&lt;br /&gt;
	g.drawString(&amp;quot;Button&amp;quot;, 2, getHeight()-3);&lt;br /&gt;
&lt;br /&gt;
	// Draw the border&lt;br /&gt;
	g.setColor(Color.black);&lt;br /&gt;
	g.drawRect(0, 0, getWidth()-1, getHeight()-1);&lt;br /&gt;
&lt;br /&gt;
	// Restore the context's color&lt;br /&gt;
	g.setColor(savedColor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is quite procedural despite it being a methodology within an object-oriented language.  Using a general purpose language like Java to perform something as domain-specific as graphics generation can lead to a lot of redundant overhead that is taken care of in a specialized language.  This example illustrated the saving and restoring of the Graphic object's ''Color'' attribute, but could have required the saving and subsequent restoration of multiple properties, such as the current ''Transform'', ''Stroke'' or ''Font''.  An OODSL would provide a more robust and flexible set of drawing and graphics APIs that would ideally perform the redundant tasks like saving and restoring the graphics state attributes, as is the case with SVG.  Here is the same example written in using this OODSL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot;&lt;br /&gt;
 &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;lt;svg width=&amp;quot;10%&amp;quot; height=&amp;quot;10%&amp;quot; version=&amp;quot;1.1&amp;quot; xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot;&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;rect width=&amp;quot;100%&amp;quot; height=&amp;quot;100%&amp;quot;&lt;br /&gt;
	      style=&amp;quot;fill:rgb(128,128,128);stroke-width:1;stroke:rgb(0,0,0)&amp;quot; /&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;text x=&amp;quot;35%&amp;quot; y=&amp;quot;50%&amp;quot;&amp;amp;gt;Button&amp;amp;lt;/text&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/svg&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code is more declarative, object-oriented and much less procedural.  Instead of using a method to draw a rectangle the rectangle itself is an object with many data members used to define how the rectangle is rendered.  Ironically, the style attribute of the rectangle is a subset of CSS, another OODSL.  Since SVG is a language specific to the vector and imagery domain it provides capabilities (like opacity and gradients) that may be difficult to perform in general purpose languages without specialized libraries or an internal OODSL.&lt;br /&gt;
&lt;br /&gt;
The SVG declaration could be &amp;quot;compiled&amp;quot; into an image format (such as JPG) as opposed to the Java code, which can only paint on the Graphics context passed into it.  The point is, the SVG implementation is more versatile within the image domain in performing the same or similar methods as a general purpose language like Java.&lt;br /&gt;
&lt;br /&gt;
== When should OODSLs be used? ==&lt;br /&gt;
In order to determine if a OODSL should be used or created you must first examine the advantages of OODSLs.  If the problem domain is a well-known domain that already has an OODSL defined for it then it may be useful to use this OODSL, after all it was created for a reason.  If the selected OODSL does not fully support the operations needed for the problem domain then maybe a different OODSL is needed or the OODSL needs to be extended.&lt;br /&gt;
&lt;br /&gt;
If, however, there is no existing OODSL defined then creating a new OODSL may be the answer.  This usually happens when there is a well-defined or at least well-understood domain where certain operations are performed over and over again.  For example, a good candidate for an OODSL is robotics.  Consider a robotic arm in a factory that needs to perform repetetive tasks such as picking up an object from one conveyor belt and moving it to another.  If there is a OODSL that defines the movements of the arm then new behaviors could be easily added to the armature and existing actions can be easily changed.  These changes in behavior may even be performed by a technician or subject matter expert (SME) instead of a developer.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Object-oriented Domain-specific Languages provide a level of abstraction to a given domain.  This abstraction may result in enhanced capabilities (such as rapid prototyping) or a greater control or understanding of that domain.  It may also enable non-developers, like SMEs, to write &amp;quot;code&amp;quot; that utilizes the OODSL to affect a system or generate some sort of output.  OODSLs are classified as either internal or external where internal is an OODSL that &amp;quot;lives&amp;quot; within a host language and external is a standalone language in its own right.  General purpose languages are good for just that, general purpose development.  OODSLs are very focused and are prevalent in almost every niche of computing.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
*[http://portal.acm.org/citation.cfm?id=1118890.1118892 ACM - When and how to develop domain-specific languages]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Domain-specific_language Wikipedia - Domain-specific Language]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/UnrealScript Wikipedia - UnrealScript]&lt;br /&gt;
*[http://www.infoq.com/news/2007/06/dsl-or-not What's a Ruby DSL and what isn't?]&lt;br /&gt;
*[http://www.martinfowler.com/bliki/DomainSpecificLanguage.html Martin Fowler - Domain-specific Language]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/XAML Wikipedia - Extensible Application Markup Language]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/SVG Wikipedia - Scalable Vector Graphics]&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=34020</id>
		<title>CSC/ECE 517 Fall 2010/ch2 S23 GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=34020"/>
		<updated>2010-09-08T21:41:38Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Object-Oriented Domain-Specific Languages ==&lt;br /&gt;
Domain-specific Languages, or DSLs, are programming languages or a subset of other languages that are used to solve domain specific problems.  This is in opposition to general purpose programming languages that are used for all problems.  The advantage of DSLs over general purpose languages are they are more targeted to a specific set of problems that may be higher level than is necessary for a general purpose language.  Domain-specific languages are is use everyday, even though it may not be apparent.  Here are examples of some domain-specific languages:&lt;br /&gt;
* CSS&lt;br /&gt;
* SQL&lt;br /&gt;
* Regular Expressions&lt;br /&gt;
* UnrealScript&lt;br /&gt;
&lt;br /&gt;
General purpose languages contain more functionality than DSLs and generally provide specific system level access.  Of course this may be a misnomer since a DSL may be developed specifically to handle system level APIs, like file systems.  Examples of general purpose languages include:&lt;br /&gt;
* Java&lt;br /&gt;
* C++&lt;br /&gt;
* C#&lt;br /&gt;
&lt;br /&gt;
Object-oriented Domain-specific Languages (OODSLs) differ from traditional DSLs in the same way that traditional languages differ from their object-oriented counterparts.  An OOP uses &amp;quot;objects&amp;quot;, which are data structures that contain both data members and methods.  Therefore, OODSLs are simply DSLs that exmploy and object-oriented paradigm.  Examples of OODSLs are:&lt;br /&gt;
* Scalable Vector Graphics (SVG)&lt;br /&gt;
* Extensible Application Markup Language (XAML)&lt;br /&gt;
* Kiddo&lt;br /&gt;
* Spring Configuration&lt;br /&gt;
&lt;br /&gt;
== Internal vs. External ==&lt;br /&gt;
Among OODSLs there is a distinction between internal OODSLs and external OODSLs.  Internal or embedded OODSLs give a &amp;quot;host&amp;quot; language domain-specific extensions or elements.  For example, an internal OODSL may extend a general purpose language to allow for easier implementation of generating graphics through the use of specific APIs.  An example of an embedded OODSL is Javascript hosted within an HTML document.&lt;br /&gt;
&lt;br /&gt;
However, there is a fuzzy line between embedded OODSLs and 3rd party libraries.  For example, the drawing methods of a Graphics object within Java may be considered an embedded OODSL or just a series of library APIS that are used in a contractual way.&lt;br /&gt;
&lt;br /&gt;
External OODSLs are languages that are not hosted within another language, but are compiled or interpreted in a standalone manner.  These OODSLs usually have a complete toolset and development environment behind them.  It is up to the language implementor, but external OODSLs are generally interpreted instead of compiled.  However, a OODSL does not necessarily need to be compiled into executable code.  A OODSL may be a representation of something else.  The CSound OODSL compiles a an Orchestra and Score markup files into audio.  Another example is compiling or converting SVG into a rasterized image, such as Portable Networg Graphics (PNG).&lt;br /&gt;
&lt;br /&gt;
== Practical Example: Java2D and SVG ==&lt;br /&gt;
One way to illustrate the benefits of OODSLs is to compare a OODSL and a general purpose language performing the same task.  The following practical example illustrates how a language like Java and an OODSL perform painting tasks.  Both examples will draw a square button with the word ''Button'' in the center.  The Java code is taken from a common [http://en.wikipedia.org/wiki/Java_Swing Swing] construct where a JButton overrides it's paintComponent method to draw something more custom than the Swing default look and feel.  The Java Graphics API is used to perform both vector and raster drawing operations within a Java application.  These operations could be used for either drawing user interfaces or directly onto in-memory images for later display.  Here is an example of drawing a square button using a Java Graphics object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@Override&lt;br /&gt;
protected void paintComponent(Graphics g) {&lt;br /&gt;
	// Save the current context's color&lt;br /&gt;
	Color savedColor = g.getColor();&lt;br /&gt;
&lt;br /&gt;
	// Fill the shape&lt;br /&gt;
	g.setColor(Color.gray);&lt;br /&gt;
	g.fillRect(0, 0, getWidth(), getHeight());&lt;br /&gt;
&lt;br /&gt;
	// Draw the text&lt;br /&gt;
	g.setColor(Bolor.black);&lt;br /&gt;
	g.drawString(&amp;quot;Button&amp;quot;, 2, getHeight()-3);&lt;br /&gt;
&lt;br /&gt;
	// Draw the border&lt;br /&gt;
	g.setColor(Color.black);&lt;br /&gt;
	g.drawRect(0, 0, getWidth()-1, getHeight()-1);&lt;br /&gt;
&lt;br /&gt;
	// Restore the context's color&lt;br /&gt;
	g.setColor(savedColor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is quite procedural and while minimally illustrated can  lead to a lot of housekeeping.  In the previous example the Graphic object's color needed to be saved and then restored.  An OODSL would provide a more robust and flexible set of drawing and graphics APIs.  Such is the case with SVG, here is the same example written in using this OODSL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot;&lt;br /&gt;
 &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;lt;svg width=&amp;quot;10%&amp;quot; height=&amp;quot;10%&amp;quot; version=&amp;quot;1.1&amp;quot; xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot;&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;rect width=&amp;quot;100%&amp;quot; height=&amp;quot;100%&amp;quot;&lt;br /&gt;
	      style=&amp;quot;fill:rgb(128,128,128);stroke-width:1;stroke:rgb(0,0,0)&amp;quot; /&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;text x=&amp;quot;35%&amp;quot; y=&amp;quot;50%&amp;quot;&amp;amp;gt;Button&amp;amp;lt;/text&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/svg&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code is more declarative, supports more options (like opacity and gradients) and is quite domain focused.  Also, it is more object-oriented than the previous Java code since each shape is an object with attributes as opposed to Java's procedural drawing methodology.  The SVG declaration could be &amp;quot;compiled&amp;quot; into an image format (such as JPG) as opposed to the Java code, which can only paint on the Graphics context passed into it.  The point is the SVG implementation is more versatile within the image domain in performing the same or similar methods as a general purpose language like Java.&lt;br /&gt;
&lt;br /&gt;
== When should OODSLs be used? ==&lt;br /&gt;
In order to determine if a OODSL should be used or created you must first examine the advantages of OODSLs.  If the problem domain is a well-known domain that already has an OODSL defined for it then it may be useful to use this OODSL, after all it was created for a reason.  If the selected OODSL does not fully support the operations needed for the problem domain then maybe a different OODSL is needed or the OODSL needs to be extended.&lt;br /&gt;
&lt;br /&gt;
If, however, there is no existing OODSL defined then creating a new OODSL may be the answer.  This usually happens when there is a well-defined or at least well-understood domain where certain operations are performed over and over again.  For example, a good candidate for an OODSL is robotics.  Consider a robotic arm in a factory that needs to perform repetetive tasks such as picking up an object from one conveyor belt and moving it to another.  If there is a OODSL that defines the movements of the arm then new behaviors could be easily added to the armature and existing actions can be easily changed.  These changes in behavior may even be performed by a technician or subject matter expert (SME) instead of a developer.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Object-oriented Domain-specific Languages provide a level of abstraction to a given domain.  This abstraction may result in enhanced capabilities (such as rapid prototyping) or a greater control or understanding of that domain.  It may also enable non-developers, like SMEs, to write &amp;quot;code&amp;quot; that utilizes the OODSL to affect a system or generate some sort of output.  OODSLs are classified as either internal or external where internal is an OODSL that &amp;quot;lives&amp;quot; within a host language and external is a standalone language in its own right.  General purpose languages are good for just that, general purpose development.  OODSLs are very focused and are prevalent in almost every niche of computing.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
*[http://portal.acm.org/citation.cfm?id=1118890.1118892 ACM - When and how to develop domain-specific languages]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Domain-specific_language Wikipedia - Domain-specific Language]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/UnrealScript Wikipedia - UnrealScript]&lt;br /&gt;
*[http://www.infoq.com/news/2007/06/dsl-or-not What's a Ruby DSL and what isn't?]&lt;br /&gt;
*[http://www.martinfowler.com/bliki/DomainSpecificLanguage.html Martin Fowler - Domain-specific Language]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/XAML Wikipedia - Extensible Application Markup Language]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/SVG Wikipedia - Scalable Vector Graphics]&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=33506</id>
		<title>CSC/ECE 517 Fall 2010/ch2 S23 GP</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S23_GP&amp;diff=33506"/>
		<updated>2010-09-08T04:48:07Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to Object-Oriented Domain-Specific Languages ==&lt;br /&gt;
Domain-specific Languages, or DSLs, are programming languages or a subset of other languages that are used to solve domain specific problems.  This is in opposition to general purpose programming languages that are used for all problems.  The advantage of DSLs over general purpose languages are they are more targeted to a specific set of problems that may be higher level than is necessary for a general purpose language.  Domain-specific languages are is use everyday, even though it may not be apparent.  Here are examples of some domain-specific languages:&lt;br /&gt;
* CSS&lt;br /&gt;
* SQL&lt;br /&gt;
* Regular Expressions&lt;br /&gt;
* UnrealScript&lt;br /&gt;
&lt;br /&gt;
General purpose languages contain more functionality than DSLs and generally provide specific system level access.  Of course this may be a misnomer since a DSL may be developed specifically to handle system level APIs, like file systems.  Examples of general purpose languages include:&lt;br /&gt;
* Java&lt;br /&gt;
* C++&lt;br /&gt;
* C#&lt;br /&gt;
&lt;br /&gt;
Object-oriented Domain-specific Languages (OODSLs) differ from traditional DSLs in the same way that traditional languages differ from their object-oriented counterparts.  An OOP uses &amp;quot;objects&amp;quot;, which are data structures that contain both data members and methods.  Therefore, OODSLs are simply DSLs that exmploy and object-oriented paradigm.  Examples of OODSLs are:&lt;br /&gt;
* Scalable Vector Graphics (SVG)&lt;br /&gt;
* Extensible Application Markup Language (XAML)&lt;br /&gt;
* Kiddo&lt;br /&gt;
* Spring Configuration&lt;br /&gt;
&lt;br /&gt;
== Internal vs. External ==&lt;br /&gt;
Among OODSLs there is a distinction between internal OODSLs and external OODSLs.  Internal or embedded OODSLs give a &amp;quot;host&amp;quot; language domain-specific extensions or elements.  For example, an internal OODSL may extend a general purpose language to allow for easier implementation of generating graphics through the use of specific APIs.  An example of an embedded OODSL is Javascript hosted within an HTML document.&lt;br /&gt;
&lt;br /&gt;
However, there is a fuzzy line between embedded OODSLs and 3rd party libraries.  For example, the drawing methods of a Graphics object within Java may be considered an embedded OODSL or just a series of library APIS that are used in a contractual way.&lt;br /&gt;
&lt;br /&gt;
External OODSLs are languages that are not hosted within another language, but are compiled or interpreted in a standalone manner.  These OODSLs usually have a complete toolset and development environment behind them.  It is up to the language implementor, but external OODSLs are generally interpreted instead of compiled.  However, a OODSL does not necessarily need to be compiled into executable code.  A OODSL may be a representation of something else.  The CSound OODSL compiles a an Orchestra and Score markup files into audio.  Another example is compiling or converting SVG into a rasterized image, such as Portable Networg Graphics (PNG).&lt;br /&gt;
&lt;br /&gt;
== Practical Example: Java2D and SVG ==&lt;br /&gt;
The Java2D API is used to perform both vector and raster drawing operations within a Java application.  These operations could be used for either drawing user interfaces or directly onto in-memory images for later display.  Here is an example of drawing a square button using the Java2D API.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@Override&lt;br /&gt;
protected void paintComponent(Graphics g) {&lt;br /&gt;
	// Save the current context's color&lt;br /&gt;
	Color savedColor = g.getColor();&lt;br /&gt;
&lt;br /&gt;
	// Fill the shape&lt;br /&gt;
	g.setColor(Color.gray);&lt;br /&gt;
	g.fillRect(0, 0, getWidth(), getHeight());&lt;br /&gt;
&lt;br /&gt;
	// Draw the text&lt;br /&gt;
	g.setColor(Bolor.black);&lt;br /&gt;
	g.drawString(&amp;quot;Button&amp;quot;, 2, getHeight()-3);&lt;br /&gt;
&lt;br /&gt;
	// Draw the border&lt;br /&gt;
	g.setColor(Color.black);&lt;br /&gt;
	g.drawRect(0, 0, getWidth()-1, getHeight()-1);&lt;br /&gt;
&lt;br /&gt;
	// Restore the context's color&lt;br /&gt;
	g.setColor(savedColor);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is quite procedural and while minimally illustrated can  lead to a lot of housekeeping.  In the previous example the Graphic object's color needed to be saved and then restored.  An OODSL would provide a more robust and flexible set of drawing and graphics APIs.  Such is the case with SVG, here is the same example written in SVG.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot;&lt;br /&gt;
 &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;lt;svg width=&amp;quot;10%&amp;quot; height=&amp;quot;10%&amp;quot; version=&amp;quot;1.1&amp;quot; xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot;&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;rect width=&amp;quot;100%&amp;quot; height=&amp;quot;100%&amp;quot;&lt;br /&gt;
	      style=&amp;quot;fill:rgb(128,128,128);stroke-width:1;stroke:rgb(0,0,0)&amp;quot; /&amp;amp;gt;&lt;br /&gt;
	&amp;amp;lt;text x=&amp;quot;35%&amp;quot; y=&amp;quot;50%&amp;quot;&amp;amp;gt;Button&amp;amp;lt;/text&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/svg&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code is more declarative, supports more options (like opacity and gradients) and is quite domain focused.  Also, it is more object-oriented than the previous Java code since each shape is an object with attributes as opposed to Java's procedural drawing methodology.&lt;br /&gt;
&lt;br /&gt;
== When should OODSLs be used? ==&lt;br /&gt;
In order to determine if a OODSL should be used or created you must first examine the advantages of OODSLs.  If the problem domain is a well-known domain that already has an OODSL defined for it then it may be useful to use this OODSL, after all it was created for a reason.  If the selected OODSL does not fully support the operations needed for the problem domain then maybe a different OODSL is needed or the OODSL needs to be extended.&lt;br /&gt;
&lt;br /&gt;
If, however, there is no existing OODSL defined then creating a new OODSL may be the answer.  This usually happens when there is a well-defined or at least well-understood domain where certain operations are performed over and over again.  For example, a good candidate for an OODSL is robotics.  Consider a robotic arm in a factory that needs to perform repetetive tasks such as picking up an object from one conveyor belt and moving it to another.  If there is a OODSL that defines the movements of the arm then new behaviors could be easily added to the armature and existing actions can be easily changed.  These changes in behavior may even be performed by a technician or subject matter expert (SME) instead of a developer.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Object-oriented Domain-specific Languages provide a level of abstraction to a given domain.  This abstraction may result in enhanced capabilities (such as rapid prototyping) or a greater control or understanding of that domain.  It may also enable non-developers, like SMEs, to write &amp;quot;code&amp;quot; that utilizes the OODSL to affect a system or generate some sort of output.  OODSLs are classified as either internal or external where internal is an OODSL that &amp;quot;lives&amp;quot; within a host language and external is a standalone language in its own right.  General purpose languages are good for just that, general purpose development.  OODSLs are very focused and are prevalent in almost every niche of computing.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
*[http://portal.acm.org/citation.cfm?id=1118890.1118892 ACM - When and how to develop domain-specific languages]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Domain-specific_language Wikipedia - Domain-specific Language]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/UnrealScript Wikipedia - UnrealScript]&lt;br /&gt;
*[http://www.infoq.com/news/2007/06/dsl-or-not What's a Ruby DSL and what isn't?]&lt;br /&gt;
*[http://www.martinfowler.com/bliki/DomainSpecificLanguage.html Martin Fowler - Domain-specific Language]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/XAML Wikipedia - Extensible Application Markup Language]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/SVG Wikipedia - Scalable Vector Graphics]&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S20_st&amp;diff=33498</id>
		<title>CSC/ECE 517 Fall 2010/ch2 S20 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_S20_st&amp;diff=33498"/>
		<updated>2010-09-08T04:31:44Z</updated>

		<summary type="html">&lt;p&gt;Gpascar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[CSC/ECE 517 Fall 2010/ch1 S10 MS]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE_517_Fall_2010/ch1_1a_br]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 GP]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S10 MM]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2010/ch1 S23 GP]]&lt;/div&gt;</summary>
		<author><name>Gpascar</name></author>
	</entry>
</feed>