Category Archives: Software development

10 things every software architect should consider (AKA – 10 key architectural concepts)

After a session I gave about Scalability in Wellington NZ, one of developers asked me what are the things software architect should consider. I have gathered and compiled this list:

1. Security

Application security encompasses measures taken throughout the application’s life-cycle to prevent exceptions in the security policy of an application or the underlying system (vulnerabilities) through flaws in the design, development, deployment, upgradation, or maintenance of the application. [1]

2. Reliability / Consistency

Data consistency summarizes the validity, accuracy, usability and integrity of related data between applications and across the IT enterprise. This ensures that each user observes a consistent view of the data, including visible changes made by the user’s own transactions and transactions of other users or processes. Data Consistency problems may arise at any time but are frequently introduced during or following recovery situations when backup copies of the data are used in place of the original data. [2]

3. Scalability

Scalability is a desirable property of a system, a network, or a process, which indicates its ability to either handle growing amounts of work in a graceful manner, or to be readily enlarged. [3]

4. High Availability

High availability is a system design protocol and associated implementation that ensures a certain absolute degree of operational continuity during a given measurement period.

Availability refers to the ability of the user community to access the system, whether to submit new work, update or alter existing work, or collect the results of previous work. If a user cannot access the system, it is said to be unavailable. Generally, the term downtime is used to refer to periods when a system is unavailable. [4]

5. Interoperability / integration

Interoperability is a property referring to the ability of diverse systems and organizations to work together (inter-operate). With respect to software, the term interoperability is used to describe the capability of different programs to exchange data via a common set of exchange formats, to read and write the same file formats, and to use the same protocols. (The ability to execute the same binary code on different processor platforms is ‘not’ contemplated by the definition of interoperability.) The lack of interoperability can be a consequence of a lack of attention to standardization during the design of a program. Indeed, interoperability is not taken for granted in the non-standards-based portion of the computing world. [5]

6. Maintainability

In software engineering, the ease with which a software product can be modified in order to:

* correct defects

* meet new requirements

* make future maintenance easier, or

* cope with a changed environment;

[6]

7. Recovery / DR

Disaster recovery planning is a subset of a larger process known as business continuity planning and should include planning for resumption of applications, data, hardware, communications (such as networking) and other IT infrastructure. A business continuity plan (BCP) includes planning for non-IT related aspects such as key personnel, facilities, crisis communication and reputation protection, and should refer to the disaster recovery plan (DRP) for IT related infrastructure recovery / continuity. [7]

8. Performance

Determine how fast some aspect of a system performs under a particular workload. It can also serve to validate and verify other quality attributes of the system, such as scalability, reliability and resource usage. Performance testing is a subset of Performance engineering, an emerging computer science practice which strives to build performance into the design and architecture of a system, prior to the onset of actual coding effort. [8]

9. Standards/ Compliance

Software standard essentially is certain agreed to terms, concepts and techniques by software creators so that many different software can understand each other.

For instance, HTML, TCP/IP, SMTP, POP and FTP are software standards that basically all software designers must adhere to if the software decides to interface with these standards. For instance in order for a email to be read from Yahoo! Mail that is sent from a Microsoft Outlook software application and vice versa, the Microsoft Outlook needs to send the email using for instance the SMTP (Simple Mail Transfer Protocol) protocol (standard) and Yahoo! Mail receives it also through SMTP reader and displays the email. Without a standardized technique to send an email from Outlook to Yahoo! Mail, they can’t be able to accurately display emails sent between the two entities. Specifically, all emails essentially have “from,” “to,” “subject,” and “message” fields and those are the standard in which all emails should be designed and handled. [9]

10. User experience

A newly added member – User experience design is a subset of the field of experience design which pertains to the creation of the architecture and interaction models which impact a user’s perception of a device or system. The scope of the field is directed at affecting “all aspects of the user’s interaction with the product: how it is perceived, learned, and used. [10]

Seems about right… What do you think?

How to: Adding wildcard pages to robots.txt

Sometimes we want to exclude a page from search engines. For example, repetitive pages that might lead to page rank penalties.

If you want to exclude pages with a specific name from several locations in your site – for example you might have a comments.php or a help.php in multiple parts of your site, and you want to hide it from search engines, you need to modify robots.txt.

Here is how you do it:
1) Create or edit robots.txt in the root of your site
Continue reading

Generate and Format Last Updated in PHP

As a reader of many on line product reviews, I am always interested in the time this review is relevant for. As time pass things change and review get stale.

If you have this need as a webmaster and your review is file based (as appose to DB) you can use the filemtime function to automatically generate the last updated:


$LAST_UPDATED = date ("F d Y", filemtime('review.php'));

Where review.php is the file that holds the product review for example.
Continue reading

How to: Redirect 404 (page not found) pages in PHP and Apache – Internet Explorer problem

Sometimes you want your client to see a different page then the default 404 (page not found)
To do this you just need to add and entry to .htaccess file on your web folder:

ErrorDocument 404 /404err.php

404err.php is an example of the PHP page you want the Apache to serve instead of the apache default.
Continue reading

Does the open source professional services business model suck?

Today I participated and lectured at an open source event. It was great to meet enthusiastic people that believe in something bigger then themselves. These events are always a mixture of young people full of vigor and need for rebellion as well as more balanced older people that have believed in open source for a long time.

I have been intrigued with open source and open source business models for a long time now, so I might belong to the second group.

Anyway, in the keynote, the speaker talked about open source business models, saying that the professional services business model is better then proprietary code business model because it provides real value to the end consumer and because you get a return of your investment in this business model.

Well, I have my reservations:money

1) I have seen companies misuse the professional services business model (open source or not) – selling poor service and wasting the clients time and spending his money with "experts" that know very little.

2) There is no motivation for a company, basing its business on open source development and professional services, to create simple and easy to use application. This is because simple and easy to use applications do not generate the need for professional services. Professional services thrive on complexity and difficulty.

opensource-110x953) Professional services business model (open source or not) can create a tension between the service provider that wants to prolong the duration and manpower sent on a project and the client how wants exactly the opposite

4) I am not sure the open source professional services business model is a big enough business to drive the entire market to open source products or to sustain open source companies.

I have once personally been told in an open source project – “Do not add this auto-configuration feature, it will kill our professional services” of course after a long “discussion” we added the feature, but the potential to provide a sucky product just to satisfy this open source business models was still there.

I am still thinking about and waiting for the business models that can really sustain and grow a  large scale and successful open source company.


You might also what to read how to spot a good software consultant

PHP calling .NET – PHP to WCF calls with parameters

In my last post I provided an example of PHP calling a .NET windows communication foundation web service. The PHP invoked the .NET service with no parameters, getting the time on server.

Sometime (well, most of the times) you need to pass parameters to the .NET web service. for example you might want to pass a client ID and get back its account balance.

 

Here is what you do:

First create a "out of the box" windows communication foundation (WCF) WCF service library project ( I used Visual Studio 2008) .

Then, modify the project files according to the files posted bellow. 

My server side WCF code looks like this:

1)  Service1.cs –

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WcfServiceLibrary2
{
    // NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in App.config.
    public class Service1 : IService1
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }

    }
}

2)  IService1.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WcfServiceLibrary2
{
    // NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in App.config.
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetData(int value);

    }   
}

The server side WCF application configuration (App.config) file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!– When deploying the service library project, the content of the config file must be added to the host’s
  app.config file. System.Configuration does not support config files for libraries. –>
  <system.serviceModel>
    <services>
      <service name="WcfServiceLibrary2.Service1" behaviorConfiguration="WcfServiceLibrary2.Service1Behavior">
        <host>
          <baseAddresses>
            <add baseAddress = "
http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary2/Service1/" />
          </baseAddresses>
        </host>
        <!– Service Endpoints –>
        <!– Unless fully qualified, address is relative to base address supplied above –>
        <endpoint address ="" binding="basicHttpBinding" contract="WcfServiceLibrary2.IService1">
          <!–
              Upon deployment, the following identity element should be removed or replaced to reflect the
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity
              automatically.
          –>
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!– Metadata Endpoints –>
        <!– The Metadata Exchange endpoint is used by the service to describe itself to clients. –>
        <!– This endpoint does not use a secure binding and should be secured or removed before deployment –>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfServiceLibrary2.Service1Behavior">
          <!– To avoid disclosing metadata information,
          set the value below to false and remove the metadata endpoint above before deployment –>
          <serviceMetadata httpGetEnabled="True"/>
          <!– To receive exception details in faults for debugging purposes,
          set the value below to true.  Set to false before deployment
          to avoid disclosing exception information –>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

 

Note my blog post about the importance of setting this WCF service binding to basicHttpBinding

The PHP side of the application code looks like this:

<h1>
<?php

try{
    $client = new
        SoapClient(
            "
http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary2/Service1/?wsdl"
        );
    $params = array(‘value’=>"3");
    $webService = $client->GetData($params);
    $wsResult = $webService->GetDataResult;
    print  $wsResult;
} catch (Exception $e) {
    print  ‘Caught exception: ‘.  $e->getMessage(). "\n";
}

?>

</h1>

 

This is very similar to the previous example of PHP to WCF communication, only here the PHP passes an array of parameters to the WCF web service:

$params = array(‘value’=>"3");
$webService = $client->GetData($params);

In my next post I will show how to investigate the WCF service and learn the parameters it requires and their soup names.


PHP calling .NET – PHP to WCF communication

I am done doing my first PHP to .NET interoperability example. In this example a PHP page calls a windows communication foundation (WCF) service in .NET

Here is what we want to create:

php-wcf 

 

First create a "out of the box" windows communication foundation (WCF) WCF service library project.

Then, modify the project files according to the files posted bellow.

My server side WCF code looks like this:

1)  Service1.cs –

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WcfServiceLibrary1
{
    // NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in App.config.
    public class Service1 : IService1
    {
        public string GetData()
        {
            return string.Format("Time on server is " + System.DateTime.Now.ToString());
        }

    }
}

2)  IService1.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WcfServiceLibrary1
{
    // NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in App.config.
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetData();

        // TODO: Add your service operations here
    }

}

The server side WCF application configuration file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!– When deploying the service library project, the content of the config file must be added to the host’s
  app.config file. System.Configuration does not support config files for libraries. –>
  <system.serviceModel>
    <services>
      <service name="WcfServiceLibrary1.Service1" behaviorConfiguration="WcfServiceLibrary1.Service1Behavior">
        <host>
          <baseAddresses>
            <add baseAddress = "
http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
          </baseAddresses>
        </host>
        <!– Service Endpoints –>
        <!– Unless fully qualified, address is relative to base address supplied above –>
        <endpoint address ="" binding="basicHttpBinding" contract="WcfServiceLibrary1.IService1">
          <!–
              Upon deployment, the following identity element should be removed or replaced to reflect the
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity
              automatically.
          –>
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!– Metadata Endpoints –>
        <!– The Metadata Exchange endpoint is used by the service to describe itself to clients. –>
        <!– This endpoint does not use a secure binding and should be secured or removed before deployment –>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfServiceLibrary1.Service1Behavior">
          <!– To avoid disclosing metadata information,
          set the value below to false and remove the metadata endpoint above before deployment –>
          <serviceMetadata httpGetEnabled="True"/>
          <!– To receive exception details in faults for debugging purposes,
          set the value below to true.  Set to false before deployment
          to avoid disclosing exception information –>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

Note my blog post about the importance of setting this WCF service binding to basicHttpBinding

 

The PHP side of the application code looks like this:

<h1>
<?php

try{
    $client = new
        SoapClient(
            "
http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary1/Service1/?wsdl"
        );

    $webService = $client->GetData();

    $wsResult = $webService->GetDataResult;

    print  $wsResult;

} catch (Exception $e) {

    print  ‘Caught exception: ‘.  $e->getMessage(). "\n";

}

?>

</h1>

The only thing you need to modify is the URL parameter passed to the SoapClient to match your WCF service URL.

If you want to pass parameters to the WCF web service call please see this blog post.

If you have any questions please post a reply.

PHP calling .NET – Running WCF service with basicHttpBinding

I am Writing a PHP application that needs to run a back end .NET application. When creating a running the WCF web service out of the box, the PHP could not connect to the web service.

The problem:

The PHP returns "Caught exception: Cannot process the message because the content type ‘text/xml; charset=utf-8’ was not the expected type ‘application/soap+xml; charset=utf-8’."

 

The reason:

WCF is running a new version of web services than expected by the PHP.

 

The solution:

Change the binding type of the WCF service from binding="wsHttpBinding" to binding="basicHttpBinding".

This insures that your .NET web service would support clients and other services that conform to the WS-I standards.

 



You can see an example of such configuration in my blog posts named:

PHP calling .NET – PHP to WCF communication

and

PHP calling .NET – PHP to WCF calls with parameters

Tip: Visual Studio 2008 fails to debug WCF web service

When trying to debug a WCF ( windows communication foundation) .NET 3.5 framework library, you might encounter a problem where Visual Studio (VS 2008) refuses to run or debug the WCF web service.

 

the problem:

The error you get from the WCF test client when trying to debug the WCF service is this – "WCF Test Client: Unrecognized option ‘targetclientversion’ specified"

wcf fail

The solution:

1) Close Visual Studio

2) Install the latest version of Windows SDK for Windows Server 2008 and .NET Framework 3.5

3)  open Visual Studio again

 

This solved the problem for me.

I love my MVC …

If this was a comics style blog it would start like this:

They both stood there, the clean and virtues super-hero MVC and his arch-enemy the dirty and corrupt spaghetti-design-pattern… they were both aware that only one of them will prevail.

The fact is that real life is more complicated than that, writing code is an on-going process and sometimes you need to “get things done now” instead of “get things done right”. The important thing is to keep in mind the important notions  that lays behind MVC.

So who is this super-hero? From Wikipedia: Model-View-Controller (MVC) is a design pattern used in software engineering. In complex computer applications that present lots of data to the user, one often wishes to separate data (Model) and user interface (View) concerns, so that changes to the user interface do not impact the data handling, and that the data can be reorganized without changing the user interface. The Model-View-Controller design pattern solves this problem by decoupling data access and business logic from data presentation and user interaction, by introducing an intermediate component- the Controller.

While MVC might take a little more time to design, the notion of decoupling presentation, logic and data layers is imperative. Code that has been written this way can easily be changed without enforcing changes on other layers of code. Because it is a well known fact of life that things always change, agile code makes our life easier and simpler. It is also usually makes the code more comprehensible.

On the other hand you have spaghetti code, it is takes no planning at all but changing it is a nightmare. Moreover, spaghetti code is incomprehensible and as the saying goes: “Always write your code as if the person who will maintain it is a violent psychotic who knows where you live.”

So keep your layers decoupled and live longer and happier.

BTW: if you don’t know which song was playing while I wrote this blog see the title or click here.