A new trend in programming is beginning to emerge that has the potential to simplify some common tasks. The trend I am talking about is declarative programming. It can be seen in ASP.NET and the new emerging ATLAS technology. One of the things you will quickly notice is that the code is easy to ready and integrates well with the technologies. To get an idea of what declarative programming looks like I have included some examples in ASP.NET and ATLAS.
ASP.NET Sample
This sample demonstrates creating an SQLDataSource object declaratively. Notice how easy it is to declare Insert, Update and Delete commands as well as parameters that can go with these command.
<asp:SqlDataSource ID=”SqlDataSource1″ runat=”server”
ConnectionString=”<%$ ConnectionStrings:introaspdotnetConnectionString1 %>”
DeleteCommand=
“DELETE FROM [movies] WHERE [movie_id] = @movie_id”
InsertCommand=
“INSERT INTO [movies] ([title], [release_date]) VALUES (@title, @release_date)”
ProviderName=
“<%$ ConnectionStrings:introaspdotnetConnectionString1.ProviderName %>”
SelectCommand=”SELECT [movie_id], [title], [release_date] FROM [movies]”
UpdateCommand=”UPDATE [movies] SET [title] = @title, [release_date] = @release_date WHERE [movie_id] = @movie_id”>
<InsertParameters>
<asp:Parameter Name=”title” Type=”String” />
<asp:Parameter Name=”release_date” Type=”DateTime” />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name=”title” Type=”String” />
<asp:Parameter Name=”release_date” Type=”DateTime” />
<asp:Parameter Name=”movie_id” Type=”Int32″ />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name=”movie_id” Type=”Int32″ />
</DeleteParameters>
</asp:SqlDataSource
ATLAS Sample
This sample demonstrates how you can write script declaratively in ATLAS. In this sample reference files are declared, web services that are called are declared and databinding and events are declared all without writing standard code.
<script type=”text/xml-script”>
<page xmlns:script=”http://schemas.microsoft.com/xml-script/2005“>
<references>
<add src=”ScriptLibrary/AtlasUI.js” />
<add src=”ScriptLibrary/AtlasControls.js” />
</references>
<components>
<textBox id=”SearchKey” />
<serviceMethod id=”helloService” url=”HelloWorldService.asmx”
methodName=”HelloWorld”>
<bindings>
<binding dataContext=”SearchKey” dataPath=”text”
property=”parameters” propertyKey=”query” />
</bindings>
<completed>
<invokeMethod target=”resultsBinding”
method=”evaluateIn” />
</completed>
</serviceMethod>
<button targetElement=”SearchButton”>
<click>
<invokeMethod target=”helloService” method=”invoke” />
</click>
</button>
<label targetElement=”results”>
<bindings>
<binding id=”resultsBinding” dataContext=”helloService”
dataPath=”response.object” property=”text”
automatic=”false” />
</bindings>
</label>
</components>
</page>
</script>