Technologies

ALM Area

Technology

Version

Source

Pros

Cons

Decision

Hosting platform

Windows Server

2016

https://www.microsoft.com/en-us/cloud-platform/windows-server

  

  

  

  

Ubuntu

18.04 LTS

https://www.ubuntu.com/server

  

  

  

Hosting model

Azure

  

http://azure.microsoft.com/en-us/

  

  

  

  

DigitalOcean

  

https://www.digitalocean.com/

  

  

  

  

Private DG’s box

  

  

  

  

  

Database

SQL Server

2016

https://www.microsoft.com/en-us/sql-server

  

  

  

  

MySQL

  

https://www.mysql.com/

  

  

  

Source control

GitHub

  

https://github.com/

  

  

  

  

Bitbucket

  

https://bitbucket.org/

  

  

  

Code publisher

Teamcity

2017.1

http://www.jetbrains.com/TeamCity

  

  

  

  

Jenkins

  

https://jenkins.io/

  

  

  

Client technologies

AngularJS

1.6.4

https://angularjs.org/

  

  

  

  

Angular

4

https://angular.io/

  

  

  

  

AngularDart

3.1.0

https://webdev.dartlang.org/angular/

  

  

  

  

Angular Material

  

https://material.angular.io/

  

  

  

Client template

Leadpages

  

http://www.leadpages.net

  

  

  

Primary development platform

.NET Framework

4.7

https://docs.microsoft.com/en-us/dotnet/framework/whats-new/index#v47

  

  

  

  

.NET Core

2

https://www.microsoft.com/net/core/platform

  

  

  

  

.NET Standard

2

https://docs.microsoft.com/en-us/dotnet/standard/net-standard

  

  

  

Secondary development platform

Xamarin

  

https://www.xamarin.com/

  

  

  

  

Cordova

  

https://cordova.apache.org/

  

  

  

 

Enterprise Architecture

To maximize organizational software throughput, an overall architecture must be contemplated and subsequent plans & periodic reviews put in place.  It’s a process whose primary objectives must include

Continuous improvement to quantify & minimize long term operating cost

Organizations consist of sets of processes.  A currently popular architectural pattern, MVC, scales reasonably well to enterprise level for encapsulating processes.  Any software environment has three main tiered components:

Model Controller View
Security Security Security
Repository

  • Source of Truth (SOT)
  • Archive
  • Warehouse
Rules On Demand
ORM Workflow Usability

EnterpriseArchitectureSecurity is a rare subcomponent where redundancy is not only accepted, it’s recommended.

Model – this tier has three subcomponents: Security, Repository & ORM.  The Repository is the core raw material of an organization’s knowledgebase.  Acute attention must be paid here because other components rely on it and inefficiencies at this level will have multiplicative effects on higher tiered components.

Repository maybe divided into three subcategories:

  • SOT
  • Archive
  • Warehouse

Currently acceptable and predominantly used mechanism for hosting SOT is to use relational database.  Main objective here is to minimize data element redundancy.  Relational database platforms offer a hierarchical process called normalization, based on well established mathematical model, whose usage guarantees reduction in data element duplication proportional to implementation depth, e.g., 2NF guarantees less redundancy than 1NF.  It’s important to note that higher degree of normalization adds more structural complexity, which may in turn raise operating cost of this and subsequent tiers higher up by lowering performance and maintainability, thus a balance must be achieved.  Subject to given environment, implementation to 3NF is widely accepted as a rule of thumb.

Archive is a repository subcomponent necessary to keep SOT agile & tuned.  It hosts dated transactional material, which frees SOT to deal with static & chronologically relevant data.  It structurally parallels SOT’s transactional entities.  Various mechanisms exist to move data from SOT to Archive, such as scheduled SSIS package, etc.

Warehouse has a different objective, to de-normalize a set of data elements for consumer expediency, e.g., reporting, etc. and thus it must adhere to a couple of basic rules, data elements within this category must

  • Solely rely on data elements within SOT as its data source
  • Be non-transactional, e.g., read only

Log tracks sources of accessed data.  It maybe as simple as a single entity written to by various data access triggers within other entities.  Regardless of implementation, any Log record must be traceable back to specific entity along with timestamp & uniquely identifiable source.  Logging mechanism is crucial for SOT but may also be implemented for Archive and/or Warehouse.

ORM is the objectified map of relational entities.  It’s main objectives include seamless integration between data and code.  Modern software applications often rely heavily on ORM for Rapid Application Development (RAD).  An enterprise-wide ORM library would reduce duplication of efforts per application, but, it must be manually kept in sync with data repository and breaking changes would require adjustments to consumer components higher up the chain.  Frequent changes to this layer points to either dynamic nature of the underlying business model or a lack of thorough understanding of it.  Test Driven Development (TDD) approach would help changes in this layer avoid unintentionally breaking consumer applications.

There are a handful of reasonable security implementation options within the Model tier.  One established option in windows environment is to funnel various levels of CRUD access via business process task specific windows AD groups, with sets of users as its members.  In such implementation, new users need to be granted task specific access via their AD group membership while deactivating a user in AD automatically revokes their privileges.

Since changes in the Model tier has broad impact, it should be designed carefully from the start, involving specialists in data modeling to ensure well normalized SOT as well as relevant business model experts to ensure that entity model closely represents business model, so that technical changes are only necessary to accommodate business model changes, which is unavoidable regardless of implementation.

Controller – main objective of this component is to host & enforce rules and facilitate workflow & navigation.  A controller library may encapsulate one or more Business Process Tasks and by it’s nature must be specific to one or more business processes.  There are, however, ways to minimize code redundancy, for example, a base controller library might encapsulate workflow and rules engines, while business process specific controllers may use it to perform relevant tasks.  Controller libraries may also be shared between different platforms, targeting a website & a smart phone application, for example.  Important thing to note here is to have controllers emulate business processes and not bind too close a target platform.

Since controllers operate within an application’s context, security is often delegated to application host for authentication & authorization, but, security implementation at this tier is possible via Code Access Security (CAS), Filters, etc.

View – main objective of views are to provide visible access to data sets and ways to interact with it.  It’s important to keep this tier as thin as possible, so that, targeting a new platform for an existing process could be as simple as creating a new view for the target platform.

Security at this tier is largely a matter of direct access, e.g., via installation, etc.

Developing Business Strategy

Tags

, , ,

Strategy is the bridge between an idea and it’s implementation, whereby, the effectiveness of the strategy maybe directly responsible for the quality of success.   Easy-Strategy.com has published a nice article, some of which I’ll reference here for emphasis.  The word “strategy” derives from the Greek word stratçgos; which derives from two words

  • stratos – army
  • ago – leading/guiding/moving

Merriam-Webster defines strategy as “The science and art of employing the political, economic, psychological, and military forces of a nation or group of nations to afford the maximum support to adopted policies in peace or war”.   Although, the idea behind strategy is to devise mechanisms (battle plans) by which a given set of objectives may be attained, let’s slightly generalize this definition and remove the military aspect, so we can analyze the concept without the distraction of implementation specifics.  So, our modified definition then is:

The science and art of employing the political, economic, psychological, and available task forces to achieve said objective

If we are to assume the definition above sufficiently captures the concept of strategy, we can then break it down to its elements and produce a generic strategy development model.  Here’s an elaboration of the keywords within the context of developing strategy:

  • Science – mathematical models
  • Art – experience and intuition
  • Political – governing body
  • Economic – product/service life cycle
  • Psychological – perception and related behavior
  • Task force – resources tasked with various aspects of identification, analysis, development & implementation
  • Objective – desired outcome

Strategy could then be described as a road map which begins with objective, uses science and art to draw a mission pathway to psychologically influence the economics within the bounds of political conditions and uses appropriate task forces to carry out various aspects of such mission.  A strategy has a starting point, an end point, and a set of moving components between them, it could thus be loosely compared to control systems.  However, missing in this basic definition is a feedback loop, which is a key component in control systems and are used to measure success and adjust course as appropriate.  Since a business strategy is ultimately tied to the bottom line, it must integrate a feedback loop to measure its effectiveness and adjust course as appropriate to achieve objective.

If we model the strategy development process after a generic solution development process, we can generate a high level task list:

  1. Identify – current state with readily available information
    • Stated business objectives, relevant to the target strategy
    • Business case
    • Constants & variables
    • Success criteria
  2. Analyze – current state and trends of stakeholders
    • Organization
    • Environment
    • Employees
    • Customers
    • Competitors
    • Governing bodies
  3. Develop
    • Strategy elements
    • Implementation & governance tasks
  4. Test developed elements
  5. Implement strategy elements
  6. Monitor
    • Success based on predefined criteria
    • Dynamic elements

We’ll next use this formula to develop an instance of a strategy, Raise Market Share

Problem Solving – The Science & The Art

Tags

, , , ,

There are only a handful of generic components associated with solving problems: identify, analyze, develop, & implement along with some optional feedback loop, e.g., test & monitor.

Figure 1: 6 Step Problem Resolution Process Flow

Each of these components is merely a coherent set of tasks.  Let’s analyze these components in more detail:

Identify – the main objective of this process is data collection.   Whatever the problem, it can only exist within a certain context, the root context.  Identifying this context with reasonable accuracy is important, it also defines the problem scope which in turn scopes the identification process and tasks.

Figure 2: Problem Identification Process

If aspects of a problem falls outside an identified root context, then the context must be expanded.  If the scope of the context is too broad, it neutralizes the benefits of the scope.  It’s also important to collect just the data and not associate any meaning to it so as to not skew the next process, the analysis.   ManagementHelp has published a comprehensive article on the subject of problem identification.

Analyze – the main objective of this process is to determine the why and generate resolution options including none, e.g., the option to not resolve.  Consider including resolution options that would resolve not just the problem but the class of problems, which is generally likely to be more expensive in the near term

Figure 3: Problem Analysis Process

but less expensive overall.  Specific tasks will depend on the root context, figure 3 samples a few common ones along with some permanent tasks (darker background).  It’s important that this process is accomplished with no knowledge of the developmental process, to avoid biasing the analysis.

Develop – the objective of this process is to build all the necessary parts of the solution selected in analysis, so as to enable the solution to be implemented.  Specific analysis aspects may need to be revisited and/or scope adjusted, during the build process

Figure 4: Solution Development Process

Note that a monitoring mechanism should also be built at this stage, so that the results of the solution may be meaningfully tracked.

Implement – the objective of this process is to deploy the built solution and the monitoring mechanism.

Figure 5: solution implementation process

Also important at this stage is to schedule periodic review and analysis of reports generated from monitor.

WCF Web API

The API targets the REST starter kit but is more broadly scoped, both on the client and on the server.  It enhances WCF offering but is not intended as a replacement of it.  Figure 1 depicts high level architecture of the concept, note that it still follows core WCF service model.

image

Figure 1 – Web API architecture

With Web API, REST has come ways to within striking distance of becoming a first class service model within the WCF platform.  It’s a set of libraries that enhance WCF’s REST offering, which may be downloaded directly at CodePlex or via NuGet (recommended).

To install the Web API package:

  1. Download and install NuGet
  2. Create new or open existing Visual Studio application
  3. Reference Web API package

image 

Figure 2 – NuGet context menu for project references

image

Figure 3 – NuGet reference management dialog

When a package is installed (e.g., referenced via NuGet) the following steps occur:

  1. A subfolder named packages is created at the solution root
  2. Libraries, with dependencies, are placed underneath it
  3. Project references, to the libraries in step 2, are made
  4. A configuration file, packages.config, is added to the project, identifying installed components

image

Figure 4 – WebApi.All component model

WebApi.All installs 4 components.  Full list of (Preview 4) components, libraries, namespaces, & classes are listed below:

  • HttpClient
    • Microsoft.Net.Http
      • System.Net.Http
        • ByteArrayContent
        • DelegatingChannel
        • FormUrlEncodedContent
        • HttpClient
        • HttpClientChannel
        • HttpCompletionOption
        • HttpContent
        • HttpException
        • HttpMessageChannel
        • HttpMethod
        • HttpRequestMessage
        • HttpResponseMessage
        • MessageProcessingChannel
        • MultipartContent
        • MultipartFormDataContent
        • StreamContent
        • StringContent
        • WebRequestChannel
      • System.Net.Http.Headers
        • AuthenticationHeaderValue
        • CacheControlHeaderValue
        • ContentRangeHeaderValue
        • EntityTagHeaderValue
        • HttpContentHeaders
        • HttpHeaders
        • HttpRequestHeaders
        • HttpResponseHeaders
        • MediaTypeHeaderValue
        • MediaTypeWithQualityHeaderValue
        • NameValueHeaderValue
        • NameValueWithParametersHeaderValue
        • ProductHeaderValue
        • ProductInfoHeaderValue
        • RangeConditionHeaderValue
        • RangeHeaderValue
        • RangeItemHeaderValue
        • RetryConditionHeaderValue
        • StringWithQualityHeaderValue
        • TransferCodingHeaderValue
        • TransferCodingWithQualityHeaderValue
        • ViaHeaderValue
        • WarningHeaderValue
  • JasonValue
    • Microsoft.Runtime.Serialization.Json
      • System.Json
        • JsonArray
        • JsonObject
        • JsonObjectValidation
        • JsonPrimitive
        • JsonType
        • JsonValue
        • JsonValueChange
        • JsonValueChangeEventArgs
        • JsonValueLinqExtensions
      • System.Runtime.Serialization.Json
        • JsonValueExtensions
    • Microsoft.ServiceModel.Web.jQuery
      • Microsoft.ServiceModel.Activation
        • WebServiceHostFactory3
      • Microsoft.ServiceModel.Configuration
        • WebHttpElement3
      • Microsoft.ServiceModel.Web
        • FormUrlEncodedExtensions
        • WebHttpBehavior3
        • WebServiceHost3

  • WebApi.Core (installs dependencies: HttpClient & JsonValue)
    • Microsoft.ApplicationServer.Common
      • Microsoft.ApplicationServer.Common
        • ChainedBeginHandler : MulticastDelegate
        • ChainedEndHandler : MulticastDelegate
      • Microsoft.ApplicationServer.Common.Notification
        • INotificationService
        • NotificationEvent
        • NotificationReceiver
        • NotificationSender
    • Microsoft.ApplicationServer.Http
      • Microsoft.ApplicationServer.Http
        • FormUrlEncodedMediaTypeFormatter
        • HttpBinding
        • HttpBindingSecurity
        • HttpBindingSecurityMode
        • HttpContentExtensionMethods
        • HttpRequestMessage<T>
        • HttpResponseMessage<T>
        • HttpServiceHost
        • IQueryComposer
        • JsonMediaTypeFormatter
        • JsonValueMediaTypeFormatter
        • MediaRangeMapping
        • MediaTypeFormatter
        • MediaTypeFormatterCollection
        • MediaTypeFormatterExtensionMethods
        • MediaTypeMapping
        • ObjectContent
        • ObjectContent<T>
        • QueryCompositionAttribute
        • QueryCompositionMessageProperty
        • QueryStringMapping
        • TrailingSlashMode
        • UriPathExtensionMapping
        • UrlQueryComposer
        • XmlMediaTypeFormatter
      • Microsoft.ApplicationServer.Http.Activation
        • HttpServiceHostFactory
      • Microsoft.ApplicationServer.Http.Channels
        • HttpMessageEncodingBindingElement
        • HttpMessageExtensionMethods
        • HttpMessageHandlerBindingElement
        • HttpMessageHandlerFactory
      • Microsoft.ApplicationServer.Http.Configuration
        • HttpBehaviorElement
        • HttpBindingCollectionElement
        • HttpBindingElement
        • HttpBindingSecurityElement
        • HttpEndpointCollectionElement
        • HttpEndpointElement
      • Microsoft.ApplicationServer.Http.Description
        • HttpBehavior
        • HttpEndpoint
        • HttpOperationDescription
        • HttpOperationDescriptionExtensionMethods
        • HttpOperationHandlerFactory
        • HttpParameter
        • HttpParameterExtensionMethods
      • Microsoft.ApplicationServer.Http.Dispatcher
        • HttpErrorHandler
        • HttpInstanceProvider
        • HttpMessageFormatter
        • HttpMessageInspector
        • HttpOperationHandler
        • HttpOperationHandler<T,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,T9,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,T8,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,T7,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,T6,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,T5,TOutput>
        • HttpOperationHandler<T1,T2,T3,T4,TOutput>
        • HttpOperationHandler<T1,T2,T3,TOutput>
        • HttpOperationHandler<T1,T2,TOutput>
        • HttpOperationSelector
        • HttpResponseException
        • RequestContentHandler
        • ResponseContentHandler
        • UriAndMethodOperationSelector
        • UriTemplateHandler
    • Microsoft.ApplicationServer.Serialization
      • Microsoft.ApplicationServer.Serialization
        • IDataContractSurrogate
      • Microsoft.ApplicationServer.Serialization.Configuration
        • TypeElementExtensionMethods
    • Microsoft.ApplicationServer.ServiceModel
      • Microsoft.ApplicationServer.ServiceModel.Configuration
        • ServiceModelConfigurationElement
        • ServiceModelConfigurationElementCollection<ConfigurationElementType>
        • ServiceModelEnhancedConfigurationElementCollection<TConfigurationElement>
    • Microsoft.QueryComposition
      • Microsoft.QueryComposition.Client
        • ALinqExpressionVisitor
        • CountOption
        • DataServiceALinqExpressionVisitor
        • Evaluator
        • ExpressionNormalizer
        • InputReferenceExpression
        • ProjectionQueryOptionExpression
        • QueryOptionExpression
        • ReferenceEqualityComparer
        • ReferenceEqualityComparer<T>
        • ResourceBinder
        • ResourceExpression
        • ResourceSetExpression
        • UriWriter
      • Microsoft.QueryComposition.Server
        • DataServiceProviderMethods
        • OpenTypeMethods
        • QueryTranslator
    • WebApi.Enhancements (installs dependencies: Core)
    • Microsoft.ApplicationServer.HttpEnhancements
      • Microsoft.ApplicationServer.Http
        • HtmlForamtter
        • PlainTextFormatter
      • Microsoft.ApplicationServer.Http.Activation
        • HttpConfigurableServiceHost
        • HttpConfigurableServiceHost<TService>
        • HttpConfigurableServiceHostFactory
        • IConfigurableServiceHostFactory
        • RouteCollectionExtensions
      • Microsoft.ApplicationServer.Http.Description
        • HttpBehaviorWithErrorHandler
        • HttpErrorHandlerBehavior
        • HttpHostConfiguration
        • IContractConfiguration
        • IEndpointConfiguration
        • IEndpointFactory
        • IHttpHostConfigurationBuilder
        • InstanceProviderBehavior
        • IOperationConfiguration
        • IResourceFactory
        • IServiceConfiguration
        • ResourceFactoryProvider

To develop a Web API MVC service (source):

  1. Create empty MVC 3 app
  2. Reference WebApi
  3. Add DTO (POCO Data Transfer Object)
  4. Add & register service contract
  5. Add service operation
  6. Expose operation over http
  7. Consume operation (verification)

Hosting WCF Services

Hosting Options

There are two main options to hosting WCF services:
  • Self host – explicitly controlled lifetime, e.g., hosted within an executable
  • Long running host – “implicitly” controlled lifetime, e.g., IIS, WAS, Windows Service, etc., although lifetime must be explicitly controlled within windows services other than WAS

How To Host WCF Services

There are four basic steps to hosting a WCF service within a .Net environment:
  1. Create a host project, e.g., website, web app, console app, etc.
  2. Reference relevant libraries, e.g., ServiceModel and appropriate service libraries and dependencies
  3. Configure EndPoints to accept requests, unless factories are used
  4. Appropriately instantiate a ServiceHost object or a subclass

The Object Model

Hosts are supported by the framework by a set of classes primarily from the System.ServiceModel namespace.

Figure 1 – partial WCF 4 runtime object model

System.ServiceModel.ServiceHost – default host


Hosts and exposes services and allows interaction with them.

Figure 2 – ServiceHost class

ServiceHost() – Initializes a new instance of the ServiceHost class.
ServiceHost(Object, Uri[]) – Initializes a new instance of the ServiceHost class with the instance of the service and its base addresses specified.
ServiceHost(Type, Uri[]) – Initializes a new instance of the ServiceHost class with the type of service and its base addresses specified.
 
SingletonInstance – Gets the singleton instance of the hosted service.

 
AddServiceEndpoint(Type, Binding, String) – Adds a service endpoint to the hosted service with a specified contract, binding, and endpoint address.
AddServiceEndpoint(Type, Binding, Uri) – Adds a service endpoint to the hosted service with a specified contract, binding, and URI that contains the endpoint address.
AddServiceEndpoint(Type, Binding, String, Uri) – Adds a service endpoint to the hosted service with a specified contract, binding, an endpoint address, and a URI on which the service listens.
AddServiceEndpoint(Type, Binding, Uri, Uri) – Adds a service endpoint to the hosted service with a specified contract, binding, a URI that contains the endpoint address, and a URI on which the service listens.
CreateDescription – Creates a description of the service hosted. (Overrides ServiceHostBase.CreateDescription(IDictionary<String, ContractDescription>).)
InitializeDescription(Object, UriSchemeKeyedCollection) – Initializes a description of the service hosted based on its instance and specified base addresses.
InitializeDescription(Type, UriSchemeKeyedCollection) – Initializes a description of the service hosted based on its type and specified base addresses.

System.ServiceModel.ServiceHostBase – abstract base


Provides base object for the default and custom hosts

Figure 3 – ServiceHostBase class

ServiceHostBase – Initializes a new instance of the ServiceHostBase class.
 
BaseAddresses – Gets the base addresses used by the hosted service.
CloseTimeout – Gets or sets the interval of time allowed for the service host to close.
DefaultCloseTimeout – Gets the default interval of time allowed for the service host to close. (Overrides CommunicationObject.DefaultCloseTimeout.)
DefaultOpenTimeout – Gets the default interval of time allowed for the service host to open. (Overrides CommunicationObject.DefaultOpenTimeout.)
ManualFlowControlLimit – Gets or sets the flow control limit for messages received by the service hosted.
OpenTimeout – Gets or sets the interval of time allowed for the service host to open.
 
 AddBaseAddress – Adds a base address to the service host.
AddDefaultEndpoints – Adds service endpoints for all base addresses in each contract found in the service host with the default binding.
AddServiceEndpoint(ServiceEndpoint) – Adds the specified service endpoint to the hosted service.
AddServiceEndpoint(String, Binding, String) – Adds a service endpoint to the hosted service with a specified contract, binding, and endpoint address.
AddServiceEndpoint(String, Binding, Uri) – Adds a service endpoint to the hosted service with a specified contract, binding, and a URI that contains the endpoint address.
AddServiceEndpoint(String, Binding, String, Uri) – Adds a service endpoint to the hosted service with a specified contract, binding, endpoint address and URI that contains the address at which it listens.
AddServiceEndpoint(String, Binding, Uri, Uri) – Adds a service endpoint to the hosted service with the specified contract, binding, and URIs that contain the endpoint and listening addresses.
 ApplyConfiguration – Loads the service description information from the configuration file and applies it to the runtime being constructed.
 CreateDescription – When implemented in a derived class, creates the description of the hosted service.
IncrementManualFlowControlLimit – Increases the limit on the flow rate of messages to the hosted service by a specified increment.
 InitializeDescription – Creates and initializes the service host with the contract and service descriptions.
 InitializeRuntime – Initializes the runtime for the service host.
 LoadConfigurationSection – Loads the service element from the configuration file of the hosted service.
 OnAbort – Aborts the service. (Overrides CommunicationObject.OnAbort().)
 OnBeginClose – Begins an asynchronous operation invoked on the close of the service host. (Overrides CommunicationObject.OnBeginClose(TimeSpan, AsyncCallback, Object).)
 OnBeginOpen – Begins an asynchronous operation invoked on the opening of the service host. (OverridesCommunicationObject.OnBeginOpen(TimeSpan, AsyncCallback, Object).)
 OnClose – Closes down the hosted service, including their channel dispatchers and associated instance contexts and listeners. (OverridesCommunicationObject.OnClose(TimeSpan).)
 OnClosed – Releases resources used by the service host. (Overrides CommunicationObject.OnClosed().)
 OnEndClose – Completes an asynchronous operation invoked on the closing of the service host. (OverridesCommunicationObject.OnEndClose(IAsyncResult).)
 OnEndOpen – Completes an asynchronous operation invoked on the opening of the service host. (OverridesCommunicationObject.OnEndOpen(IAsyncResult).) OnOpen – Opens the channel dispatchers. (Overrides CommunicationObject.OnOpen(TimeSpan).)
 OnOpened – Gets the service credentials,service authentication and authorization behavior for the hosted service. (OverridesCommunicationObject.OnOpened().)
 ReleasePerformanceCounters – Releases the service and channel dispatcher performance counters for the hosted service.
SetEndpointAddress – Sets the endpoint address of the specified endpoint to the specified address.


UnknownMessageReceived
– Occurs when an unknown message is received.

WCF Messaging

System.ServiceModel.MessageContractAttribute – Strongly Typed SOAP Message


 
 HasProtectionLevel – Gets a value that indicates whether the message has a protection level.
 IsWrapped – Gets or sets a value that specifies whether the message body has a wrapper element.
 ProtectionLevel – Gets or sets a value that specified whether the message must be encrypted, signed, or both.
 WrapperName – Gets or sets the name of the wrapper element of the message body.
 WrapperNamespace – Gets or sets the namespace of the message body wrapper element.

WCF Exception Handling

System.ServiceModel.FaultContractAttribute – Service Operation Interface Decorator


Specifies one or more SOAP faults that are returned when a service operation encounters processing errors.

 Action – Gets or sets the action of the SOAP fault message that is specified as part of the operation contract.
 DetailType – Gets the type of a serializable object that contains error information.
 HasProtectionLevel – Gets a value that indicates whether the SOAP fault message has a protection level assigned.
 Name – Gets or sets the name of the fault message in Web Services Description Language (WSDL).
 Namespace – Gets or sets the namespace of the SOAP fault.
 ProtectionLevel – Specifies the level of protection the SOAP fault requires from the binding.

Other references

WCF Service Object Model

The Framework

WCF provides the framework to comprehensively manage and utilize the following 6 broad aspects of service orientation and development:

  1. Service – the core of the framework and an almost independent entity
  2. Host – independent of the service and is independently scalable
  3. Client – aware of the service API only via the proxy
  4. Communication – connects clients to service hosts via channels
  5. Security – tiers of out-of-the-box protection
  6. Debugging – tools and techniques

The Service

A WCF service promotes the separation of state and behavior.  It’s important for two main reasons:

  1. Behavior encapsulation and centralization – lower TCO in terms of maintainability and reusability as well as raising the potential scalability by orders of magnitude.
  2. State portability without much fear of unintentional or other malice.

The Object Model

Services are supported by the framework by a set of classes primarily from the System.ServiceModel namespace.

Figure 1 – core service framework object model

System.ServiceModel.ServiceContractAttribute – Service Interface Decorator


CallbackContract – Gets or sets the type of callback contract when the contract is a duplex contract.  Defaults to null.
 ConfigurationName – Gets or sets the name used to locate the service in an application configuration file.  Defaults to fully qualified interface type name.
 HasProtectionLevel – Gets a value that indicates whether the member has a protection level assigned.   Defaults to false.
 Name – Gets or sets the name for the <portType> element in Web Services Description Language (WSDL).  Defaults to Managed type name.
 Namespace – Gets or sets the namespace of the <portType> element in Web Services Description Language (WSDL).  Defaults to http://tempuri.org/.
 ProtectionLevel – Specifies whether the binding for the contract must support the value of the ProtectionLevel property.  Defaults to None.
 SessionMode – Gets or sets whether sessions are allowed, not allowed or required.  Defaults to Allowed.

System.ServiceModel.ServiceBehaviorAttribute – Service Implementation Decorator


 AddressFilterMode – Gets or sets the AddressFilterMode that is used by the dispatcher to route incoming messages to the correct endpoint.  Defaults to Exact.
    • Available options
      1. Any – Indicates a filter that matches on any address of an incoming message.  Using this value turns off the address filter check. Any message, no matter what its WS-Adressing:To identity is accepted
      2. Exact – Indicates a filter that does an exact match on the address of an incoming message
      3. Prefix – Indicates a filter does the longest prefix matches on the address of an incoming message
    • AddressFilterMode.Prefix
    • Understanding Address Filtering
    • WCF Addressing In Depth
 AutomaticSessionShutdown – Specifies whether to automatically close a session when a client closes an output session.  Defaults to true.
 ConcurrencyMode – Gets or sets whether a service supports one thread, multiple threads, or reentrant calls.  Defaults to Single.
    • Available options
      1. Single – The service instance is single-threaded and does not accept reentrant calls. If the InstanceContextMode property is Single, and additional messages arrive while the instance services a call, these messages must wait until the service is available or until the messages time out.
      2. Reentrant – The service instance is single-threaded and accepts reentrant calls. The reentrant service accepts calls when you call another service; it is therefore your responsibility to leave your object state consistent before callouts and you must confirm that operation-local data is valid after callouts. Note that the service instance is unlocked only by calling another service over a channel. In this case, the called service can reenter the first service via a callback. If the first service is not reentrant, the sequence of calls results in a deadlock. For details, see ConcurrencyMode.
      3. Multiple – The service instance is multi-threaded. No synchronization guarantees are made. Because other threads can change your service object at any time, you must handle synchronization and state consistency at all times.
 ConfigurationName – Gets or sets the value used to locate the service element in an application configuration file.  Defaults to fully qualified implementation type name.
 IgnoreExtensionDataObject – Gets or sets a value that specifies whether to send unknown serialization data onto the wire.  Defaults to false.
 IncludeExceptionDetailInFaults – Gets or sets a value that specifies that general unhandled execution exceptions are to be converted into a System.ServiceModel.FaultException<TDetail> of type System.ServiceModel.ExceptionDetail and sent as a fault message. Set this to true only during development to troubleshoot a service.  Defaults to false.
 InstanceContextMode – Gets or sets the value that indicates when new service objects are created.  Defaults to PerSession.
    • Available options
      1. PerSession – A new InstanceContext object is created for each session.
      2. PerCall – A new InstanceContext object is created prior to and recycled subsequent to each call. If the channel does not create a session this value behaves as if it were PerCall.
      3. Single – Only one InstanceContext object is used for all incoming calls and is not recycled subsequent to the calls. If a service object does not exist, one is created.  For singleton lifetime behavior (for example, if the host application calls the ServiceHost constructor and passes an object to use as the service), the service class must set InstanceContextMode to InstanceContextMode.Single, or an exception is thrown when the service host is opened.
 MaxItemsInObjectGraph – Gets or sets the maximum number of items allowed in a serialized object.  Defaults to 64KB.
 Name – Gets or sets the value of the name attribute in the service element in Web Services Description Language (WSDL).  Defaults to service implementation class name.
 Namespace – Gets or sets the value of the target namespace for the service in Web Services Description Language (WSDL).  Defaults to http://tempuri.org/.
 ReleaseServiceInstanceOnTransactionComplete – Gets or sets a value that specifies whether the service object is released when the current transaction completes.  Defaults to true.
 TransactionAutoCompleteOnSessionClose – Gets or sets a value that specifies whether pending transactions are completed when the current session closes without error.  Defaults to false.
 TransactionIsolationLevel – Specifies the transaction isolation level for new transactions created inside the service, and incoming transactions flowed from a client.  Defaults to Unspecified.
    • Available options
      1. Serializable – Volatile data can be read but not modified, and no new data can be added during the transaction.
      2. RepeatableRead – Volatile data can be read but not modified during the transaction. New data can be added during the transaction.
      3. ReadCommitted – Volatile data cannot be read during the transaction, but can be modified.
      4. ReadUncommitted – Volatile data can be read and modified during the transaction.
      5. Snapshot – Volatile data can be read. Before a transaction modifies data, it verifies if another transaction has changed the data after it was initially read. If the data has been updated, an error is raised. This allows a transaction to get to the previously committed value of the data.  When you try to promote a transaction that was created with this isolation level, an InvalidOperationException is thrown with the error message "Transactions with IsolationLevel Snapshot cannot be promoted".
      6. Chaos – The pending changes from more highly isolated transactions cannot be overwritten.
      7. Unspecified – A different isolation level than the one specified is being used, but the level cannot be determined. An exception is thrown if this value is set.
 TransactionTimeout – Gets or sets the period within which a transaction must complete.  Defaults to 0.
 UseSynchronizationContext – Gets or sets a value that specifies whether to use the current synchronization context to choose the thread of execution.  Defaults to true.
 ValidateMustUnderstand – Gets or sets a value that specifies whether the system or the application enforces SOAP MustUnderstand header processing.  Defaults to true.

 GetWellKnownSingleton – Retrieves an object that implements the service and that is used as the singleton instance of the service, or null if there is no singleton instance.
 SetWellKnownSingleton – Specifies an object that implements the service and that is used as the singleton instance of the service.
 ShouldSerializeConfigurationName – Returns a value that indicates whether the ConfigurationName property has changed from its default value and should be serialized.
 ShouldSerializeReleaseServiceInstanceOnTransactionComplete – Returns a value that indicates whether the ReleaseServiceInstanceOnTransactionComplete property has changed from its default value and should be serialized.
 ShouldSerializeTransactionAutoCompleteOnSessionClose – Returns a value that indicates whether the TransactionAutoCompleteOnSessionClose property has changed from its default value and should be serialized.
 ShouldSerializeTransactionIsolationLevel – Returns a value that indicates whether the TransactionIsolationLevel property has changed from its default value and should be serialized.
 ShouldSerializeTransactionTimeout – Returns a value that indicates whether the TransactionTimeout property has changed from its default value and should be serialized.

 

System.ServiceModel.OperationContractAttribute – Service Operation Interface Decorator


 Action – Gets or sets the WS-Addressing action of the request message.
 AsyncPattern – Indicates that an operation is implemented asynchronously using a Begin<methodName> and End<methodName> method pair in a service contract.
 HasProtectionLevel – Gets a value that indicates whether the messages for this operation must be encrypted, signed, or both.
 IsInitiating – Gets or sets a value that indicates whether the method implements an operation that can initiate a session on the server (if such a session exists).
 IsOneWay – Gets or sets a value that indicates whether an operation returns a reply message.
 IsTerminating – Gets or sets a value that indicates whether the service operation causes the server to close the session after the reply message, if any, is sent.
 Name – Gets or sets the name of the operation.
 ProtectionLevel – Gets or sets a value that specifies whether the messages of an operation must be encrypted, signed, or both.
 ReplyAction – Gets or sets the value of the SOAP action for the reply message of the operation.

 

System.ServiceModel.OperationBehaviorAttribute – Service Operation Implementation Decorator


 AutoDisposeParameters – Gets or sets whether parameters are to be automatically disposed.  Defaults to true.
 Impersonation – Gets or sets a value that indicates the level of caller impersonation that the operation supports.  Defaults to NotAllowed.
 ReleaseInstanceMode – Gets or sets a value that indicates when in the course of an operation invocation to recycle the service object.  Defaults to None.
 TransactionAutoComplete – Gets or sets a value that indicates whether to automatically complete the current transaction scope if no unhandled exceptions occur.  Defaults to true.
 TransactionScopeRequired – Gets or sets a value that indicates whether the method requires a transaction scope for its execution.  Defaults to false.

 

System.Runtime.Serialization.DataContractAttribute – Service Payload Decorator


 IsReference – Gets or sets a value that indicates whether to preserve object reference data.  Defaults to false.
 Name – Gets or sets the name of the data contract for the type.  Defaults to class name.
 Namespace – Gets or sets the namespace for the data contract for the type.  Defaults to class namespace.

 

System.Runtime.Serialization.DataMemberAttribute – Service Payload Member Decorator


  • Members must be both readable and writable otherwise System.Runtime.Serialization.InvalidDataContractException is raised.
 EmitDefaultValue – Gets or sets a value that specifies whether to serialize the default value for a field or property being serialized.  Defaults to true.
 IsRequired – Gets or sets a value that instructs the serialization engine that the member must be present when reading or deserializing.  Defaults to false. 
 Name – Gets or sets a data member name.  Default is the actual member name.
    • Separates CLR member name from externally exposed contract member name, which bear security and versioning benefits.
    • Allows member names, otherwise not allowed in CLR
 Order – Gets or sets the order of serialization and deserialization of a member.

Other references:

Professional WCF Programming

Legacy Migration – to .Net and Beyond

Unlike some of the legacy platforms, the .Net platform is a more thought out and strategically planned development platform, incorporating lessons learned and avoiding mistakes of earlier platforms.  It’s similar in concept to the Java platform in that both platforms rely on a virtual machines to accept intermediate language code compiled from diverse 3GL languages and to provide final execution environment.  Target of our analysis here is the .Net platform, so, let’s focus on some key areas that a migrating development team should carefully consider.

Follow migration objectives

Corporate objectives behind a migration should be explicitly identified and prioritized, because this will drive target platform choice, architecture and design decisions and mitigate among conflicting directives.  Some examples of general objectives are:

  • Extend application life – an older platform application may become progressively isolated and unsupported, yet still have business value to the organization, thus prompting migration rather than obsolescence
  • Reduce application TCO – enhancing and/or supporting an existing application written on an older platform may become progressively more expensive and eventually lead to a tipping point whereby leading to the decision to migrate.  This may occur for individual applications or a development environment as a whole encompassing a broader initiative
  • Remain competitive – aside from lowering TCO of application space, technology driven solutions have the potential to help business processes be more efficient at execution

Fundamental .Net concepts

Some of the building blocks of the .Net framework may be unfamiliar to development teams experienced in other platforms.  A solid understanding of some of these key concepts is crucial before majority of the .Net development begins, otherwise another beginning could also simultaneously occur, the maintenance and support nightmare especially pertaining to memory leaks and sluggish performance.  The single most fundamental concept of the .Net platform is the Common Language Runtime (CLR).  It is the virtual machine, mentioned earlier, that forms the core of the platform.  Some other key concepts are:

  • Full object orientation – everything in .Net inherits from object, some explicitly and others implicitly.  Only single inheritance is supported whereby a type may inherit from only one type but may implement multiple interfaces, which may be used to implement polymorphism.  An abstract type may be used to implement the most basic form of abstractionEncapsulation is supported in 5 access modifier scopes: public, protected internal/friend, internal/friend, protected, and private
  • Supported types – there are two high level types: value type and reference type.  Value types form the basis of primitives, such as Integer, Boolean, etc., which give the platform a substantial performance boost that lacked in older platforms like SmallTalk.  Value types are dynamically boxed/unboxed to support implicit inheritance from object
  • Garbage collection – out of scope object instances are garbage collected, eliminating the need to explicitly reset them, unless they implement the IDisposable interface, which identifies an object to be or aggregate unmanaged resource(s), e.g., non-CLR type(s) and that it must be explicitly disposed before it may be garbage collected.  Microsoft recommends a design pattern to cleanup disposable objects
  • Multiple concurrent language support – a .Net solution may contain multiple projects, each in it’s supported language of choice, e.g., one project may be in VB.NET while another in C# and yet another in F#
  • COM support – .Net supports a two way COM interoperability framework called the COM Interop.  Any .Net library may consume or be exposed to COM objects via the COM Interop framework.  Consumption is automatically handled by the IDE, which dynamically creates interoperability wrappers at the time of referencing, while exposure must be explicitly configured to avoid unintentional performance lags.  Keep in mind that COM Interop is very expensive and should be avoided when possible
  • Delegates – these are thread safe function pointers, e.g., c-style pointers with a strongly typed signature.  The .Net event model along with countless other framework aspects have delegates at the core
  • Generics – it’s the support for the use of templated types.  A generic server may declares one or more generic type(s) in the type/method declarations and use them as correspondingly scoped type instance and/or parameters

Migration steps

Easiest and the quickest solution may be to run the migration wizard and manually resolve any resulting errors and call it a migrated application.  However, that’s also potentially the most expensive approach, mainly because coding intentions are not accounted for and what may be a widely accepted good practice in one platform may be blasphemy in the other.  Depending on the specifics of the to and from application types and platforms, the entire end product may run against the grain and may raise nightmare support and maintenance scenarios until re-written.  A common migration scenario is moving from classic VB smart client application to ASP.NET web application.  Timely developer training is the high risk scenario here, because moving from a stated environment mindset to a stateless one requires a good training schedule and an elongated transient period to sync in.  Your context and exact scenario will dictate the specificity of your migration steps, but, here’s a rundown of the general steps:

  1. Prepare the source codebase – if it’s an option, it may be worthwhile to refactoring the codebase at the source and separate the model, view, and the controller tiers because it may be more expedient to do so in the source platform and because it reduces potential manual operations mainly centered around the UI (view)
    1. Label the codebase in source control
    2. Develop unit & integration test scripts, if not already available.  These scripts would likely be easily transferable to the target platform and be used to certify both the initial and the final product
    3. Execute all test scripts and archive reports in source control
    4. Refactor the codebase and move as much logic out of the UI tier and into the middle tier(s) as possible.  Note that this will have an impact on the overall application because the resultant public API will be altered and should be considered carefully for potential negative impact before refactoring
    5. Label the codebase in source control
  2. Prepare destination databases – the migrated product may or may not use the same databases as the pre-migration product.  If the databases are the same then skip this step otherwise backup the source database and restore it as the destination database, so, you have an exact snapshot replica with both data and schema
  3. Generate the destination codebase – if a wizard driven migration is applicable, e.g., same before and after application types, initiate the wizard by starting the legacy application with the appropriate .Net IDE
    1. Let the wizard drive.  If a wizard driven approach is not possible for the entire application, e.g., moving from classic VB to ASP.NET, consider migrating individual libraries one at a time using the wizard or using online language translators or manually typing, whichever is more expedient
    2. Review and resolve errors, there will generally be some conversion errors, review and resolve each as appropriate
    3. Add the project to source control
    4. Migrate all the test scripts to .Net using the migration wizard
    5. Execute all test scripts and verify expected behavior and archive reports in source control
    6. Label the codebase in source control
  4. Refactor the final product – this is likely to be the most time expensive part of the operation.  Depending on how the application was originally written, a complete rewrite may be in order
    1. Reverse engineer existing design artifacts and compare and map them to existing domain models.  Domain driven designs produce some of the lowest TCOs, as a general trend, regardless of migration
    2. Isolate different processes within the application to the extent possible with an eye on SOA, because that’s the upcoming and potentially prevalent platform, whereby, applications maybe rendered meaningless in its current sense and services interacting via discoverable interfaces (e.g., XML), regardless of their underlying platform, would form the basis of our software space
    3. Wrap service layers around the different and independently serviceable modules, if applicable

Every step of this potentially lengthy migration process, keep in mind the next migration for this very application and how it could be made more portable without sacrificing performance.