DCSIMG
July 2007 - Posts - ekampf 2.0

ekampf 2.0

Provides rich user reading experience and a warm fuzzy feeling...

על הבלוג

DeveloperZen.com feed (my main blog):

 Subscribe in a reader

ekampf 2.0 (blogs.microsoft.co.il syndication) feed:

 Subscribe in a reader

    Navigation

    July 2007 - Posts

    GarageGeeks

    I didn't go to the GarageGeeks party. I had a university class to attend to...
    My friends went to the party and hooked up with some guys from Google that we hang out with at Tel Aviv for teh past couple of days. Tal has the whole thing documented on his Flickr page :-)



    © 2007 Eran Kampf. This Feed is for personal non-commercial use only.

    Prepping a New Duet Release (Traveling to Bangalore)

    It seems like its that time of the year again. We're finalizing the next Duet release (1.5) and I'm traveling to Banglore to support the teams there. Last time I was supposed to stay therefor 10 days and ended up being there for almost a month and with another extra day in Bombay due to an airport strike in Israel.

    The good thing this year is that the strike is already over so there's little chance of getting stuck again...

    Since we've already been to the Taj Mahal last year, and due to bad weather conditions that prevent us from going to Goa etc. we plan on going to Sri Lanka for the weekend. I wodner how this will trun out...



    © 2007 Eran Kampf. This Feed is for personal non-commercial use only.

    חברת התוכנה הגדולה בעולם?

    מסתבר של-SAP היה יותר מסתם רבעון טוב, לפחות לפי גלובס שם מצאתי את הפסקה הבאה בסיכום יום המסחר בוול סטריט:

    חברת התוכנה הגדולה בעולם, SAP (סימול: SAP), דיווחה היום על צמיחה של 8.2% ברווח הנקי ברבעון השני של השנה, הודות לקפיצה במכירות רישיונות התוכנה. החברה אף הצליחה לעבור את תחזיות האנליסטים בשורה העליונה והתחתונה.

    או שאני עובד בחברה שהכפילה ואף שילשה את עצמה בין לילה, הישג שבהחלט עוקף את תחזיות האנליסטים, או שלאיזה כתב כלכלי שם בגלובס יש עוד קצת מה ללמוד...

    Posted: Jul 19 2007, 11:54 PM by ekampf | with no comments
    תגים:

    Duet Behind the Scenes: Bounded Items

    Binding to Outlook item (Mail, Task, Contact, etc.) is one of the main features that differentiates Duet's user experience from other OBA products such as Snap-Ins, Extensio etc.
    What exactly are bounded items? and how is binding implemented?

    What are Bounded Items?

    A bounded item is a simple Outlook item, which can be an email, appointment, contact etc. with an attached schema that defines it as a specific presentation object (presentation objects discussed in the previous post) and carries the business data related to that object. We call this a payload.
    The payload is an encrypted XML containing the presentation object reference and business data mentioned above and attached to the Outlook item as a custom property.

    For example, a payload attached to a contact item that represents a CRM customer would probably contain data such as the customer's ID, company he works at, etc.

    Before we examine how this payload is built, maintained and displayed to the user we first have to take a step back and understand how its schema defined. Or to be more accurate, how we define a presentation object.

    Bound Item Definitions

    If you remember the metadata illustration from the first post, one of the key parts in a presentation object's metadata definition is its Data Definitions as displayed in the illustration:

    image

    A presentation item's Data Definitions contain the following information:

    1. Presentation object name- A unique resource name identifying this presentation object type
    2. Outlook definitions -Specifies the Outlook item type this objects relates to and its default folder location.
    3. Synchronization behavior - Type of synchronization used to synchronize to the backend. 
    4. Business Data Schema - A schema for the business data this object carries with it
    5. Data Mapping to\from Outlook Properties - A set of mappings that define how the Outlook item's default fields (Such as Subject, Location, Start\End Time) map to\from values in the item's business data.

    If we look at a definition for a CRM Customer object again, its name would be something like "urn:sap:duet:crm:customer" and its business data would probably contain name and contact information (address, phone numbers). This data would be mapped to the relevant Outlook fields (phone numbers to Contact item phone properties, address to the Contact item address property etc.) so that when the user edits the object the changes will be propagated back to the business data payload (and eventually to the backend).

    This data definition, termed Bound Item Definition looks like this:

    <BoundItemDefinition Name="urn:sap:duet:crm:customer" xmlns="http://schemas.microsoft.com/OBA/2005/BoundItemDefinition">
      <Outlook DefaultFolder="CRM Contacts" MessageClass="IPM.Contact" />
      <Synchronization>
        <Behavior>Always</Behavior>
      </Synchronization>
      <Properties>
        <Property Name="Crm.Customer.FirstName" Type="String">
          <Behavior>OutlookToXml</Behavior>
          <Outlook Name="FirstName" />
          <Xml XPath="/ns0:CRMContact/Name" Namespaces="ns0='urn:sap:duet:crm:customer'" />
        </Property>
        <Property Name="Crm.Customer.LastName" Type="String">
          <Behavior>OutlookToXml</Behavior>
          <Outlook Name="LastName" />
          <Xml XPath="/ns0:CRMContact/ns0:LastName" Namespaces="ns0='urn:sap:duet:crm:customer'" />
        </Property>
        ...
      </Properties>
      <XmlTemplate>
        <s0:CRMContact xmlns:s0="urn:sap:duet:crm:customer">
          <s0:FirstName>String</s0:FirstName>
          <s0:LastName>String</s0:LastName>
          <s0:FileAsName>String</s0:FileAsName>
          <s0:Comapany>String</s0:Comapany>
          <s0:JobTitle>String</s0:JobTitle>
          ...
        </s0:CRMContact>
      </XmlTemplate>
    </BoundItemDefinition>

    Binding an Item

    The process of binding an item is where we take a regular Outlook item and mark it has a presentation object.
    Basically we're taking a regular Outlook item and marking it as a presentation object. The item's behavior and schema for the business data attached to it are according to the presentation object's data definitions.

    When binding an item the Duet platform adds 3 custom properties to the item:

    1. BoundItemId - A unique ID to represent this bounded item.
    2. BoundItemType - The type of presentation object that the item represents
    3. BoundData - The business data the item carries (payload).

    In our example, a bounded IPM.Contact object representing a customer would have urn:sap:duet:crm:customerIn as its BoundItemType and the following XML as its BoundData:

        <s0:CRMContact xmlns:s0="urn:sap:duet:crm:customer">
          <s0:FirstName>Eran</s0:FirstName>
          <s0:LastName>Kampf</s0:LastName>
          <s0:FileAsName>Kampf, Eran</s0:FileAsName>
          <s0:Comapany>SAP Labs Israel</s0:Comapany>
          ...
        </s0:CRMContact>
    

    The values in the BoundData are populated according to the data mapping rules specified in the bound item definition for our customer object.

    Security Considerations

    The BoundData can contain confidential information. Once retrieved from the backend systems we would like to limit access to it specifically to the user who got the information. Otherwise, sensitive information which is part of the user's item can leek if, for example the user forwards the item to someone or if an IT administrator (or anyone else who has access to the user's mailbox) looks at the item.

    We use DPAPI to encrypt the BoundData using the current user's credentials so that only the Duet user who received the data can decrypt it.
    This way, even if someone else gets hold of the BoundData value he has no way to decipher it...

    This also means that when forwarding a Duet item the receiving side will not have Duet information available and will see the item as a regular unbounded Outlook item. I'll discuss how forwarding of bounded items is performed in a future post dedicated to forwarding...

    kick it on DotNetKicks.com

    What's wrong with this code? #1 - Discussion

    The Singleton implementation in the snippet I gave works fine as a lazy, thread-safe Singleton as it ensures only one thread can create the instance.
    However, there's a big performance hit caused by the fact that we acquire a lock each time the Singleton's instance is requested.

    Yoav, suggested to fix this performance problem by checking for null twice - outside the lock and inside the lock:

            public static Singleton Instance
            {
                get
                {
                    if (Singleton._insatnce == null)
                    {
                        lock (_syncRoot)
                        {
                            if (Singleton._insatnce == null)
                            {
                                Singleton._insatnce = new Singleton();
                            }
                        }
                    }
                    return Singleton._insatnce;
                }
            }

    This code, known as "Double-Check Locking" doesn't work in the presence of either an optimizing compiler or  shared memory multiprocessor.
    The main reason for this (as explained by Brad) is that the CLR's memory model allows non-volatile read\writes to be reordered as long as that change cannot be noticed from the point of view of a single thread.
    This means that the compiler can reorder write to _instance during initialization and its construction write, causing another thread to see _instance as set even though it wasn't initialized yet (appears on stress testing).

    To prevent such optimizations we can declare _instance to be volatile or by explicitly specifying a memory barrier before accessing the data member using System.Threading.Thread.MemoryBarrier(). Using Thread.MemoryBarrier() is more efficient than volatile as it allows compiler optimization when barrier is not required:

            public static Singleton Instance
            {
                get
                {
                    if (Singleton._insatnce == null)
                    {
                        lock (_syncRoot)
                        {
                            if (Singleton._insatnce == null)
                            {
                                Singleton newInstance = new Singleton();
                                // Ensure all writes used to construct new value have been flushed.
                                System.Threading.Thread.MemoryBarrier();
                                Singleton._insatnce = newInstance;         // publish the new value
                            }
                        }
                    }
                    return Singleton._insatnce;
                }
            }

     Another way of doing the same thing is using System.Threading.Interlocked.CompareExchange() which also enforces a memory barrier.

    Omer, suggested creating the instance of Singleton in the static constructor (which is guaranteed to be thread-safe) rather than in the Instance accessor.
    While in this implementation you lose some of the flexibility of controlling exactly at which point in time the Singleton instance is created, this kind of control is not really required in most cases and giving up on it allows making the code shorter and less confusing...

    kick it on DotNetKicks.com

    26 Years to my Launch

    On February 27th 2008 it would be 26 years to my own "launch".
    I'm truelly honored that Microsoft decided to commemorate this date by launching Windows Server 2008, Visual Studio 2008 and SQL Server 2008 on the same date.

    In fact, I wouldn't mind celebrating with them at Los Angeles if I get the chance :-)

    mscountdownheader[1]



    © 2007 Eran Kampf. This Feed is for personal non-commercial use only.

    26 שנים להשקה של עצמי

    mscountdownheader[1] מיקרוסופט החליטו להידחף לי לחגיגה ולהשיק את Windows Server, Visual Studio ו-SQL Server.
    אחלה תאריך...
    האמת, לא אכפת לי לחגוג אותו בלוס אנג'לס :)

    Will the iPhone Blend?

    iphone2[1] Got to love this "Will it blend" videos series...
    So what do you think? How about an iPhone smoothy? ;)

    http://www.willitblend.com/videos.aspx?type=unsafe&video=iphone



    © 2007 Eran Kampf. This Feed is for personal non-commercial use only.

    What's wrong with this code? #1

    I decided to start a new column gathering all sorts of "what's wrong with this code?" snippets.
    Why?

    1. Its fun.
    2. Its good for interview questions.
    3. It starts discussions. More interesting than just talking (or writing) to myself.

    So, here's what I plan:

    1. I post a code snippet (most probably C# but I'm not setting constraints on myself)
    2. You comment on what's wrong with the code on the snippet
    3. I post my answer, interesting comments, etc. (you can comment on my answer too :-))

    * Note that these posts are syndicated on blogs.microsoft.co.il (and maybe some other places) so please leave your comments at the main blog - www.ekampf.com/blog/

    ** I know there are many "What's wrong with this code?" out there already. I'll try not to recycle (too much ;))

    When looking at these snippets note the following "Bad Code" classifications: Confusing code, Overly complex code, Performance Issues, Buggy.

    So, to start with an easy one (I think), check out the following Singleton implementation:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
        public sealed class Singleton
    {
    private Singleton() { }

    private static Singleton _insatnce;
    private static object _syncRoot = new Object();

    public static Singleton Instance
    {
    get
    {
    lock (_syncRoot)
    {
    if (Singleton._insatnce == null)
    {
    Singleton._insatnce = new Singleton();
    }

    return Singleton._insatnce;
    }
    }
    }
    }


    © 2007 Eran Kampf. This Feed is for personal non-commercial use only.

    Blogerim.Net

    Blogerim.Net are having a digg-style blogs competition.
    So, I signed up my blog (as a Personal Blog and an Internet&Technology blog) and you're all welcome to vote :)\

    Update 8/July/2007:

    Apperantly Bloggers.Net is for Hebrew blogs only, so my blog entry got deleted.
    In any case, I recieved over 10 votes over the weekend so thanks to anyone who voted :-)

    blogs.microsoft.co.il - הצעות שיפור

    With the recent boost of attention to this site and its bloggers I thought I just wanted to write down some features
    I hope to see here in the future as:

    1. "Recent Comments" panel (pagelet?) on the main page.
      I don't know about you but as a blogger I like receiving comments and reading\commenting on other posts. In fact, sometimes the discussion on a post's comments thread is far more interesting than the post itself.
      There's not enough discussion going on in blogs.microsoft.co.il. I think such a panel on the main page will encourage discussion...
      Alternatively (or additionally) you can something like a recent most commented\popular\viewed posts.
    2. Blog Statistics. According to Yossi (and a quick look at my blog's html) all the site's pages are monitored by Google Analytics. Being monitored already by one account is probably the reason I could not get Google to monitor my own blog using my account. Can these stats be exposed to the bloggers\public?
    3. Adsense. I have adsense installed on my main blog. I don't see any reason why blogger shouldn't make money on their blog. On Yossi's post on the subject people commented that its not good for Microsoft's "image" to use Google services.
      Well, as long as Microsoft doesn't have a competing service I'm not sure what's the harm.
    4. Bloggers Panel at Tech-Ed. Just for the chance to get invited to next Tech-Ed for free ;-)

    What do you think?

    Btw, Yossi etc. keep up the good work! :)

    WPF Flocking and Evasion Demo

     Came across this cool XBAP by Denis Dolfus:

    FlockingXBAP

    © 2007 Eran Kampf. This Feed is for personal non-commercial use only.

    Windows Live Writer Spell-Checker is Missing?

    If you've installed the latest WLW beta you must have noticed that the spell-checker is missing.

    Apperantly, this is a bug that happends when the machine's locale isn't set to en-us.
    The workaround for this (besides changing your system to use the en-us locale) is to create your own loader that loads Windows Live Writer in en-us locale.
    The solution and code can be found here or if you prefer C# you can sue this

            static void Main(string[] args)
            {
                string wlwInstallDir = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Live Writer", "InstallDir", string.Empty).ToString();
                string wlwExe = Path.Combine(wlwInstallDir, "WindowsLiveWriter.exe");
    
                if (!File.Exists(wlwExe))
                {
                    System.Windows.Forms.MessageBox.Show("Windows Live Writer cannot be found at " + wlwExe);
                    return;
                }
    
                Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
                AppDomain app = System.AppDomain.CreateDomain(wlwExe);
                app.ExecuteAssembly(wlwExe);
            }


    © 2007 Eran Kampf. This Feed is for personal non-commercial use only.

    Duet Microsoft Partner Program Page

    Saw the news on Ian's blog. Microsoft launched their Duet partners page. Check it out...



    © 2007 Eran Kampf. This Feed is for personal non-commercial use only.

    Duet Behind the Scenes: Metadata Driven Solutions

    The Duet applications are built using metadata definitions that are interpreted during runtime and drive the different application's workflow and UI.
    How is Duet's metadata defined and used? What are the advantages of this model? image  

    Presentation Objects

    The Duet metadata defines business objects and how they interact with the user and the backend system. I like to refer to such objects as "presentations objects" because unlike the backend Business Objects that make sense to backend developers these are objects that make sense to the user.
    For example, information about a person's salary, compensation and HR information may be represented as several different business objects on the backend (or on several backend systems, maybe even from different vendors). The end-user, looking at a contact information on his Outlook doesn't have to know about all the different backend and business objects that were used to aggregate the information on his screen.

    Therefore, the Duet metadata defines such presentation objects - the information they carry, how this information is aggregated to and from the backend system(s)and how they interact with the user in his Office environment. So, from an abstract point of view, an application's metadata structure is somewhat similar to this:

    image

    DuetML

    All the UI components in Duet are defined by a markup language - DuetML. Each UI component displayed to the user is actually represented by an XML defining the UI and a .NET assembly codebehind defining the logic behind the UI. Basically this mechanism is a lot like WPF's XAML but with several key differences:

    1. DuetML is based on top of WinForms and has very limited UI capabilities specifically designed for Duet's UI screens
    2. XAML gets compiled (to BAML) during design time while DuetML is interpreted during runtime.
      This gives us a lot of customization & translation capabilities on the server where we process the DuetMLs before sending them to the user (I will probably have to dedicate a whole post specifically to discuss business customization and localization)

    In fact, DuetML's schema was designed to closely resembles XAML to allow transition to XAML in the future...

    So, Why Use Metadata?

    Simplified solution development. The metadata-based architecture makes it possible to develop declarative business solutions. Because solutions are defined in metadata, developers can build simple, powerful solutions with little or no coding using pre-made common solution building blocks. Advanced developers can use .NET further customize their applications and add new features.

    Centralized deployment. In order to run Duet solutions all the clients need is the Duet runtime which is a generic add-in that runs inside the Office applications and can load and interpret the metadata fetched from the server. The different solutions are deployed on a central server and do not require additional installations on the client.

    Enhanced customization capabilities. Declarative approach also allows enhanced customization capabilities as customizing the application simply means editing its metadata. Duet's ACE (Application Configuration Environment) goes a step further by allowing providing a configuration environment that allows the business administrator to apply such changes without requiring knowledge about the metadata and code behind a solution.

    Automatic generation and modeling. A declarative approach for defining solution is the basis for enabling modeling and automatic generation of solutions. Imagine that you could quickly select some objects from the backend, define the matching object in Outlook and the data you wish to see and a solution will automatically be generated for you? And imagine you could customize such a solution using a visual programming tool such as Visual Composer (Microsoft Popfly, Yahoo Pipes style of development for you non SAPers)

    Technorati Tags: , ,


    © 2007 Eran Kampf. This Feed is for personal non-commercial use only.
    More Posts Next page »