Declarative Programming

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 %>” 

            “DELETE FROM [movies] WHERE [movie_id] = @movie_id”       

              “INSERT INTO [movies] ([title], [release_date]) VALUES (@title,     @release_date)” 

“<%$ 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”> 


            <asp:Parameter Name=”title” Type=”String” /> 

            <asp:Parameter Name=”release_date” Type=”DateTime” /> 



            <asp:Parameter Name=”title” Type=”String” /> 

            <asp:Parameter Name=”release_date” Type=”DateTime” /> 

            <asp:Parameter Name=”movie_id” Type=”Int32″ /> 



            <asp:Parameter Name=”movie_id” Type=”Int32″ /> 



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=”“> 


      <add src=”ScriptLibrary/AtlasUI.js” /> 

      <add src=”ScriptLibrary/AtlasControls.js” /> 



      <textBox id=”SearchKey” /> 

      <serviceMethod id=”helloService” url=”HelloWorldService.asmx” 



          <binding dataContext=”SearchKey” dataPath=”text” 

            property=”parameters” propertyKey=”query” /> 



          <invokeMethod target=”resultsBinding” 

            method=”evaluateIn” /> 



      <button targetElement=”SearchButton”> 


          <invokeMethod target=”helloService” method=”invoke” /> 



      <label targetElement=”results”> 


          <binding id=”resultsBinding” dataContext=”helloService” 

            dataPath=”response.object” property=”text” 

            automatic=”false” /> 






Leave a Reply

Your email address will not be published. Required fields are marked *