Monday, May 1, 2017

Designing Software Architecture basics



How an architecture is prepared


How does the Architecture world works or move 
[from Open Group]



Desired Architecture for today’s world



Architectural Patterns and Styles
An architectural style, sometimes called an architectural pattern, is a set of principles—a coarse grained pattern that provides an abstract framework for a family of systems. An architectural style improves partitioning and promotes design reuse by providing solutions to frequently recurring problems. You can think of architecture styles and patterns as sets of principles that shape an application.
An understanding of architectural styles provides several benefits. The most important benefit is that they provide a common language. They also provide opportunities for conversations that are technology agnostic. This facilitates a higher level of conversation that is inclusive of patterns and principles, without getting into specifics. For example, by using architecture styles, you can talk about client/server versus n-tier. Architectural styles can be organized by their key focus area. The following table lists the major areas of focus and the corresponding architectural styles.
Combining Architectural Styles
The architecture of a software system is almost never limited to a single architectural style, but is often a combination of architectural styles that make up the complete system. For example, you might have a SOA design composed of services developed using a layered architecture approach and an object-oriented architecture style.
A combination of architecture styles is also useful if you are building a public facing Web application, where you can achieve effective separation of concerns by using the layered architecture style. This will separate your presentation logic from your business logic and your data access logic. Your organization's security requirements might force you to deploy the application using either the 3-tier deployment approach, or a deployment of more than three tiers. The presentation tier may be deployed to the perimeter network, which sits between an organization's internal network and an external network. On your presentation tier, you may decide to use a separated presentation pattern (a type of layered design style), such as Model-View-Controller (MVC), for your interaction model. You might also choose a SOA architecture style, and implement message-based communication, between your Web server and application server.
If you are building a desktop application, you may have a client that sends requests to a program on the server. In this case, you might deploy the client and server using the client/server architecture style, and use the component-based architecture style to decompose the design further into independent components that expose the appropriate communication interfaces. Using the object-oriented design approach for these components will improve reuse, testability, and flexibility.
Many factors will influence the architectural styles you choose. These factors include the capacity of your organization for design and implementation; the capabilities and experience of your developers; and your infrastructure and organizational constraints. The following sections will help you to determine the appropriate styles for your applications.

Maintain Multi Session on Multiple Tabs of browser


How do you maintain multiple sessions on different tabs of browser.


Yes this is an interesting topic.

I knew it was easy if we were using cookieless session, but ours is a cookie enabled session.

I was struggling all the day and then I finally got a hint that we can use Web.config to handle above issue.

Wondering how?

 <sessionState cookieless="UseUri" regenerateExpiredSessionId="true">
  </sessionState>



ASP.Net MVC in a flash for Experienced


Request is received by Routing table which creates RouteData Object [RouteCollection] and passes it to IRouteHandler.
IRouteHandler decides which handler to be invoked to handle the request, here in this case it would be MVC Handler.
MVC Handler looks at the url and passes the controller name to IController Factory which checks the controller presence and returns Controller instance to Handler. Now the Handler invokes the execute method of the returned Controller instance and passes the request to ActionSelector.
Action Selector has two ways to handle the action
  1. ActionName selector
  2. ActionMethod selectors
Action selector resolves the Action and request is passed to IActionInvoker. By default Action selector loads all the methods of the class and based on URL it calls the action method.
IActionInvoker calls the IActionFilter’s which runs in below sequence
  1. IAuthentication filter
  2. IAuthorization filter
  3. IAction filter
  4. IException filter
  5. IResult filter
The IAction filter makes use of IModelBinder which in turn takes help of ValueProvider to resolve the action parameter value(s) and the action method gets executed and the result is passed to IViewEngine.
If Result is View or PartialView then IViewEngine loads the
  • WebForm View Engine(.aspx)
  • Razor View Engine (.cshtml)

MVC does not support method overloading for Action methods, we can achieve this by using Action Name or by using Attribute [HTTPPost/ HTTPGet]
IModelBinder does 3 tasks
  1. Resolves value
  2. Conversion
  3. Validates
It takes help of Value Provider to resolve/ get actual value.
ValueProvider
| ChildActionValueProvider
| FormValueProvider
| JSONValueProvider
| RouteDataValueProvider
| QueryStringValueProvider
| HttpFileCollectionValueProvider
|JQueryFormValueProvider
We can create Custom ValueProvider if required. Eg:- To read from Cookie we can extend ValueProvider.

To post a form we have 3 ways in MVC.
  1. Using parameter with button name in action
  2. Use hidden field set value before post
  3. Use Action attribute of the button in HTML5 which would change URL in browser.
When we add layout page to a View bootstrap gets included in the project automatically.
Partial Views are used to send partial HTML & avoid layout settings.
There are three ways in which Partial View can be included in a page.
  1. @RenderPage 
  1. is faster because it writes to Response.
  2. Does not use lookup method
  3. Is used for static content
  1. @HTML.Partial - Used with strongly typed views.
  1. @HTML.RenderPartial   - Supports both strongly typed & non-static. Best suited for Ajaxified pages.

@Section are to be used for local style/ css or something page specific, these sections are declared in layout and in Views we can use these sections to embed Style/ css/ js files.
Browsers have limitation to download 3 files at a time.
The JSONResult action returns Microsoft JSON format, this JSON cannot be used with JQuery directly. JQuery understands NewtonSoft JSON, so this has to be converted to NewtonSoft JSON.

Ajax Helpers
Four steps should be followed to use Ajax helpers
  1. Install unobtrusive javascript
  2. Use it as Ajax.ActionLink
  3. Provider the Ajax options to method
  4. Include validate.js & unobtrusive.jquery.validation.js
To get the validation work
  1. Set config setting unobtrusive & client validation to true.
  2. Apply Data annotation attribute on properties.
  3. Only use strongly typed helpers or template helpers to generate UI.
  4. Refer jquery Validate & unobtrusive js files on page
  5. ModelState to be checked before operation.
Customising Routes
We customise routes only when URL parameters must be altered.
  1. Change parameter name [id to something(PId)].
  2. Change parameter order
  3. Update no. of parameters
  4. Change URL value to controller name, a kind of mapping to avoid the end client know the controller name and action name.
We can add constraints to route which would validate the value type using Regex.

Declarative Helpers
This feature helps us to avoid creating partial view for displaying content which have less text. For eg:- If we have to display DateTime on each page we can create cshtml and keep it inside the App_Code folder which gets complied to a class and at runtime is available to Views.
Cshtml would look like
@helper HelloWorld(string message)
{
<h1>Welcome @message</h1>
<h2>@DateTime.ToString() </h2>
}

In the Views we include Declarative helpers as @<FileName>. <METHOD_NAME>

Generative AI: Paving the way for Performance-Driven Enterprise Architecture

  Generative AI is not just reshaping the technological frontier; it's rapidly becoming an essential tool in optimizing enterprise archi...