May 6, 2009

composite application guidance framework - building modular systems

Loading modules based on rules. This allows you to only load modules that are applicable for a specific role. An application might retrieve from a service the list of modules to load.

Loading modules from different locations. A Windows Presentation Foundation (WPF) application might retrieve modules from the Web, from the file system and/or from a database. A Silverlight application might load modules from different XAP files. However, most of the time, the modules come from one location; for example, there is a specific folder that contains the modules or they are in the same XAP file.

guidelines for developing a modular system:
- should be opaque to the rest of the system and initialized through a well known interface
- modules should not directly reference one another or the application that loaded them
- should use loosely coupled techniques such as shared services to communicate to each other or to the application that loaded them instead of communicating directly
- modules should not be responsible for managing dependencies. should be managed externally through dependency injection
- should not rely on static methods, which inhibits testability
- modules should support being added and removed from the system in a pluggable fashion

design a modular system:
- define module's responsibilities
- module to have distinct set of responsibilities
- each module consists of its own presentation layer, business layer and resource access layer

communication patterns between modules:
- loosely coupled events: publish and subscribe to events for communciation between modules. pattern works when the number of events required to fulfill a task is small. otherwise, overheads happen due to wait time for the event triggers.
- shared services: a class that can be accessed through a common interface. a shared assembly containing common functions such as authentication, logging, configuration is an example.
- shared resources: modules can communicate indirectly through a database or web service instead of communication directly

team development using modules:
- infrastructure team: cross module interfaces and functionality such as logging, authentication
- ui team: shell and visual components design
- operations team: managing deployment of modules

UI composition:
views from multiple modules have to be displayed at run time in specific locations within an application's UI
developer defines layout with named locations within which the views will be displayed at run time
layout can evolve independently wihtout affecting the modules that are adding views to the layout
shell of the application defines the layout at the highest level
the module that defines the view and the view being displayed doesn't have knowledge of how it be displayed in the named location

view discovery approach for composite ui design:
modules can register views against a particular location
when that location is displayed at run time, the registered view will be automatically created and displayed
modules register views with the registry
parent view queries the registry for views registered with a particular location
displays views in the named location control
after the application is loaded, the composite view is notified to handle the placement of views that are added to the registry
composiste application library defines a standard registry called RegionViewRegistry to register views for named locations

view injection approach to composite ui design:
views are programmatically added or removed from a named location by the modules that manage them
application contains a registry of named locations
module can lookup locations in the registry and programmatically inject views into it
the locations adhere to a common interface to inject views
composiste application libarary defines a standard registry called RegionManager and an interface called IRegion for view injection

--> when to use view discovery versus view injection, see the UI Composition technical concept.


May 4, 2009

way to get my silverlight application talking to the COM port on my local computer

There's no access to computer resources, but you can communicate with sockets. So it's possible to have your users install an application which listens on a port and communicates with a COM port. You can do this by opening a socket connection from your Silverlight control to a local socket which intern have the COM port access

Use a XBAP (Browser Deployed WPF) that requests some extra permissions. Would live inside the browser, but only run on Windows machines with .NET 3.0 / 3.5 installed

Write an ActiveX control that talks to the local device and expose an API. Then use JavaScript to consume this API and interact with the JavaScript code from Silverlight. This would give you a in-browser application, but your users would have to install an additional device  ActiveX component.

SL and Javascript two way connectivity sample:
http://blogs.msdn.com/salvapatuel/archive/2008/05/01/build-interaction-between-javascript-and-silverlight-2.aspx

Calling ActiveX from Javascript
http://www.coderanch.com/t/121777/HTML-JavaScript/Editing-Excel-Sheet-using-javascript

Sample code to connect SL, Javascript and ActiveX
SL Mainpage.xaml:
<UserControl x:Class="JavascriptTest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300"
             Name="Xaml1">
    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel>
        <TextBox Name="NameTxt" Width="500" Height="20"></TextBox>
        <Button Name="NameBtn" Content="Send to JS"></Button>
        </StackPanel>
    </Grid>
</UserControl>

SL Mainpage.xaml.cs:
namespace JavascriptTest
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            NameBtn.Click += new RoutedEventHandler(NameBtn_Click);
            HtmlPage.RegisterScriptableObject("navObj", this);
        }

        void NameBtn_Click(object sender, RoutedEventArgs e)
        {
            HtmlPage.Window.Invoke("ExecuteAnimation", NameTxt.Text);
        }

        [ScriptableMember()]
        public void SendMessage(string state)
        {
            MessageBox.Show("Message reached SL");
        }
    }
}

test.html:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>JavascriptTest</title>
    <script type="text/javascript">
        function ExecuteAnimation(params) {
            loadexcel(params);
            alert("Hello, World");
        }
        function load() {
            var ctrl = $get("Silverlight1");
            ctrl.Content.navObj.SendMessage('Hello');
        }
        function loadexcel(params) {
            var ExcelSheet;
            ExcelSheet = new ActiveXObject("Excel.Application");
            ExcelSheet.Workbooks.Open(params);
            //ExcelSheet.Visible = true;
            // Place some text in the first cell of the sheet.
            ExcelSheet.ActiveSheet.Cells(1, 1).Value = "This is column A, row 1";
            // Save the sheet.
            ExcelSheet.SaveAs("C:\\TEST.XLS");
            // Close Excel with the Quit method on the Application object.
            ExcelSheet.Quit();
            // Release the object variable.
            ExcelSheet = "";
        }
        </script>
    <style type="text/css">
    html, body {
        height: 100%;
        overflow: auto;
    }
    body {
        padding: 0;
        margin: 0;
    }
    </style>
</head>
<body >
    <form id="form1" runat="server" style="height:100%;">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div  style="height:90%;">
            <asp:Silverlight ID="Silverlight1" runat="server" Source="~/ClientBin/JavascriptTest.xap" MinimumVersion="3.0.40307.0" Width="100%" Height="100%" />
        </div>
        <input type="submit" onclick="load()" />
        <input type="submit" onclick="loadexcel()" />
    </form>
   
</body>
</html>



Mar 11, 2009

Wall Street - When profits are privatized and losses are socialized

Lehman Brothers (Sept 15, 2008)Image by Jodene via Flickr

What happens, when bankers start looting? in daylight.. and, none is held accountable.. probably, another Great Depression.

There are more and more articles dissecting the fallout of the Lehman Brothers and the life after the shocker.

Series of bank failures, collapse of stock market, historic job losses, deficit state budgets, mounting jobless claims, rising foreclosures.. just a few among the long list of impact on the economy.

The greed of bankers and lack of moral ethics even in times of deep recession have been condemned in numerous instances. Merill Lynch giving away millions in staff bonuses, when the bank was requesting billions in bailout from the government.

How did it go unnoticed? Why didn't the economic experts predict it? Probably, not all of them. But, some did. Economists George Akerlof and Paul Romer questioned the system of running banks and the bankers' mentality in the 1990s.

The article "The Looting of America’s Coffers" from New York Times presents a great indepth into lessons learnt and lessons to learn to avoid another great recession. Following are the key excerpts from the article:

Promised bailouts mean that anyone lending money to Wall Street — ranging from small-time savers like you and me to the Chinese government — doesn’t have to worry about losing that money. The United States Treasury (which, in the end, is also you and me) will cover the losses.

The knowledge among lenders that their money will ultimately be returned, no matter what, clearly brings a terrible downside. It keeps the lenders from asking tough questions about how their money is being used.

When people are protected from the consequences of risky behavior, they behave in a pretty risky fashion. Bankers can make long-shot investments, knowing that they will keep the profits if they succeed, while the taxpayers will cover the losses.

Merrill Lynch’s losses from the last two years wiped out its profits from the previous decade.

Banks borrowed money from lenders around the world. The bankers then kept a big chunk of that money for themselves, calling it “management fees” or “performance bonuses.” Once the investments were exposed as hopeless, the lenders — ordinary savers, foreign countries, other banks, you name it — were repaid with government bailouts. In effect, the bankers had siphoned off this bailout money in advance, years before the government had spent it.

The federal government needs the power and the will to take over a firm as soon as its potential losses exceed its assets. Anything short of that is an invitation to loot.

The above excerpts and title are from the original article here at NYTimes. Recommended read.



Reblog this post [with Zemanta]

Mar 5, 2009

Safari 4 browser - Awesome treat from Apple

I have been following Safari browser with utmost curiosity since its first release on Windows. Simplicity was good in the first release. The best performance rendering was another great thing(fastest browser in the market today!). But, certainly didn't have the touch of a Mac or iPhone kind of jazzy UI.With the release of Safari 4 beta, Apple has just blown away the competition showcasing what its best at. The GUI. The Safari 4 is already topping the charts on rendering performance, Acid Test 3 100% compliance and awesome UI.The browser brings in some of the jazzy features available in its existing line of products. Let the pictures speak the million words, that i can't express with :)

History Preview - Top Sites: Grabs your attention the moment you open it. Eventhough similar to Opera/Chrome preview, this has the Apple touch to make it 3d and jazzy.


Editing your history - Apple way!


Flip through history pages like albums - iTunes and iPhone thingy.


Tabbed browsing - a tinge of Google Chrome

Split out tabs into windows and stitch them back.This is a cool feature similar to Google Chrome. Inorder to drag a tab into a new window, click on the small bunch of stripes at the top right corner of a tab and drag it. The tab now becomes a separate Safari window/browser whichever way you like.To put them back together, just drag the tab into another tab. The tabs stitch together into a single browser.Surprising, there is a company that Apple likes to follow, atleast in some aspects. Voila Google!Bad news - Safari gobbled 225mb of memory and never gave it up till i had to kill the "beauty outside, beast inside" browser ;)


On the whole, Safari is very Apple with a taste of Chrome.



Reblog this post [with Zemanta]

Feb 11, 2009

Downturn is the best time to invest.

Fishing for DreamsImage by ...-Wink-... via Flickr

Downturn is the best time for a corporation to build a product or revamp an existing infrastructure. Average work is not acceptable any more. Only the outstanding can survive the downturn. And, every single person in the crowd knows that. So, everyone is going to give better than their best so far.

All the above state that, the quality of work and the value for money is at the highest now than ever. Moreover, this is the best time for organizations to build great products at very competitive cost, to have them ready when the economy springs back couple of months from now. Pulicat

To summarize, this is the best time for organizations to build products or start new initiatives. People are going to know their true potential by putting their best efforts ever to survive the downturn and trying out things they haven't done so far.
Reblog this post [with Zemanta]

Jan 23, 2009

Recession or Depression - How bad will it be?

WASHINGTON - OCTOBER 21:  Tourist Tony Arroyo ...Image by Getty Images via Daylife

The current Recession is portrayed more as the upcoming Second Great Depression. Its the popular belief. Its the speculation that drives the economy. Its the way economy works. If you are still making good money, expect to be on job for the next 5 months, you have nothing to do with the Recession. Its just a personal thingy.

Technically, the entire globe is in great recession.

Newspapers, Magazines and Websites are churning out bad news and hopes to survive. This is my perception of how bad is the recession.

It's the worst recession since the great depression.

GM and Chrysler are on the verge on collapse. Bad decisions are the cause. It has always been so with these companies. They had respite from financial lenders. It's not going to be the case now. There is no money in the market and only the government can save these companies.

Toyota has announced loss for the first time in its 70 years history.

Microsoft is cutting jobs for the first time in its history.

Google cutting jobs for the first time.

The big US banks that once controlled the global economy don't exist anymore.

Circuit City closes chain, due to non-availability of credit for merchandise.

German billionaire tycoon Adolf Merckle commits suicide. Forbes 94th richest man on planet.

Typically in every recession, the signs are known towards the end of recession, meaning the turn around in economy is around the corner. The current recession signs seem to be just the beginning of worse.



Reblog this post [with Zemanta]

Jan 21, 2009

When perfection becomes a curse

Rear view of an original iPhone. The back is m...Image via WikipediaBeing perfect is associated with "Winning", "Pride", "Confidence" etc. But, being finicky about perfection can become a hurdle and cause negative impact on your personality.

That's the message from a recent article. It presents the uncommon perspective of being perfect.
But, nevertheless no one can deny that Perfection pays and distinguishes the creamy. We wouldn't have the great products like iPhone, Gmail, Bose or Facebook of today without someone's desire for perfection.

Here is the well written article.
Reblog this post [with Zemanta]