<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8000681016804453978</id><updated>2012-02-16T00:31:44.763-08:00</updated><category term='Coding'/><category term='Adventures'/><category term='Picnic'/><category term='Designing'/><category term='Anniversary Party'/><category term='Helping others'/><category term='RIA'/><category term='Spacers'/><title type='text'>KaZeitgeist</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.kaz.com.bd/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-2757509702750753403</id><published>2012-02-02T01:19:00.000-08:00</published><updated>2012-02-02T04:05:38.466-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Helping others'/><title type='text'>Yet another win for Agile</title><content type='html'>We've been talking about how to help our community at Kaz for a long time. Being a bunch of "techies" that’s no easy goal!&lt;br /&gt;&lt;br /&gt;We thought, we'll use our experiences of software process to achieve this goal. That immediately led us to some brainstorming sessions, which led to chaos (as usual) and minor ideological war (even more usual), this led to a wiki page for idea submission. But hey that’s the PROCESS!&lt;br /&gt;&lt;br /&gt;We got a lot of ideas, some of them phenomenally good and some borderline crazy. We thought we will pick up some of them and start. But that’s where things stopped.&lt;br /&gt;&lt;br /&gt;After cycling through this several times we realized that we are really running things classic Waterfall with big design upfront and all of its smelly friends (sorry, you have to forgive me for these weak allusions, but this blog is consumed mostly by software guys). Anyway, we realized we need to go agile and take some baby steps to get something done.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/-Ul3zlAzQn4s/Typ3x-Hr9DI/AAAAAAAAAAg/gRkWpnFmrYY/s1600/Untitled-4.jpg"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 320px; FLOAT: left; HEIGHT: 234px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5704503578390688818" border="0" alt="" src="http://3.bp.blogspot.com/-Ul3zlAzQn4s/Typ3x-Hr9DI/AAAAAAAAAAg/gRkWpnFmrYY/s320/Untitled-4.jpg" /&gt;&lt;/a&gt; As luck would have it, pretty much around same time of this ground breaking, earth shattering realization that agile is good, a dodgy looking guy dropped in at Kaz. He came as friend of a Kaz guy but it turned out he is a super secret philanthropist who runs a teaching program for street children pretty close to us. This was our chance! We went agile with him.&lt;br /&gt;&lt;br /&gt;So the success of this baby step is that we are now proudly providing snacks for every child that turn up for the class - and that acts as very good magnet to keep the children coming. The next baby step is that we do some basic computer skill training to the children (I know, somewhere someplace that machine had to come in). Sadly the secret philanthropist tells us that teaching them C++ (which we feel is a must for anyone touching that machine) won't be very helpful for the kids so we are sticking to the "how to click the start button" path. But we hope that this is a start of bigger and better things - maybe even some of our ideas in the wiki too.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/-D1HFQ4R77KY/Typ3xoJ4S2I/AAAAAAAAAAY/5SNTyc7th00/s1600/Untitled-3.jpg"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 235px; FLOAT: left; HEIGHT: 320px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5704503572494306146" border="0" alt="" src="http://3.bp.blogspot.com/-D1HFQ4R77KY/Typ3xoJ4S2I/AAAAAAAAAAY/5SNTyc7th00/s320/Untitled-3.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you feel like making a baby step too, feel free to drop in at the street class at around 4pm on the street that leads from Aziz Super market to Paribag:&lt;br /&gt;&lt;br /&gt;So yet another karma point for Agile - this thing is definitely making it to the Nirvana.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/-GI4JG3yKP0M/Typ3xo-XnVI/AAAAAAAAAAQ/w0VFoKvAH_E/s1600/Untitled-1.jpg"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 320px; FLOAT: left; HEIGHT: 210px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5704503572714462546" border="0" alt="" src="http://2.bp.blogspot.com/-GI4JG3yKP0M/Typ3xo-XnVI/AAAAAAAAAAQ/w0VFoKvAH_E/s320/Untitled-1.jpg" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-2757509702750753403?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/2757509702750753403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/2757509702750753403'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2012/02/yet-another-win-for-agile.html' title='Yet another win for Agile'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-Ul3zlAzQn4s/Typ3x-Hr9DI/AAAAAAAAAAg/gRkWpnFmrYY/s72-c/Untitled-4.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-2722388921697378875</id><published>2009-11-25T21:39:00.000-08:00</published><updated>2010-05-29T01:38:40.920-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Coding'/><title type='text'>Extending WCF Part I</title><content type='html'>&lt;style&gt; PRE { 	PADDING-RIGHT: 7pt; PADDING-LEFT: 7pt; PADDING-BOTTOM: 7pt; FONT: 9pt "Courier New", Courier, mono; OVERFLOW: auto; PADDING-TOP: 7pt; WHITE-SPACE: pre; BACKGROUND-COLOR: #fbedbb } CODE { 	FONT-SIZE: 11pt; COLOR: #990000; FONT-FAMILY: "Courier New" , Courier, mono } .AutherTitle{font-size:12px;padding:0;margin:0}&lt;/style&gt;&lt;br/&gt;    &lt;h3&gt;by Mosfiqur Rahman&lt;/h3&gt;&lt;br/&gt;    &lt;p class="AutherTitle"&gt;Senior Software Engineer @Kaz&lt;/p&gt;&lt;br/&gt;&lt;br/&gt;    &lt;h2&gt;Introduction&lt;/h2&gt;&lt;br/&gt;    &lt;p&gt;&lt;br/&gt;        Microsoft WCF Framework (System.ServiceModel) provides several extension points&lt;br/&gt;        from where developer can extend the framework when it requires. In this Part I article&lt;br/&gt;        I'm going to cover two perspective of extending WCF framework:&lt;br/&gt;    &lt;/p&gt;&lt;br/&gt;    &lt;a id="lnkIntroItem1"&gt;&lt;/a&gt;&lt;br/&gt;    &lt;p&gt;&lt;br/&gt;        1. Lets think about a WPF desktop application or a WPf browser application or a&lt;br/&gt;        windows desktop application or a .net web application, built on service oriented&lt;br/&gt;        architecture and all the back end services are WCF services. Now for several reasons&lt;br/&gt;        you may need to change the server for your service which in turn changes your service&lt;br/&gt;        URL or you may need to change the configuration of service bindings/behaviors. If&lt;br/&gt;        you change any WCF configuration at the server you need to provide the same bindings/behaviors&lt;br/&gt;        configuration to the clients also to work the client-service interaction properly.&lt;br/&gt;        And this is very difficult in typical clients like XBAP (WPF Browser application)&lt;br/&gt;        clients. My ExtendingWCFPartI.WcfExtentions.dll component provides a solution to&lt;br/&gt;        this. You can have an external configuration file (e.g. by downloading it from server&lt;br/&gt;        before client application starts up) where service endpoints are configured properly&lt;br/&gt;        and use that external configuration file to create the WCF service proxy instances.&lt;br/&gt;    &lt;/p&gt;&lt;br/&gt;&lt;br/&gt;    &lt;a id="lnkIntroItem2"&gt;&lt;/a&gt;&lt;br/&gt;    &lt;p&gt;&lt;br/&gt;        2. In many cases we want to get exactly the same exception thrown from WCF service&lt;br/&gt;        at WCF client. ExtendingWCFPartI.WcfExtentions.dll component also provides this.&lt;br/&gt;    &lt;/p&gt;&lt;br/&gt;    &lt;h2&gt;&lt;br/&gt;        Background&lt;/h2&gt;&lt;br/&gt;    &lt;h3&gt;&lt;br/&gt;        Extending ChannelFactory&amp;lt;T&amp;gt;&lt;/h3&gt;&lt;br/&gt;&lt;br/&gt;    &lt;p&gt;&lt;br/&gt;        This extension is to serve the &lt;a href="#lnkIntroItem1"&gt;first&lt;/a&gt; introduction item.&lt;br/&gt;        In general System.ServiceModel.ChannelFactory&amp;lt;T&amp;gt; provides us the option to&lt;br/&gt;        get a proxy instance programmatically instead of using the proxy generated through&lt;br/&gt;        svcutil.exe (.NET Framework tool). I've extended this class to write my own ExtendingWCFPartI.WcfExtentions.ExtendedChannelFactory&amp;lt;T&amp;gt;&lt;br/&gt;        class to provide the &lt;a href="#lnkIntroItem1"&gt;external configuration file&lt;/a&gt; functionality.&lt;br/&gt;        The constructor argument "configurationPath" should contain the full path of the&lt;br/&gt;        external configuration file. Then I override the ChannelFactory&amp;lt;T&amp;gt;.CreateDescription()&lt;br/&gt;        method to apply the external configuration file. The external configuration file&lt;br/&gt;        looks exactly the same as conventional client's app.config or web.config file. For&lt;br/&gt;        sample external configuration, you can look at the ExtendingWCFPartI.Client.WcfClientConfiguration.xml&lt;br/&gt;        file.&lt;br/&gt;    &lt;/p&gt;&lt;br/&gt;&lt;br/&gt;    &lt;h3&gt;&lt;br/&gt;        Extending WCF Service and WCF client behavior&lt;br/&gt;    &lt;/h3&gt;&lt;br/&gt;    &lt;p&gt;&lt;br/&gt;        To provide the &lt;a href="#lnkIntroItem2"&gt;second&lt;/a&gt; introduction item, we need to&lt;br/&gt;        extend behavior of service, endpoint and contract.&lt;br/&gt;        &lt;pre&gt;&lt;br/&gt;public class ExtendedServiceErrorHandler:IErrorHandler&lt;br/&gt;{&lt;br/&gt;    #region IErrorHandler Members&lt;br/&gt;&lt;br/&gt;    bool IErrorHandler.HandleError(Exception error)&lt;br/&gt;    {&lt;br/&gt;        if (error is FaultException)&lt;br/&gt;        {&lt;br/&gt;            return false; // Let WCF do normal processing&lt;br/&gt;        }&lt;br/&gt;        else&lt;br/&gt;        {&lt;br/&gt;            return true; // Fault message is already generated&lt;br/&gt;        }&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    void IErrorHandler.ProvideFault(Exception error,&lt;br/&gt;        MessageVersion version,&lt;br/&gt;        ref Message fault)&lt;br/&gt;    {&lt;br/&gt;        if (error is FaultException)&lt;br/&gt;        {&lt;br/&gt;            // Let WCF do normal processing&lt;br/&gt;        }&lt;br/&gt;        else&lt;br/&gt;        {&lt;br/&gt;            // Generate fault message manually&lt;br/&gt;            MessageFault messageFault = MessageFault.CreateFault(&lt;br/&gt;                new FaultCode("Sender"),&lt;br/&gt;                new FaultReason(error.Message),&lt;br/&gt;                error,&lt;br/&gt;                new NetDataContractSerializer());&lt;br/&gt;            fault = Message.CreateMessage(version, messageFault, null);&lt;br/&gt;        }&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    #endregion&lt;br/&gt;}// end of class&lt;br/&gt;    &lt;/pre&gt;&lt;br/&gt;        ExtendedServiceErrorHandler should be injected into &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ms734665.aspx"&gt;&lt;br/&gt;&lt;br/&gt;            ChannelDispatcher's&lt;/a&gt; error handler list. Then WCF Framework will use our&lt;br/&gt;        implemented IErrorHandler.ProvideFault method when any exception is thrown from&lt;br/&gt;        service. Inside the method implementation I used the NetDataContractSerializer to&lt;br/&gt;        serialize the MessageFault which will be trasmitted to client.&lt;br/&gt;        &lt;pre&gt;&lt;br/&gt;public class ExtendedClientMessageInspector:IClientMessageInspector&lt;br/&gt;{&lt;br/&gt;    #region Methods&lt;br/&gt;&lt;br/&gt;    /// Reads the soap message to find the&lt;br/&gt;    /// node. If found than deserialize it using the &lt;br/&gt;    /// NetDataContractSerializer to construct the exception.&lt;br/&gt;    private static object ReadFaultDetail(Message reply)&lt;br/&gt;    {&lt;br/&gt;        const string detailElementName = "Detail";&lt;br/&gt;&lt;br/&gt;        using (var reader = reply.GetReaderAtBodyContents())&lt;br/&gt;        {&lt;br/&gt;            // Find&lt;br/&gt;&lt;soap:detail&gt;&lt;br/&gt;            while (reader.Read())&lt;br/&gt;            {&lt;br/&gt;                if (reader.NodeType == XmlNodeType.Element &amp;&amp; reader.LocalName == detailElementName)&lt;br/&gt;                {&lt;br/&gt;                    break;&lt;br/&gt;                }&lt;br/&gt;            }&lt;br/&gt;&lt;br/&gt;            // Did we find it?&lt;br/&gt;            if (reader.NodeType != XmlNodeType.Element || reader.LocalName != detailElementName)&lt;br/&gt;            {&lt;br/&gt;                return null;&lt;br/&gt;            }&lt;br/&gt;&lt;br/&gt;            // Move to the contents of &lt;soap:Detail&gt;&lt;br/&gt;            if (!reader.Read())&lt;br/&gt;            {&lt;br/&gt;                return null;&lt;br/&gt;            }&lt;br/&gt;&lt;br/&gt;            // Deserialize the fault&lt;br/&gt;            var serializer = new NetDataContractSerializer();&lt;br/&gt;            try&lt;br/&gt;            {&lt;br/&gt;                return serializer.ReadObject(reader);&lt;br/&gt;            }&lt;br/&gt;            catch (FileNotFoundException)&lt;br/&gt;            {&lt;br/&gt;                // Serializer was unable to find assembly where exception is defined &lt;br/&gt;                return null;&lt;br/&gt;            }&lt;br/&gt;        }&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    #endregion&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;    #region IClientMessageInspector Members&lt;br/&gt;&lt;br/&gt;    /// Create a copy of the original reply to allow &lt;br/&gt;    /// default processing of the message. Then its reads &lt;br/&gt;    /// the copied reply to find Fault Detail using the ReadFaultDetail method&lt;br/&gt;    void IClientMessageInspector.AfterReceiveReply(ref Message reply, object correlationState)&lt;br/&gt;    {&lt;br/&gt;        if (reply.IsFault)&lt;br/&gt;        {&lt;br/&gt;            // Create a copy of the original reply to allow default processing of the message&lt;br/&gt;            var buffer = reply.CreateBufferedCopy(Int32.MaxValue);&lt;br/&gt;            var copy = buffer.CreateMessage();  // Create a copy to work with&lt;br/&gt;            reply = buffer.CreateMessage();         // Restore the original message&lt;br/&gt;&lt;br/&gt;            var faultDetail = ReadFaultDetail(copy);&lt;br/&gt;            var exception = faultDetail as Exception;&lt;br/&gt;            if (exception != null)&lt;br/&gt;            {&lt;br/&gt;                throw exception;&lt;br/&gt;            }&lt;br/&gt;        }&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    object IClientMessageInspector.BeforeSendRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel)&lt;br/&gt;    {&lt;br/&gt;        return null;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    #endregion&lt;br/&gt;}// end of class&lt;br/&gt;    &lt;/pre&gt;&lt;br/&gt;        Now we need to extend the IClientMessageInspector to get back the same exception&lt;br/&gt;        at client end. At IClientMessageInspector.AfterReceiveReply method implementation,&lt;br/&gt;        NetDataContractSerializer has been used to get desrialize the fault exception and&lt;br/&gt;        get the actual exception back again.&lt;br/&gt;        &lt;pre&gt;&lt;br/&gt;&lt;br/&gt;public class ExtendedServiceBehavior:Attribute, IServiceBehavior, IEndpointBehavior, IContractBehavior&lt;br/&gt;{&lt;br/&gt;    private void ApplyDispatchBehavior(ChannelDispatcher dispatcher)&lt;br/&gt;    {&lt;br/&gt;        // Don't add an error handler if it already exists&lt;br/&gt;        foreach (IErrorHandler errorHandler in dispatcher.ErrorHandlers)&lt;br/&gt;        {&lt;br/&gt;            if (errorHandler is ExtendedServiceErrorHandler)&lt;br/&gt;            {&lt;br/&gt;                return;&lt;br/&gt;            }&lt;br/&gt;        }&lt;br/&gt;        dispatcher.ErrorHandlers.Add(new ExtendedServiceErrorHandler());&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;    private void ApplyClientBehavior(ClientRuntime runtime)&lt;br/&gt;    {&lt;br/&gt;        // Don't add a message inspector if it already exists&lt;br/&gt;        foreach (IClientMessageInspector messageInspector in runtime.MessageInspectors)&lt;br/&gt;        {&lt;br/&gt;            if (messageInspector is ExtendedClientMessageInspector)&lt;br/&gt;            {&lt;br/&gt;                return;&lt;br/&gt;            }&lt;br/&gt;        }&lt;br/&gt;&lt;br/&gt;        runtime.MessageInspectors.Add(new ExtendedClientMessageInspector());&lt;br/&gt;    }&lt;br/&gt;}&lt;br/&gt;        &lt;/pre&gt;&lt;br/&gt;        To tell the .NET runtime to use my ExtendedServiceErrorHandler at Service end error&lt;br/&gt;        handling and ExtendedClientMessageInspector at client error halding we need this&lt;br/&gt;        ExtendedServiceBehavior class which implemented service, endpoint and contract behavior.&lt;br/&gt;        All behaviors have an AddBindingParameters method, an ApplyDispatchBehavior method,&lt;br/&gt;        a Validate method, and an ApplyClientBehavior method with one exception: Because&lt;br/&gt;        IServiceBehavior cannot execute in a client, it does not implement ApplyClientBehavior.&lt;br/&gt;        For more details you can read the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ms730137.aspx"&gt;&lt;br/&gt;            msdn&lt;/a&gt; documentation.&lt;br/&gt;    &lt;/p&gt;&lt;br/&gt;    &lt;h2&gt;&lt;br/&gt;        Using the Code&lt;/h2&gt;&lt;br/&gt;    &lt;p&gt;&lt;br/&gt;&lt;br/&gt;        For simplicity, I've hosted the WCF service at console. To run the sample code and&lt;br/&gt;        see it working, follow the steps below:&lt;br/&gt;        &lt;br/&gt;        1. After opening the "ExtendingWCFPartI" application with VS, right click on the&lt;br/&gt;        ExtendingWCFPartI.Service project then click Debug -- &gt; Start new instance. Doing&lt;br/&gt;        so, you have ensured that the service is running at console host.&lt;br/&gt;        &lt;br/&gt;        2. Then run the ExtendingWCFPartI.Client project under debug mode.&lt;br/&gt;        &lt;br/&gt;        ExtendingWCFPartI.WcfExtentions.dll is the reusable component which is going to&lt;br/&gt;        be used at both WCF client and WCF service. Also make sure that you wrote the custom&lt;br/&gt;        exceptions in a common assembly which will be used at both WCF client and WCF service.&lt;br/&gt;    &lt;/p&gt;&lt;br/&gt;    &lt;h3&gt;&lt;br/&gt;        Using the code at WCF Service&lt;br/&gt;    &lt;/h3&gt;&lt;br/&gt;&lt;br/&gt;    &lt;p&gt;&lt;br/&gt;        At first let me show you how we can use this component to host our WCF services. You&lt;br/&gt;        can host the WCF services at IIS or at Windows Service or at console, no matter&lt;br/&gt;        where you host it, add the following section at your app.config or web.config ServiceModel&lt;br/&gt;        section. Add a reference the ExtendingWCFPartI.WcfExtentions.dll to your service&lt;br/&gt;        host application&lt;br/&gt;        &lt;pre&gt;&lt;br/&gt;&amp;lt;system.serviceModel&amp;gt;&lt;br/&gt;    &amp;lt;extensions&amp;gt;&lt;br/&gt;      &amp;lt;behaviorExtensions&amp;gt;&lt;br/&gt;        &amp;lt;add name="ExtendedServiceBehavior" type="ExtendingWCFPartI.WcfExtentions.ServiceBehaviorExtension, ExtendingWCFPartI.WcfExtentions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/&amp;gt;&lt;br/&gt;&lt;br/&gt;      &amp;lt;/behaviorExtensions&amp;gt;&lt;br/&gt;    &amp;lt;/extensions&amp;gt;&lt;br/&gt;&amp;lt;/system.serviceModel&amp;gt;&lt;br/&gt;        &lt;/pre&gt;&lt;br/&gt;        ExtendingWCFPartI.WcfExtentions.ServiceBehaviorExtension has been used to tell WCF&lt;br/&gt;        framework to use ExtendedServiceBehavior at its CreateBehavior() method.&lt;br/&gt;        &lt;pre&gt;&lt;br/&gt;&amp;lt;system.serviceModel&amp;gt;&lt;br/&gt;    &amp;lt;behaviors&amp;gt;&lt;br/&gt;&lt;br/&gt;      &amp;lt;serviceBehaviors&amp;gt;&lt;br/&gt;        &amp;lt;behavior name="CustomServiceBehavior"&amp;gt;&lt;br/&gt;          &amp;lt;serviceMetadata httpGetEnabled="true" /&amp;gt;&lt;br/&gt;          &amp;lt;serviceDebug includeExceptionDetailInFaults="true" /&amp;gt;&lt;br/&gt;          &amp;lt;serviceThrottling maxConcurrentCalls="16" maxConcurrentSessions="16" /&amp;gt;&lt;br/&gt;          &amp;lt;ExtendedServiceBehavior /&amp;gt;&lt;br/&gt;&lt;br/&gt;        &amp;lt;/behavior&amp;gt;&lt;br/&gt;      &amp;lt;/serviceBehaviors&amp;gt;&lt;br/&gt;    &amp;lt;/behaviors&amp;gt;&lt;br/&gt;&amp;lt;/system.serviceModel&amp;gt;&lt;br/&gt;        &lt;/pre&gt;&lt;br/&gt;        Now create a service behavior like the example above. &amp;lt;ExtendedServiceBehavior&lt;br/&gt;        /&amp;gt; ensures that this behavior configuration will use the ExtendedServiceBehavior.&lt;br/&gt;        &lt;pre&gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;system.serviceModel&amp;gt;&lt;br/&gt;    &amp;lt;services&amp;gt;&lt;br/&gt;      &amp;lt;service behaviorConfiguration="CustomServiceBehavior" name="ExtendingWCFPartI.Service.CustomerService"&amp;gt;&lt;br/&gt;        ... &lt;br/&gt;        ... &lt;br/&gt;        Your service endpoint's configuration goes here.&lt;br/&gt;      &amp;lt;/service&amp;gt;&lt;br/&gt;    &amp;lt;/services&amp;gt;&lt;br/&gt;&amp;lt;/system.serviceModel&amp;gt;&lt;br/&gt;&lt;br/&gt;        &lt;/pre&gt;&lt;br/&gt;        Thats all you need to do to host your WCF service which will have the two functionalities&lt;br/&gt;        explained at &lt;a href="#lnkIntro"&gt;introduction&lt;/a&gt;.&lt;br/&gt;    &lt;/p&gt;&lt;br/&gt;    &lt;h3&gt;&lt;br/&gt;        Using the code at WCF Client&lt;br/&gt;    &lt;/h3&gt;&lt;br/&gt;    &lt;p&gt;&lt;br/&gt;        Add a reference to the ExtendingWCFPartI.WcfExtentions.dll at your client application.&lt;br/&gt;        Now create the external configuration file. It may look like following:&lt;br/&gt;        &lt;pre&gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;br/&gt;&amp;lt;configuration&amp;gt;&lt;br/&gt;  &amp;lt;system.serviceModel&amp;gt;&lt;br/&gt;    &amp;lt;extensions&amp;gt;&lt;br/&gt;      &amp;lt;behaviorExtensions&amp;gt;&lt;br/&gt;        &amp;lt;add name="ExtendedServiceEndpointBehavior" type="ExtendingWCFPartI.WcfExtentions.ServiceBehaviorExtension, ExtendingWCFPartI.WcfExtentions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/&amp;gt;&lt;br/&gt;      &amp;lt;/behaviorExtensions&amp;gt;&lt;br/&gt;&lt;br/&gt;    &amp;lt;/extensions&amp;gt;&lt;br/&gt;    &amp;lt;bindings&amp;gt;&lt;br/&gt;        .. tips: provide the same binding which has been used at service&lt;br/&gt;    &amp;lt;/bindings&amp;gt;&lt;br/&gt;    &amp;lt;behaviors&amp;gt;&lt;br/&gt;      &amp;lt;endpointBehaviors&amp;gt;&lt;br/&gt;        &amp;lt;behavior name="CustomServiceEndpointBehavior"&amp;gt;&lt;br/&gt;&lt;br/&gt;          &amp;lt;ExtendedServiceEndpointBehavior /&amp;gt;&lt;br/&gt;        &amp;lt;/behavior&amp;gt;&lt;br/&gt;      &amp;lt;/endpointBehaviors&amp;gt;&lt;br/&gt;    &amp;lt;/behaviors&amp;gt;&lt;br/&gt;    &amp;lt;client&amp;gt;&lt;br/&gt;      &amp;lt;endpoint address="http://localhost:8036/Services/CustomerService"&lt;br/&gt;          binding="wsHttpBinding" bindingConfiguration="CustomWSHttpBinding" &lt;br/&gt;          behaviorConfiguration="CustomServiceEndpointBehavior" &lt;br/&gt;          contract="ExtendingWCFPartI.Common.Services.ICustomerService" name="CustomerServiceEndPoint" /&amp;gt;&lt;br/&gt;&lt;br/&gt;    &amp;lt;/client&amp;gt;&lt;br/&gt;  &amp;lt;/system.serviceModel&amp;gt;&lt;br/&gt;&amp;lt;/configuration&amp;gt;&lt;br/&gt;        &lt;/pre&gt;&lt;br/&gt;        Now save this external configuration file at any location of your hard drive with&lt;br/&gt;        .xml or .config extension. e.g. "C:\Temp\MyAppServices.xml".&lt;br/&gt;        I've provided a very simple inerface ExtendingWCFPartI.WcfExtentions.WcfClientHelper&lt;br/&gt;        to get the instance of proxy.&lt;br/&gt;        &lt;pre&gt;&lt;br/&gt;public static T GetProxy&amp;lt;T&amp;gt;(string externalConfigPath)&lt;br/&gt;{&lt;br/&gt;    var channelFactory = new ExtendedChannelFactory&amp;lt;T&amp;gt;(externalConfigPath);&lt;br/&gt;    channelFactory.Open();&lt;br/&gt;    return channelFactory.CreateChannel();&lt;br/&gt;}&lt;br/&gt;        &lt;/pre&gt;&lt;br/&gt;&lt;br/&gt;        At client code use this interface to call your service method:&lt;br/&gt;        &lt;pre&gt;&lt;br/&gt;var externalConfigPath = @"C:\Temp\MyAppServices.xml";&lt;br/&gt;var proxy = WcfClientHelper.GetProxy&amp;lt;IMyWCFService&amp;gt;(externalConfigPath);&lt;br/&gt;proxy.CallServiceMethod();&lt;br/&gt;        &lt;/pre&gt;&lt;br/&gt;    &lt;/p&gt;&lt;br/&gt;    &lt;h2&gt;&lt;br/&gt;        Points of Interest&lt;/h2&gt;&lt;br/&gt;    &lt;p&gt;&lt;br/&gt;        There are many more extension points at WCF framework which are very interesting&lt;br/&gt;        and usefull. I'll try my best to cover few more examples later in my next article.&lt;br/&gt;        In brief, I found the WCF framework so well designed that programmers have almost&lt;br/&gt;        all the options to do whatever he wants.&lt;br/&gt;    &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-2722388921697378875?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/2722388921697378875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/2722388921697378875'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2009/11/extending-wcf-part-i.html' title='Extending WCF Part I'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-1745538145150272402</id><published>2009-11-04T02:29:00.000-08:00</published><updated>2010-05-29T01:38:40.924-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Designing'/><category scheme='http://www.blogger.com/atom/ns#' term='Coding'/><title type='text'>Designer = can do XAML !!!</title><content type='html'>&lt;p&gt;Sunday, October 25, 2009&lt;br/&gt;&lt;/p&gt;&lt;br/&gt;&lt;p&gt;It means a combination of “Creativity and Coding”. Yes now a Designer can be a coder as well. Perhaps you are thinking that it’s a crap :-). Nope it is real. I never wanted to go to the programming world. I think it is a bit boring and monotonous for a designer. Some couple of month back our CTO comes and requested me to learn XAML. He explained all the prospects of XAML in a positive mode. At that time I was thinking that what my CTO is saying is truly a fantasy web world. One question was hitting repeatedly in my mind and that is “CAN I DO THAT?”. &lt;/p&gt;&lt;br/&gt;&lt;p&gt;Yes XAML is truly a fantasy playground for a designer. After getting 2 months successful training (Thanks to our CTO and special thanks to Taufiq for being an excellent XAML teacher) on XAML I got the confident and started doing coding immediately with the other developers :-). Ok cut off the story of mine and let discuss the prospect of XAML.&lt;/p&gt;&lt;br/&gt;&lt;p&gt;XAML is a new descriptive programming language developed by Microsoft to write user interfaces for next generation managed applications. Extensible Application Markup Language or is a new declarative language that is used in Windows Framework and Windows Presentation Foundation. Introduced with .NET Framework 3.0, XAML is harbinger of declarative (in contrast with imperative using coding) programming model. In Workflow Foundation, workflows can be created using code as well as XAML. Even fully XAML-based solutions are possible with no code at all! This not only gives flexibility of no-compilation-needed to applications, it also opens up a window of possibility for entirely non-technical persons (like business analysts) to design workflows. (Though Workflow Foundation is targeted for programmers, experiments are underway around the globe for making it feasible for business analysts to model processes in it).&lt;/p&gt;&lt;br/&gt;&lt;p&gt;Let me ask a simple question. Can you build a Combo box on a button? Or can you customize a button for a Combo box? Very difficult or even not possible in other programming languages but it can be done in XAML with a few lines of code. So a Designer can play around wherever he/she wants to. So the bottom line is Designer can now think out of the box, can do outstanding mockups for web or desktop application. &lt;/p&gt;&lt;br/&gt;&lt;p&gt;&lt;a href='http://www.kaz.com.bd/blog/index.php/?attachment_id=37' rel='attachment wp-att-37' title='xaml.jpg'&gt;&lt;img src='http://www.kaz.com.bd/blog/wp-content/uploads/2009/11/xaml.jpg' alt='xaml.jpg' /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br/&gt;&lt;p&gt;For XAML, we need to have a basic knowledge on XML, CSS. You will get lot of tutorials for XAML on the net. So learn XAML and discover the future.&lt;/p&gt;&lt;br/&gt;&lt;p&gt;Enjoy!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-1745538145150272402?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/1745538145150272402'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/1745538145150272402'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2009/11/designer-can-do-xaml.html' title='Designer = can do XAML !!!'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-3711592878818386903</id><published>2009-03-12T05:22:00.000-07:00</published><updated>2010-05-29T01:38:40.927-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Picnic'/><title type='text'>Shadows of Sinensis</title><content type='html'>- Md. Ferdous Bhuiyan&lt;br/&gt;&lt;br/&gt;&lt;img src="http://www.kaz.com.bd/blog/userpic/sos/p2.jpg" alt="Shadows of Sinensis" /&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Shadows of Sinensis&lt;/strong&gt;, a memorable trip to Srimongol, will remain afresh in the mind of Kaz family.  Fun-loving Kaz Family went on rampage to obtain unlimited ‘Furti’ and relaxation during our 3-day tour to Srimongol from 15 to 17 February, 2009. Eventful Srimongol trip offered us relaxation, fun and most importantly the joy to share with our colleagues and family members. The team of Srimongol trip encompasses each and every one of Kaz Family. Young stars of the team aged 3-month to 3-year provided the team with pure and refreshing entertainment in the lap of nature. All of us along with our spouses and kids looted the unlimited joy by swimming in the pool, climbing the mountains, wandering in the wilderness and having delicious foods.&lt;br/&gt;&lt;br/&gt;&lt;img src="http://www.kaz.com.bd/blog/userpic/sos/p1.jpg" alt="Shadows of Sinensis" /&gt;&lt;br/&gt;&lt;br/&gt;Powered by 41-member, Kaz team reveals the sportive frenzy of Kaz family. Many of our enthusiastic players as well as cheering audiences enjoyed watching and playing Cricket, Badminton, Football and Table Tennis at daylight and even at night using light. Frenzied bedding accompanied by enthusiastic cheering gave the events a special glow.   &lt;br/&gt;Silence of the evenings was shattered with the sound of laughter provoked by lively ‘Adda’ and the melody of harmonica and songs sung by us ruled the isolation of night. Monotony or tiered is something that failed to touch the mind even for a second. Luxurious and well-furnished bungalows became the place to spend last few hours of night to start a new day with more enthusiasm.&lt;br/&gt;&lt;br/&gt;&lt;img src="http://www.kaz.com.bd/blog/userpic/sos/p3.jpg" alt="Shadows of Sinensis" /&gt;&lt;br/&gt;&lt;br/&gt;A spur-of-the-moment decision fixed the day scheduled. Going to ‘Lawachara’ or finding out the tea-stall named ‘Nilkantha’ to have multilayered tea was decided within a few minutes with the urge to know the unknown. Such whimsical decisions to visit outside of the Tea Resort made the trip more attractive and gave us the chance to experience something new and adventurous. Those who were more attracted to water of appealing swimming pool were busy with swimming and diving throughout the whole noon. &lt;br/&gt;Delicious Food must be there to color a memorable time. We the KAZ people vowed not to get hungry and have delicious good food with every single chance of celebrating party. There is no exception of this oath even at Srimongol trip. Being the fan of delicious food we grilled chicken and included delicious dishes for a sensational dinner and enjoyed the last night having spicy food and dessert.  &lt;br/&gt;&lt;br/&gt;&lt;img src="http://www.kaz.com.bd/blog/userpic/sos/p4.jpg" alt="Shadows of Sinensis" /&gt;&lt;br/&gt;&lt;br/&gt;Sensible traditional ethos of our firm revives with this lovely trip. And it would be no rhetoric to reiterate the truth that ‘Shadows of Sinensis’ is a great step forward for the neatly tied Kaz family to enhance its fellow-feelings and team spirit as ever.&lt;br/&gt;&lt;br/&gt;&lt;img src="http://www.kaz.com.bd/blog/userpic/sos/p7.jpg" alt="Shadows of Sinensis" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-3711592878818386903?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/3711592878818386903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/3711592878818386903'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2009/03/shadows-of-sinensis.html' title='Shadows of Sinensis'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-5199026430787645628</id><published>2008-07-31T05:15:00.000-07:00</published><updated>2010-05-29T01:38:40.930-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Adventures'/><category scheme='http://www.blogger.com/atom/ns#' term='Anniversary Party'/><title type='text'>Emperors on the move</title><content type='html'>At last August his here!&lt;br/&gt;&lt;br/&gt;August at Kaz is the long awaited month of the anniversary party! (Kaz actually started in June, but we do the anniversary party in August because it fits with the software world's tendency of taking it easy in August worldwide!)&lt;br/&gt;&lt;br/&gt;This year we are off to the great triangle trip of Delhi - Agra and Jaipur. The trip is code named "Emperors on the move!"&lt;br/&gt;&lt;br/&gt;Ten days of non-stop furti!&lt;br/&gt;&lt;br/&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2008/07/main_design.jpg" title="Emperors on the move"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/2008/07/main_design.jpg" alt="Emperors on the move" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-5199026430787645628?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/5199026430787645628'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/5199026430787645628'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2008/07/emperors-on-move.html' title='Emperors on the move'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-8305781369040737680</id><published>2008-03-29T06:25:00.000-07:00</published><updated>2010-05-29T01:38:40.934-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Coding'/><title type='text'>Home Made Java Virtual Machine</title><content type='html'>&lt;style&gt; PRE { 	PADDING-RIGHT: 7pt; PADDING-LEFT: 7pt; PADDING-BOTTOM: 7pt; FONT: 9pt "Courier New", Courier, mono; OVERFLOW: auto; PADDING-TOP: 7pt; WHITE-SPACE: pre; BACKGROUND-COLOR: #fbedbb } CODE { 	FONT-SIZE: 11pt; COLOR: #990000; FONT-FAMILY: "Courier New" , Courier, mono } &lt;/style&gt;&lt;br/&gt;&lt;h3&gt;by Maruf Maniruzzaman&lt;/h3&gt;&lt;br/&gt;&lt;!-- Start Article --&gt;&lt;br/&gt;&lt;ul class="Download"&gt;&lt;br/&gt;	&lt;li&gt;&lt;a href="http://www.kazresource.com/blog/wp-content/uploads/2008/02/kjvm.zip" target="_blank"&gt;Download JVM Source Code kjvm.zip - 39.65 KB&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;	&lt;li&gt;&lt;a href="http://www.kazresource.com/blog/wp-content/uploads/2008/02/seminar.zip" target="_blank"&gt;Download seminar presentation - 229.95 KB&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;&lt;/ul&gt;&lt;br/&gt;&lt;h2&gt;Introduction&lt;/h2&gt;&lt;br/&gt;Back in year 2004 I had to choose a thesis topic as a prerequisite of completion of my undergraduate course in&lt;br/&gt;Computer Science and Engineering. I had choosen Process Migration. And our teacher Mahmud Shahriar Hossain agreed to&lt;br/&gt;supervise my work. My partner was Md. Helal Uddin. As part of the thesis I had to implement a Java Virtual Machine.&lt;br/&gt;I wanted to write an article since then. But it never actually happened. Today (March 2) is my birth day and&lt;br/&gt;I want to start it. The virtual machine is also used in my new&lt;br/&gt;project &lt;a href="http://morpheus.kuashaonline.com/" target="_blank"&gt;Morpheus &lt;/a&gt;- a prototype of Silverlight 1.1.&lt;br/&gt;The seminar presentation downloadable from above link shows how a JVM works. You may also look at the JVM&lt;br/&gt;source code from above link. Please note that most the implementation decision taken may not match with other&lt;br/&gt;commercially available JVM implementation. Whenever JVM Spec is found to say nothing, the most easiest approach&lt;br/&gt;is taken to save time.&lt;br/&gt;&lt;h2&gt;Java Virtual Machine Parts&lt;/h2&gt;&lt;br/&gt;&lt;img src="http://www.kaz.com.bd/blog/userpic/jvm_parts.jpg" /&gt;&lt;br/&gt;&lt;h2&gt;Class File Structure&lt;/h2&gt;&lt;br/&gt;The java virtual machine needs an application that is made up of collection of java classes. At the beginning of any&lt;br/&gt;class there is a defined structure like &lt;code&gt;JavaClassFileFormat&lt;/code&gt;.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;     struct  JavaClassFileFormat&lt;br/&gt;     {&lt;br/&gt;         u4 magic;&lt;br/&gt;         u2 minor_version;&lt;br/&gt;         u2 major_version;&lt;br/&gt;         u2 constant_pool_count;&lt;br/&gt;         cp_info **constant_pool; //[constant_pool_count-1];&lt;br/&gt;         u2 access_flags;&lt;br/&gt;         u2 this_class;&lt;br/&gt;         u2 super_class;&lt;br/&gt;         u2 interfaces_count;&lt;br/&gt;         u2* interfaces; //[interfaces_count];&lt;br/&gt;         u2 fields_count;&lt;br/&gt;         field_info_ex *fields; //[fields_count];&lt;br/&gt;         u2 methods_count;&lt;br/&gt;         method_info_ex* methods; //[methods_count];&lt;br/&gt;         u2 attributes_count;&lt;br/&gt;         attribute_info** attributes; //[attributes_count];&lt;br/&gt;     };&lt;/pre&gt;&lt;br/&gt;Following are the structures used in the format. They represents constant pool (constant values used in class files), fields,&lt;br/&gt;methods and attributes in a class file. I'll describe them in details later.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;     struct cp_info&lt;br/&gt;     {&lt;br/&gt;         u1 tag;&lt;br/&gt;         u1* info;&lt;br/&gt;     }; &lt;br/&gt;&lt;br/&gt;     struct field_info&lt;br/&gt;     {&lt;br/&gt;         u2 access_flags;&lt;br/&gt;         u2 name_index;&lt;br/&gt;         u2 descriptor_index;&lt;br/&gt;         u2 attributes_count;&lt;br/&gt;         attribute_info* attributes; //[attributes_count];&lt;br/&gt;     }; &lt;br/&gt;&lt;br/&gt;     struct method_info&lt;br/&gt;     {&lt;br/&gt;         u2 access_flags;&lt;br/&gt;         u2 name_index;&lt;br/&gt;         u2 descriptor_index;&lt;br/&gt;         u2 attributes_count;&lt;br/&gt;         attribute_info* attributes; //[attributes_count];&lt;br/&gt;     }; &lt;br/&gt;&lt;br/&gt;     struct attribute_info&lt;br/&gt;     {&lt;br/&gt;         u2 attribute_name_index;&lt;br/&gt;         u4 attribute_length;&lt;br/&gt;         u1* info;//[attribute_length];&lt;br/&gt;     };&lt;/pre&gt;&lt;br/&gt;We first load the class file in memory as raw byte and then use &lt;code&gt;JavaClass&lt;/code&gt; object to parse the raw bytes&lt;br/&gt;and identify the fields, methods, exception table etc. The &lt;code&gt;JavaClass&lt;/code&gt; class represent a class in memory in&lt;br/&gt;structured form. It holds a pointer to the raw byte  stream that was loaded from class file.&lt;br/&gt;&lt;h2&gt;Java Class in Memory&lt;/h2&gt;&lt;br/&gt;Here we just inherit the &lt;code&gt;JavaClassFileFormat&lt;/code&gt; for simplicity of storing the values in in memory class&lt;br/&gt;representation. We must parse the raw class file in memory to get the values for &lt;code&gt;JavaClassFileFormat&lt;/code&gt; fields.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;	class JavaClass: public JavaClassFileFormat&lt;br/&gt;	{&lt;br/&gt;	public:&lt;br/&gt;		JavaClass(void);&lt;br/&gt;		virtual ~JavaClass(void);&lt;br/&gt;&lt;br/&gt;	public:&lt;br/&gt;		virtual BOOL LoadClassFromFile(CString lpszFilePath);&lt;br/&gt;		void SetByteCode(void* pByteCode);&lt;br/&gt;&lt;br/&gt;		BOOL ParseClass(void);&lt;br/&gt;		BOOL ParseInterfaces(char* &amp;amp;p);&lt;br/&gt;		BOOL ParseFields(char* &amp;amp;p);&lt;br/&gt;		BOOL ParseMethods(char* &amp;amp;p);&lt;br/&gt;		BOOL ParseAttributes(char* &amp;amp;p);&lt;br/&gt;		BOOL GetConstantPool(u2 nIndex, cp_info&amp;amp; const_pool);&lt;br/&gt;&lt;br/&gt;		BOOL GetStringFromConstPool(int nIndex,CString&amp;amp; strValue);&lt;br/&gt;		CString GetName(void);&lt;br/&gt;		CString GetSuperClassName(void);&lt;br/&gt;		BOOL ParseMethodCodeAttribute(int nMethodIndex, Code_attribute* pCode_attr);&lt;br/&gt;		int GetMethodIndex(CString strMethodName, CString strMethodDesc,JavaClass* &amp;amp;pClass);&lt;br/&gt;		int GetFieldIndex(CString strName, CString&amp;amp; strDesc);&lt;br/&gt;		void SetClassHeap(ClassHeap *pClassHeap){this-&amp;gt;m_pClassHeap=pClassHeap;}&lt;br/&gt;		virtual u4 GetObjectSize(void);&lt;br/&gt;		virtual u4 GetObjectFieldCount(void);&lt;br/&gt;		JavaClass* GetSuperClass(void);&lt;br/&gt;		BOOL CreateObject(u2 index, ObjectHeap *pObjectHeap, Object&amp;amp; object);&lt;br/&gt;		BOOL CreateObjectArray(u2 index, u4 count, ObjectHeap *pObjectHeap, Object&amp;amp; object);&lt;br/&gt;	private:&lt;br/&gt;		size_t m_nByteCodeLength;&lt;br/&gt;		void *m_pByteCode;&lt;br/&gt;		u2	m_nObjectFieldsCount;&lt;br/&gt;		BOOL ParseConstantPool(char* &amp;amp;p);&lt;br/&gt;		int GetConstantPoolSize(char* p);&lt;br/&gt;		ClassHeap *m_pClassHeap;&lt;br/&gt;	};&lt;/pre&gt;&lt;br/&gt;To do that we first load the file in memory and then call the &lt;code&gt;ParseClass&lt;/code&gt; method which is shown&lt;br/&gt;in the next section.&lt;br/&gt;&lt;h2&gt;Class Loader&lt;/h2&gt;&lt;br/&gt;As there are some variable length fields it is not possible to directly load the structure. So we load the&lt;br/&gt;values one by one. First we load the value of magic which is an unsigned integer (u4) value. It must be value&lt;br/&gt;of 0xCafeBabe. If it is not the class file may be either corrupted or not a java class file at all. Then we&lt;br/&gt;load other values and structures. To load structures we first load the count and then load the structure.&lt;br/&gt;For example first we load short (u2) value constant_pool_count and then load that number of constant pool.&lt;br/&gt;To parse I used definitions getu4(p) or similar which just picks 4 bytes starting at p and returns the unsigned&lt;br/&gt;int value. To parse structures hare use sepaate methods like &lt;code&gt;ParseConstantPool&lt;/code&gt;.&lt;br/&gt;It takes the &lt;em&gt;reference&lt;/em&gt; of the byte stream pointer and increments in that class. I did this only for simplicity.&lt;br/&gt;It would be more readable if I'd return the total length and increent in ParseClass method but that would me less managable.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;	BOOL JavaClass::ParseClass(void )&lt;br/&gt;	{&lt;br/&gt;		//just to be safe&lt;br/&gt;		if (m_pByteCode==NULL ||&lt;br/&gt;				m_nByteCodeLength &amp;lt; sizeof (JavaClassFileFormat)+20)&lt;br/&gt;			return FALSE;&lt;br/&gt;		char *p=( char *)m_pByteCode;&lt;br/&gt;		magic = getu4(p); p+=4;&lt;br/&gt;		ASSERT(magic == 0xCAFEBABE); &lt;br/&gt;&lt;br/&gt;		if(magic != 0xCAFEBABE)&lt;br/&gt;			return FALSE;&lt;br/&gt;&lt;br/&gt;		minor_version=getu2(p); p+=2;&lt;br/&gt;		major_version=getu2(p); p+=2;&lt;br/&gt;		constant_pool_count=getu2(p); p+=2; &lt;br/&gt;&lt;br/&gt;		if (constant_pool_count&amp;gt;0)&lt;br/&gt;			ParseConstantPool(p); &lt;br/&gt;&lt;br/&gt;		access_flags=getu2(p); p+=2;&lt;br/&gt;		this_class=getu2(p); p+=2;&lt;br/&gt;		super_class=getu2(p); p+=2;&lt;br/&gt;		interfaces_count=getu2(p); p+=2; &lt;br/&gt;&lt;br/&gt;		if (interfaces_count&amp;gt;0)&lt;br/&gt;			ParseInterfaces(p); &lt;br/&gt;&lt;br/&gt;		fields_count=getu2(p); p+=2; &lt;br/&gt;&lt;br/&gt;		if (fields_count &amp;gt; 0)&lt;br/&gt;			ParseFields(p); &lt;br/&gt;&lt;br/&gt;		methods_count = getu2(p);p+=2; &lt;br/&gt;&lt;br/&gt;		if (methods_count &amp;gt; 0)&lt;br/&gt;		{&lt;br/&gt;			ParseMethods(p);&lt;br/&gt;		}&lt;br/&gt;		attributes_count = getu2(p);p+=2; &lt;br/&gt;&lt;br/&gt;		if (attributes_count &amp;gt; 0)&lt;br/&gt;			ParseAttributes(p); &lt;br/&gt;&lt;br/&gt;		return 0;&lt;br/&gt;	}&lt;/pre&gt;&lt;br/&gt;&lt;h2&gt;Constant Pool&lt;/h2&gt;&lt;br/&gt;In a java class several constant value is stored. It stores numeric, string and reference values&lt;br/&gt;in a pool and those are used in  machine codes known as 'Java Byte Code'. Constant pool contains&lt;br/&gt;constant_pool_count items in a sequential list of following structure.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct cp_info&lt;br/&gt;    {&lt;br/&gt;	    u1 tag;&lt;br/&gt;        u1* info;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;Constant pool information structure starts with one byte of tag information that&lt;br/&gt;indicates the type of the constant pool. Constant pool structure length is variable&lt;br/&gt;depending on the type of constant. Constant pool tag value can be one of the&lt;br/&gt;following values depending on the type of constant.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    #define CONSTANT_Integer  3&lt;br/&gt;    #define CONSTANT_Float  4&lt;br/&gt;    #define CONSTANT_Long  5&lt;br/&gt;    #define CONSTANT_Double  6&lt;br/&gt;    #define CONSTANT_Utf8  1&lt;br/&gt;    #define CONSTANT_String  8  &lt;br/&gt;&lt;br/&gt;    #define CONSTANT_Class  7&lt;br/&gt;    #define CONSTANT_Fieldref  9&lt;br/&gt;    #define CONSTANT_Methodref  10&lt;br/&gt;    #define CONSTANT_InterfaceMethodref  11&lt;br/&gt;    #define CONSTANT_NameAndType  12&lt;/pre&gt;&lt;br/&gt;Depending on the value of tag we can cast the cp_info structure in more precise&lt;br/&gt;structures listed here.&lt;br/&gt;&lt;h3&gt;CONSTANT_Integer_info&lt;/h3&gt;&lt;br/&gt;If tag value equals &lt;code&gt;CONSTANT_Integer&lt;/code&gt; in cp_info structure then it is an integer&lt;br/&gt;constant. We can cast the cp_info structure in following structure.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct CONSTANT_Integer_info {&lt;br/&gt;        u1 tag;&lt;br/&gt;        u4 bytes;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;This structure does not have any reference to any other constant. It represents&lt;br/&gt;direct 4 byte integer value.&lt;br/&gt;&lt;h3&gt;CONSTANT_Float_info&lt;/h3&gt;&lt;br/&gt;If tag value equals &lt;code&gt;CONSTANT_Float&lt;/code&gt; in cp_info structure then it is a float&lt;br/&gt;constant. We can cast the cp_info structure in following structure.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct CONSTANT_Float_info {&lt;br/&gt;        u1 tag;&lt;br/&gt;        u4 bytes;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;It is a direct value constant without any reference.&lt;br/&gt;&lt;h3&gt;CONSTANT_Long_info&lt;/h3&gt;&lt;br/&gt;If tag value equals &lt;code&gt;CONSTANT_Long&lt;/code&gt; in cp_info structure then it is a long&lt;br/&gt;constant. We can cast the cp_info structure in following structure.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct CONSTANT_Long_info {&lt;br/&gt;        u1 tag;&lt;br/&gt;        u4 high_bytes;&lt;br/&gt;        u4 low_bytes;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;It is a direct value constant without any reference. It uses two four bute values&lt;br/&gt;to construct the 8 byte long value.&lt;br/&gt;&lt;h3&gt;CONSTANT_Long_info&lt;/h3&gt;&lt;br/&gt;If tag value equals &lt;code&gt;CONSTANT_Double&lt;/code&gt; in cp_info structure then it is a double&lt;br/&gt;constant. We can cast the cp_info structure in following structure.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct CONSTANT_Double_info {&lt;br/&gt;        u1 tag;&lt;br/&gt;        u4 high_bytes;&lt;br/&gt;        u4 low_bytes;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;It is a direct value constant without any reference. It uses two four bute values&lt;br/&gt;to construct the 8 byte double value.&lt;br/&gt;&lt;h3&gt;CONSTANT_Utf8_info&lt;/h3&gt;&lt;br/&gt;If tag value equals &lt;code&gt;CONSTANT_Utf8&lt;/code&gt; in cp_info structure then it is a utf8 string&lt;br/&gt;constant. We can cast the cp_info structure in following structure.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct CONSTANT_Utf8_info {&lt;br/&gt;        u1 tag;&lt;br/&gt;        u2 length;&lt;br/&gt;        u1* bytes;//[length];&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;It is a direct value constant without any reference. The short value &lt;code&gt;length&lt;/code&gt; defines&lt;br/&gt;the length of the byte array followed by &lt;code&gt;length&lt;/code&gt; number of bytes.&lt;br/&gt;&lt;h3&gt;CONSTANT_String_info&lt;/h3&gt;&lt;br/&gt;If tag value equals &lt;code&gt;CONSTANT_String&lt;/code&gt; in cp_info structure then it is a string &lt;em&gt;reference&lt;/em&gt;&lt;br/&gt;constant. We can cast the cp_info structure in following structure.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct CONSTANT_String_info {&lt;br/&gt;        u1 tag;&lt;br/&gt;        u2 string_index;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;It is a reference value constant. The short value &lt;code&gt;string_index&lt;/code&gt; refers&lt;br/&gt;to a &lt;code&gt;CONSTANT_Utf8_info&lt;/code&gt; index in the constant pool.&lt;br/&gt;&lt;h3&gt;CONSTANT_Class_info&lt;/h3&gt;&lt;br/&gt;If tag value equals &lt;code&gt;CONSTANT_Class&lt;/code&gt; in cp_info structure then it is a class &lt;em&gt;reference&lt;/em&gt;&lt;br/&gt;constant. We can cast the cp_info structure in following structure.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct CONSTANT_Class_info {&lt;br/&gt; 	    u1 tag;&lt;br/&gt;   	    u2 name_index;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;It is a reference value constant. The short value &lt;code&gt;name_index&lt;/code&gt; refers&lt;br/&gt;to a &lt;code&gt;CONSTANT_Utf8_info&lt;/code&gt; index in the constant pool that is the fully&lt;br/&gt;qualified name (ie &lt;code&gt;java/lang/String&lt;/code&gt;) of the class- dot replaced by&lt;br/&gt;slash.&lt;br/&gt;&lt;h3&gt;CONSTANT_Fieldref_info&lt;/h3&gt;&lt;br/&gt;If tag value equals &lt;code&gt;CONSTANT_Fieldref&lt;/code&gt; in cp_info structure then&lt;br/&gt;it is a field &lt;em&gt;reference&lt;/em&gt; constant. We can cast the cp_info structure&lt;br/&gt;in following structure.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct CONSTANT_Fieldref_info {&lt;br/&gt;        u1 tag;&lt;br/&gt;        u2 class_index;&lt;br/&gt;        u2 name_and_type_index;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;It is a reference value constant. The short value &lt;code&gt;class_index&lt;/code&gt; refers&lt;br/&gt;to a &lt;code&gt;CONSTANT_Class_info&lt;/code&gt; index in the constant pool and&lt;br/&gt;&lt;code&gt;name_and_type_index&lt;/code&gt; refers to a string index in the constant pool that&lt;br/&gt;is the fully qualified name (ie &lt;code&gt;java/lang/String@valueOf(F)Ljava/lang/String;&lt;/code&gt;)&lt;br/&gt;of the class- dot replaced by slash.&lt;br/&gt;&lt;h3&gt;CONSTANT_Methodref_info&lt;/h3&gt;&lt;br/&gt;If tag value equals &lt;code&gt;CONSTANT_Methodref&lt;/code&gt; in cp_info structure then&lt;br/&gt;it is a method &lt;em&gt;reference&lt;/em&gt; constant. We can cast the cp_info structure&lt;br/&gt;in following structure.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct CONSTANT_Methodref_info {&lt;br/&gt;        u1 tag;&lt;br/&gt;        u2 class_index;&lt;br/&gt;        u2 name_and_type_index;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;It is a reference value constant. The short value &lt;code&gt;class_index&lt;/code&gt; refers&lt;br/&gt;to a &lt;code&gt;CONSTANT_Class_info&lt;/code&gt; index in the constant pool and&lt;br/&gt;&lt;code&gt;name_and_type_index&lt;/code&gt; refers to a string index in the constant pool that&lt;br/&gt;is the fully qualified name (ie &lt;code&gt;java/lang/String@valueOf(F)Ljava/lang/String;&lt;/code&gt;)&lt;br/&gt;of the class- dot replaced by slash.&lt;br/&gt;&lt;h3&gt;CONSTANT_InterfaceMethodref_info&lt;/h3&gt;&lt;br/&gt;If tag value equals &lt;code&gt;CONSTANT_InterfaceMethodref&lt;/code&gt; in cp_info structure then&lt;br/&gt;it is an interface method &lt;em&gt;reference&lt;/em&gt; constant. We can cast the cp_info structure&lt;br/&gt;in following structure.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct CONSTANT_InterfaceMethodref_info {&lt;br/&gt;        u1 tag;&lt;br/&gt;        u2 class_index;&lt;br/&gt;        u2 name_and_type_index;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;It is a reference value constant. The short value &lt;code&gt;class_index&lt;/code&gt; refers&lt;br/&gt;to a &lt;code&gt;CONSTANT_Class_info&lt;/code&gt; index in the constant pool and&lt;br/&gt;&lt;code&gt;name_and_type_index&lt;/code&gt; refers to a string index in the constant pool that&lt;br/&gt;is the fully qualified name (ie &lt;code&gt;java/lang/String@valueOf(F)Ljava/lang/String;&lt;/code&gt;)&lt;br/&gt;of the class- dot replaced by slash.&lt;br/&gt;&lt;h3&gt;CONSTANT_NameAndType_info&lt;/h3&gt;&lt;br/&gt;If tag value equals &lt;code&gt;CONSTANT_NameAndType&lt;/code&gt; in cp_info structure then&lt;br/&gt;it is an interface method &lt;em&gt;reference&lt;/em&gt; constant. We can cast the cp_info structure&lt;br/&gt;in following structure.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct CONSTANT_NameAndType_info {&lt;br/&gt;        u1 tag;&lt;br/&gt;        u2 name_index;&lt;br/&gt;        u2 descriptor_index;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;It is a reference value constant. The short value &lt;code&gt;name_index&lt;/code&gt; refers&lt;br/&gt;to a string index in the constant pool and &lt;code&gt;descriptor_index&lt;/code&gt; refers to another&lt;br/&gt;string index in the constant pool.&lt;br/&gt;&lt;h3&gt;Parsing constant pool&lt;/h3&gt;&lt;br/&gt;Here we set the values of constant pool list pointers. When we need to retrieve the&lt;br/&gt;actual value we look at the tag and pick the value directly.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    BOOL JavaClass::ParseConstantPool(char* &amp;amp;p)&lt;br/&gt;    {&lt;br/&gt;        constant_pool = new cp_info*[constant_pool_count-1];&lt;br/&gt;        if(constant_pool == NULL) return FALSE;&lt;br/&gt;        for(int i=1;i&amp;lt;constant_pool_count;i++)&lt;br/&gt;        {&lt;br/&gt;            //We set the constant pointer here&lt;br/&gt;            constant_pool[i]=(cp_info*)p;&lt;br/&gt;&lt;br/&gt;            //We now calculate constant size. If it is an integer we get size = 5&lt;br/&gt;            int size = GetConstantPoolSize(p);&lt;br/&gt;            p+= size;&lt;br/&gt;&lt;br/&gt;            // If constant type is long or double constant pool takes two entries. Second entry&lt;br/&gt;            // is not used by virtual machine but kept NULL to walk constant pool correctly.&lt;br/&gt;            if(constant_pool[i]-&amp;gt;tag == CONSTANT_Long || constant_pool[i]-&amp;gt;tag == CONSTANT_Double)&lt;br/&gt;            {&lt;br/&gt;                constant_pool[i+1]=NULL;&lt;br/&gt;                i++;&lt;br/&gt;            }&lt;br/&gt;        }&lt;br/&gt;        return TRUE;&lt;br/&gt;    }&lt;/pre&gt;&lt;br/&gt;&lt;h2&gt;Interfaces&lt;/h2&gt;&lt;br/&gt;In the &lt;code&gt;interfaces&lt;/code&gt; field of a class there are &lt;code&gt;interfaces_count&lt;/code&gt;&lt;br/&gt;number of short (u2) values. Each value is a &lt;em&gt;reference&lt;/em&gt; to a constant pool entry&lt;br/&gt;of type &lt;code&gt;CONSTANT_Class&lt;/code&gt;. We parse them and store in our in-memory object-&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    BOOL JavaClass::ParseInterfaces(char* &amp;amp;p)&lt;br/&gt;    {&lt;br/&gt;        interfaces = new u2[interfaces_count];&lt;br/&gt;        for(int i=0;i&amp;lt;interfaces_count;i++)&lt;br/&gt;        {&lt;br/&gt;            interfaces[i] = getu2(p); p+=2;&lt;br/&gt;        }&lt;br/&gt;&lt;br/&gt;        return TRUE;&lt;br/&gt;    }&lt;/pre&gt;&lt;br/&gt;&lt;h2&gt;Fields&lt;/h2&gt;&lt;br/&gt;A class may contain zero, one or more fields. The actual number is stored in the&lt;br/&gt;&lt;code&gt;fields_count&lt;/code&gt; field. A list of &lt;code&gt;field_info&lt;/code&gt; structure followes&lt;br/&gt;this value.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct field_info&lt;br/&gt;    {&lt;br/&gt;	    u2 access_flags;&lt;br/&gt;        u2 name_index;&lt;br/&gt;        u2 descriptor_index;&lt;br/&gt;        u2 attributes_count;&lt;br/&gt;        attribute_info* attributes;//[attributes_count];&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;The short value &lt;code&gt;access_flags&lt;/code&gt; describes the allowed field access. Here is&lt;br/&gt;the possible access flags values which is shared also by methods and classes-&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    #define ACC_PUBLIC  0x0001&lt;br/&gt;    /*Declared public; may be accessed from outside its package.  */&lt;br/&gt;&lt;br/&gt;    #define ACC_PRIVATE  0x0002&lt;br/&gt;    /*Declared private; accessible only within the defining class.  */&lt;br/&gt;&lt;br/&gt;    #define ACC_PROTECTED  0x0004&lt;br/&gt;    /*Declared protected; may be accessed within subclasses.  */&lt;br/&gt;&lt;br/&gt;    #define ACC_STATIC  0x0008  /*Declared static.  */&lt;br/&gt;&lt;br/&gt;    #define ACC_FINAL  0x0010&lt;br/&gt;    /*Declared final; may not be overridden.  */&lt;br/&gt;&lt;br/&gt;    #define ACC_SYNCHRONIZED  0x0020&lt;br/&gt;    /*Declared synchronized; invocation is wrapped in a monitor lock.  */&lt;br/&gt;&lt;br/&gt;    #define ACC_NATIVE  0x0100&lt;br/&gt;    /*Declared native; implemented in a language other than Java.  */&lt;br/&gt;&lt;br/&gt;    #define ACC_ABSTRACT  0x0400&lt;br/&gt;    /*Declared abstract; no implementation is provided.  */&lt;br/&gt;&lt;br/&gt;    #define ACC_STRICT  0x0800&lt;br/&gt;    /*Declared strictfp; floating-point mode is FP-strict  */&lt;/pre&gt;&lt;br/&gt;The &lt;code&gt;name_index&lt;/code&gt; and &lt;code&gt;descriptor_index&lt;/code&gt; are reference to two&lt;br/&gt;constant pool of type utf8 string. The &lt;code&gt;attributes&lt;/code&gt; field defined the&lt;br/&gt;attributes of the field. Attributes are described later. Here is how we parse fields&lt;br/&gt;in a class's raw bytes-&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    BOOL JavaClass::ParseFields(char* &amp;amp;p)&lt;br/&gt;    {&lt;br/&gt;        fields = new field_info_ex[fields_count];&lt;br/&gt;        if(fields == NULL) return FALSE;&lt;br/&gt;&lt;br/&gt;        for(int i=0;i&amp;lt;fields_count;i++)&lt;br/&gt;        {&lt;br/&gt;            fields[i].pFieldInfoBase = (field_info*)p;&lt;br/&gt;&lt;br/&gt;            fields[i].access_flags= getu2(p); p+=2; //access_flags&lt;br/&gt;            fields[i].name_index= getu2(p);p+=2; //&lt;br/&gt;            fields[i].descriptor_index= getu2(p);p+=2; //&lt;br/&gt;            fields[i].attributes_count=getu2(p); p+=2;&lt;br/&gt;&lt;br/&gt;            if(fields[i].attributes_count&amp;gt;0)&lt;br/&gt;            {&lt;br/&gt;                //skip attributes - we do not need in simple cases&lt;br/&gt;                for(int a=0;a&amp;lt;fields[i].attributes_count;a++)&lt;br/&gt;                {&lt;br/&gt;	                u2 name_index=getu2(p); p+=2;&lt;br/&gt;	                //printf("Attribute name index = %dn", name_index);&lt;br/&gt;	                u4 len=getu4(p);p+=4;&lt;br/&gt;	                p+=len;&lt;br/&gt;                }&lt;br/&gt;            }&lt;br/&gt;        }&lt;br/&gt;        return TRUE;&lt;br/&gt;    }&lt;/pre&gt;&lt;br/&gt;&lt;h2&gt;Methods&lt;/h2&gt;&lt;br/&gt;A java class file may contain arbitrary number of methods. The count is stored in&lt;br/&gt;&lt;code&gt;methods_count&lt;/code&gt; member of class file structure. As it is a two byte field&lt;br/&gt;the theoritical upper limit is essentially 2^16. Like fields info, method info structure&lt;br/&gt;contains access flags, name index, descriptor index, and attributes.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct method_info&lt;br/&gt;    {&lt;br/&gt;	    u2 access_flags;&lt;br/&gt;        u2 name_index;&lt;br/&gt;        u2 descriptor_index;&lt;br/&gt;        u2 attributes_count;&lt;br/&gt;        attribute_info* attributes;//[attributes_count];&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;Method body (if any) is stored in an attribute named &lt;code&gt;Code&lt;/code&gt;- which contains the actual&lt;br/&gt;'Java Byte Code'. Here is how we parse methods in out virtual machine-&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    //TODO: Cashe the findings here&lt;br/&gt;    BOOL JavaClass::ParseMethods(char* &amp;amp;p)&lt;br/&gt;    {&lt;br/&gt;	    methods = new method_info_ex[methods_count];&lt;br/&gt;&lt;br/&gt;	    if(methods == NULL) return FALSE;&lt;br/&gt;&lt;br/&gt;	    for(int i=0;i&amp;lt;methods_count;i++)&lt;br/&gt;	    {&lt;br/&gt;		    //methods[i] = new method_info_ex;&lt;br/&gt;		    methods[i].pMethodInfoBase=(method_info*)p;&lt;br/&gt;		    methods[i].access_flags= getu2(p);	p+=2; //access_flags&lt;br/&gt;		    methods[i].name_index = getu2(p); p+=2; //name_index&lt;br/&gt;		    methods[i].descriptor_index= getu2(p); p+=2; //descriptor_index&lt;br/&gt;		    methods[i].attributes_count=getu2(p); p+=2;&lt;br/&gt;&lt;br/&gt;		    CString strName, strDesc;&lt;br/&gt;		    GetStringFromConstPool(methods[i].name_index, strName);&lt;br/&gt;		    GetStringFromConstPool(methods[i].descriptor_index, strDesc);&lt;br/&gt;&lt;br/&gt;		    TRACE(_T("Method = %s%sn"),strName, strDesc);&lt;br/&gt;&lt;br/&gt;		    TRACE("Method has total %d attributesn",methods[i].attributes_count);&lt;br/&gt;&lt;br/&gt;		    methods[i].pCode_attr=NULL;&lt;br/&gt;		    if(methods[i].attributes_count&amp;gt;0)&lt;br/&gt;		    {&lt;br/&gt;			    //skip attributes&lt;br/&gt;			    for(int a=0;a&amp;lt;methods[i].attributes_count;a++)&lt;br/&gt;			    {&lt;br/&gt;				    u2 name_index=getu2(p); p+=2;&lt;br/&gt;&lt;br/&gt;				    TRACE("Attribute name index = %dn", name_index);&lt;br/&gt;				    u4 len=getu4(p);p+=4;&lt;br/&gt;				    p+=len;&lt;br/&gt;			    }&lt;br/&gt;&lt;br/&gt;			    methods[i].pCode_attr = new Code_attribute;&lt;br/&gt;			    ParseMethodCodeAttribute(i, methods[i].pCode_attr);&lt;br/&gt;		    }&lt;br/&gt;	    }&lt;br/&gt;&lt;br/&gt;	    return TRUE;&lt;br/&gt;    }&lt;/pre&gt;&lt;br/&gt;In case of method structure ( and also same in fields structure) I have used  &lt;code&gt;method_info_ex&lt;/code&gt; instead&lt;br/&gt;of &lt;code&gt;method_info&lt;/code&gt; structure. This extended structure on pointer to pint to raw&lt;br/&gt;method info in the in-memory bytestream of class file. Here with other fields we parse the &lt;code&gt;Code&lt;/code&gt; attribute.&lt;br/&gt;The details id given later in attributes section.&lt;br/&gt;&lt;h2&gt;Attributes&lt;/h2&gt;&lt;br/&gt;In most classes attributes takes most of the space in file. Class has attributes, method has attributes,&lt;br/&gt;field has attributes. The raw definition of attribute is like this-&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct attribute_info&lt;br/&gt;    {&lt;br/&gt;	    u2 attribute_name_index;&lt;br/&gt;        u4 attribute_length;&lt;br/&gt;        u1* info;//[attribute_length];&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;The &lt;code&gt;attribute_name_index&lt;/code&gt; field is the reference index in the constant pool&lt;br/&gt;for string type constant. The &lt;code&gt;attribute_length&lt;/code&gt; field is the length of info field-&lt;br/&gt;which is another structure depending on the type/ name of the attribute. An arrtibute can be&lt;br/&gt;a constant value, exception table or code type.&lt;br/&gt;&lt;h3&gt;Constant value attribute&lt;/h3&gt;&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct ConstantValue_attribute {&lt;br/&gt;	    u2 attribute_name_index;&lt;br/&gt;	    u4 attribute_length;&lt;br/&gt;	    u2 constantvalue_index;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;&lt;h3&gt;Code Attribute&lt;/h3&gt;&lt;br/&gt;It is also a method specific attribute. The name of the attribute is hardcoded as 'Code'.&lt;br/&gt;This attribute has maximum stack and maximum local values of the method. The &lt;code&gt;code&lt;/code&gt;&lt;br/&gt;field is variable length defined by &lt;code&gt;code_length&lt;/code&gt; and it contains the actual&lt;br/&gt;'Java Byte Code'.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct Code_attribute {&lt;br/&gt;        u2 attribute_name_index;&lt;br/&gt;        u4 attribute_length;&lt;br/&gt;        u2 max_stack;&lt;br/&gt;        u2 max_locals;&lt;br/&gt;        u4 code_length;&lt;br/&gt;        u1* code;//[code_length];&lt;br/&gt;        u2 exception_table_length;&lt;br/&gt;        Exception_table* exception_table;//[exception_table_length];&lt;br/&gt;        u2 attributes_count;&lt;br/&gt;        attribute_info* attributes;//[attributes_count];&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;&lt;h4&gt;Exception table structure&lt;/h4&gt;&lt;br/&gt;This structure is used to define the exception table for methods. The exception&lt;br/&gt;table describes the exception handler depending on the program counter value or&lt;br/&gt;offset of byte code. The handler code is also an offset in the byte code.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    struct Exception_table&lt;br/&gt;    {&lt;br/&gt;        u2 start_pc;&lt;br/&gt;        u2 end_pc;&lt;br/&gt;        u2  handler_pc;&lt;br/&gt;        u2  catch_type;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;The field catch_type is a reference to a constant pool entry that describes the type&lt;br/&gt;of the exception- for example reference to a class named 'java/lang/Exception'.&lt;br/&gt;&lt;h2&gt;Java Instruction Set&lt;/h2&gt;&lt;br/&gt;Java has more than 200 instructions. The java language file, when compiled, is converted&lt;br/&gt;to a class file that contains intrtuctions as byte codes. If we have a method like this-&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;	public int mul(int a, int b)&lt;br/&gt;	{&lt;br/&gt;		return a * b;&lt;br/&gt;	}&lt;/pre&gt;&lt;br/&gt;we will get this method in byte code attribute like this- (java has also assembly like&lt;br/&gt;representation for instructions to represent byte codes in human readable format)&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;  Code Attribute:&lt;br/&gt;    Stack=2, Locals=3, Args_size=3,  Code Length = 4&lt;br/&gt;    Code:&lt;br/&gt;    0:   iload_1&lt;br/&gt;    1:   iload_2&lt;br/&gt;    2:   imul&lt;br/&gt;    3:   ireturn&lt;/pre&gt;&lt;br/&gt;Here if we follow the instructions we go like this:&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    0: Push (load) the local variable 1 on stack&lt;br/&gt;    1: Push the local variable 2 on stack&lt;br/&gt;    3: Pop two values from stack, do an integer multipucation and push the result&lt;br/&gt;    4: Return the integer value from stack top.&lt;/pre&gt;&lt;br/&gt;What we need to do in our virtual machine is load classes and follow the instructions&lt;br/&gt;in methods. There are methods to create new objects, to call methods of object. It is also&lt;br/&gt;possible to call native methods from a java method. Please refer to source code&lt;br/&gt;for most other codes (opcodes.h) or Java Virtual Machine Specification for a complete list.&lt;br/&gt;&lt;h2&gt;Class heap&lt;/h2&gt;&lt;br/&gt;In the virtual machine we must maintain a heap where the class definition objects&lt;br/&gt;can be stored. I have implemented it as a separate heap for simplity. In this heap&lt;br/&gt;we load classes from files and store it in the heap. The &lt;code&gt;ClassHeap&lt;/code&gt; class&lt;br/&gt;is responsible for maintaining the class heap in meory.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    class ClassHeap&lt;br/&gt;    {&lt;br/&gt;	    CMapStringToPtr m_ClassMap;&lt;br/&gt;	    FilePathManager *pFilePathManager;&lt;br/&gt;    public:&lt;br/&gt;	    ClassHeap(void);&lt;br/&gt;    public:&lt;br/&gt;	    virtual ~ClassHeap(void);&lt;br/&gt;    public:&lt;br/&gt;	    BOOL AddClass(JavaClass* pJavaClass);&lt;br/&gt;	    JavaClass* GetClass(CString strClassName);&lt;br/&gt;	    BOOL LoadClass(CString strClassName, JavaClass *pClass);&lt;br/&gt;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;We store &lt;code&gt;JavaClass&lt;/code&gt; objects pointer in the &lt;code&gt;m_ClassMap&lt;/code&gt; member&lt;br/&gt;using the class name as key.&lt;br/&gt;&lt;h2&gt;Object heap&lt;/h2&gt;&lt;br/&gt;Object heap is virtual machine's RAM. All objects are created on object heap and its&lt;br/&gt;reference can be stored in another object or on the stack. Any reference is stored in&lt;br/&gt;an union type storage named &lt;code&gt;Variable&lt;/code&gt;. Any field of a class can be&lt;br/&gt;represented using variable object. Anything can be stored in a &lt;code&gt;Variable&lt;/code&gt;&lt;br/&gt;object.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;    union Variable&lt;br/&gt;    {&lt;br/&gt;        u1 charValue;&lt;br/&gt;        u2 shortValue;&lt;br/&gt;        u4 intValue;&lt;br/&gt;        f4 floatValue;&lt;br/&gt;        LONG_PTR ptrValue;&lt;br/&gt;        Object object;&lt;br/&gt;    };&lt;/pre&gt;&lt;br/&gt;Object creation on heap is described later in detail.&lt;br/&gt;&lt;h3&gt;Virtual Machine Stack&lt;/h3&gt;&lt;br/&gt;Java instruction set is designed in such a way that it can work with very limited set&lt;br/&gt;of registers. Instead it uses its stack very extensively. The JVM stack element is one item&lt;br/&gt;regardless of - it may be primitive ype or object type. Only &lt;code&gt;long&lt;/code&gt; and &lt;code&gt;double&lt;/code&gt;&lt;br/&gt;type takes two stack spaces. The 'Execution Engine' maintains the JVM stack. For example when the execution&lt;br/&gt;engine executes &lt;code&gt;iadd&lt;/code&gt; instruction it pops two numeric values from the stack and&lt;br/&gt;add the values and pushes the result on the stack. The virtual machine has empty stack initially and&lt;br/&gt;the stack is populated after the initial thread and the initial method is started for execution. Each&lt;br/&gt;method instruction is allowed to operate on stack within a limited boundary of the stack. The compiler&lt;br/&gt;sets the upper limit (top) as &lt;code&gt;max_stack&lt;/code&gt; field of each methods &lt;code&gt;Code&lt;/code&gt; attribute. The&lt;br/&gt;lower limit is the top+1 stack position of previous method. This boundary of stack is named as &lt;em&gt;Stack Frame&lt;/em&gt;&lt;br/&gt;of that method.&lt;br/&gt;&lt;h3&gt;The Stack Frame&lt;/h3&gt;&lt;br/&gt;As we mentioned each methods boundary in the JVM stack is known as 'Stack Frame'. Each stack frame reserves&lt;br/&gt;positions for the parameters and local variables of that method. If it is not a static method the first parameter&lt;br/&gt;is the object reference ( the &lt;code&gt;this&lt;/code&gt; parameter) of type of the class of the method. The &lt;em&gt;Execution Engine&lt;/em&gt;&lt;br/&gt;operates between the frame and when the method returns a value it pops every element from the current frame including&lt;br/&gt;&lt;code&gt;this&lt;/code&gt; reference and pushes the return value (if method is not &lt;code&gt;void&lt;/code&gt; return type) value&lt;br/&gt;on the frame of previous frames top. To keep the implementation simple I used slightly different methodology. I used&lt;br/&gt;stack of stack. Each frame is stack type and it is pushed on the JVM stack. The stack grows on method invocation&lt;br/&gt;and shrinks on method return.&lt;br/&gt;&lt;h3&gt;Local Variables&lt;/h3&gt;&lt;br/&gt;In a stack frame local variables takes positions from zero to &lt;code&gt;max_locals&lt;/code&gt; - 1&lt;br/&gt;positions or less. If the method is not static the object takes the position zero and other&lt;br/&gt;locals follow it. Local variables are accessed using &lt;code&gt;putfield&lt;/code&gt; and &lt;code&gt;getfield&lt;/code&gt;&lt;br/&gt;instructions.&lt;br/&gt;&lt;h3&gt;Native method stack&lt;/h3&gt;&lt;br/&gt;Unlike virtual machine stack, native methods stack is not maintained by JVM. It is&lt;br/&gt;maintained by the native system. Actually while a native method is being executed the&lt;br/&gt;virtual machine component that was managing the java thread waits until the native&lt;br/&gt;method completes and returns.&lt;br/&gt;&lt;h2&gt;Runtime Environment&lt;/h2&gt;&lt;br/&gt;Each java thread has its own frame stack. All java threads in a process share common class heap&lt;br/&gt;and object heap. This things are bundled together in a &lt;code&gt;RuntimeEnvironment&lt;/code&gt; object and&lt;br/&gt;carried among the execution engine components.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt; class RuntimeEnvironment&lt;br/&gt; {&lt;br/&gt;	public:&lt;br/&gt;		Frame *pFrameStack;&lt;br/&gt;		ClassHeap *pClassHeap;&lt;br/&gt;		ObjectHeap *pObjectHeap;&lt;br/&gt; };&lt;/pre&gt;&lt;br/&gt;&lt;h2&gt;Execution Unit&lt;/h2&gt;&lt;br/&gt;This is the main module of the JVM. It interprates the instructons. Advanced JVMs may&lt;br/&gt;use JIT compiler to convert java instructions into native instruction. But I did not do&lt;br/&gt;that because of the complexity of the JIT compiler.&lt;br/&gt;When a JVM starts it usually takes initial class name as parameter. Our JVM also takes&lt;br/&gt;class name as a parameter. The class heap is then requested to load that class. Then the&lt;br/&gt;JVM finds its main method (it can be any name like Entry in case of my first implementation),&lt;br/&gt;creates the initial stack frame and requests the execution engine to start execution. The&lt;br/&gt;heart of the &lt;em&gt;Execution Unit&lt;/em&gt; is the &lt;code&gt;Execute&lt;/code&gt; method. Here is the skeleton:&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;	u4 ExecutionEngine::Execute(Frame* pFrameStack)&lt;br/&gt;	{&lt;br/&gt;		ASSERT(pFrameStack);&lt;br/&gt;		ASSERT(pFrame);&lt;br/&gt;&lt;br/&gt;		Frame* pFrame=&amp;amp;pFrameStack[0];&lt;br/&gt;&lt;br/&gt;		DbgPrint(_T("Current Frame %ld Stack start at %ldn"),&lt;br/&gt;				pFrame-Frame::pBaseFrame, 	pFrame-&amp;gt;stack-Frame::pOpStack );&lt;br/&gt;&lt;br/&gt;		if(pFrame-&amp;gt;pMethod-&amp;gt;access_flags &amp;amp; ACC_NATIVE)&lt;br/&gt;		{&lt;br/&gt;			ExecuteNativeMethod(pFrame);&lt;br/&gt;			return 0;&lt;br/&gt;		}&lt;br/&gt;&lt;br/&gt;		u1 *bc=pFrame-&amp;gt;pMethod-&amp;gt;pCode_attr-&amp;gt;code + pFrame-&amp;gt;pc;	&lt;br/&gt;&lt;br/&gt;		i4 error=0;&lt;br/&gt;		JavaClass *pClass = pFrame-&amp;gt;pClass;&lt;br/&gt;&lt;br/&gt;		CString strMethod;&lt;br/&gt;		pClass-&amp;gt;GetStringFromConstPool(pFrame-&amp;gt;pMethod-&amp;gt;name_index, strMethod);&lt;br/&gt;&lt;br/&gt;		DbgPrint(_T("Execute At Class %s Method %s n"), pClass-&amp;gt;GetName(), strMethod);&lt;br/&gt;		i4 index=0;&lt;br/&gt;		i8 longVal;&lt;br/&gt;		while(1)&lt;br/&gt;		{&lt;br/&gt;			switch(bc[pFrame-&amp;gt;pc])&lt;br/&gt;			{&lt;br/&gt;			case nop: //Do nothing&lt;br/&gt;				pFrame-&amp;gt;pc++;&lt;br/&gt;				break;&lt;br/&gt;&lt;br/&gt;			//Integer Arithmetic&lt;br/&gt;			case iadd: //96 : Pop two int values from stack add them and push result&lt;br/&gt;				pFrame-&amp;gt;stack[pFrame-&amp;gt;sp-1].intValue=pFrame-&amp;gt;stack[pFrame-&amp;gt;sp-1].intValue&lt;br/&gt;						+ pFrame-&amp;gt;stack[pFrame-&amp;gt;sp].intValue;&lt;br/&gt;				pFrame-&amp;gt;sp--;&lt;br/&gt;				pFrame-&amp;gt;pc++;&lt;br/&gt;				break;&lt;br/&gt;&lt;br/&gt;			//Method return instructions&lt;br/&gt;			case ireturn: //172 (0xac) : Pop everything from stack and push return value (int)&lt;br/&gt;				pFrame-&amp;gt;stack[0].intValue=pFrame-&amp;gt;stack[pFrame-&amp;gt;sp].intValue;&lt;br/&gt;				return ireturn; // here we break the while loop&lt;br/&gt;				break;&lt;br/&gt;&lt;br/&gt;			// Method invokation Instructions&lt;br/&gt;&lt;br/&gt;			// Here actually we do a recursive call to Execute&lt;br/&gt;			// to keep things simple- after the java method return we&lt;br/&gt;			// also return from Execute- some memory waste for simplicity&lt;br/&gt;			case invokevirtual: //182: Invoke a virtual method.&lt;br/&gt;				// The object reference and parameters are on stack by java instructions&lt;br/&gt;				ExecuteInvoke(pFrame, invokevirtual);&lt;br/&gt;				pFrame-&amp;gt;pc+=3;&lt;br/&gt;				break;&lt;br/&gt;			}&lt;br/&gt;&lt;br/&gt;			//Instructions that deal with objects&lt;br/&gt;&lt;br/&gt;			case _new:// 187 (0xbb)&lt;br/&gt;				ExecuteNew(pFrame);&lt;br/&gt;				pFrame-&amp;gt;pc+=3;&lt;br/&gt;				break;&lt;br/&gt;			case putfield: //181 (0xb5): Set field in object from stack top&lt;br/&gt;				PutField(pFrame);&lt;br/&gt;				pFrame-&amp;gt;sp-=2;&lt;br/&gt;				pFrame-&amp;gt;pc+=3;&lt;br/&gt;				break;&lt;br/&gt;&lt;br/&gt;			case getfield: //180 (0xb4) Fetch field from object and push on stack&lt;br/&gt;				GetField(pFrame);&lt;br/&gt;				pFrame-&amp;gt;pc+=3;&lt;br/&gt;				break;&lt;br/&gt;		}&lt;br/&gt;		return 0;&lt;br/&gt;	}&lt;/pre&gt;&lt;br/&gt;&lt;h3&gt;Creating object on Object Heap&lt;/h3&gt;&lt;br/&gt;An object is usually created by JVM when a &lt;code&gt;new&lt;/code&gt; or &lt;code&gt;newarray&lt;/code&gt; or&lt;br/&gt;&lt;code&gt;multinewarray&lt;/code&gt; instruction is executed. When a virtual machine creates an object it&lt;br/&gt;first calculate the size of the object. To calculate the object size we we first take the&lt;br/&gt;&lt;code&gt;fields_count&lt;/code&gt; value in the class structure then we add its super classes&lt;br/&gt;&lt;code&gt;fields_count&lt;/code&gt; value with it then we add super classes super classes &lt;code&gt;fields_count&lt;/code&gt;&lt;br/&gt;and so on recursively until we reach the final base class java.lang.Object. This way we&lt;br/&gt;calculate total fields of the object and add one with it that holds the class pointer&lt;br/&gt;in the ClassHeap. Now we multiply the &lt;code&gt;sizeof(Variable)&lt;/code&gt; to the count and&lt;br/&gt;get number of bytes required for the object. We now allocate the required bytes and&lt;br/&gt;return the pointer to that memory in a &lt;code&gt;Variable&lt;/code&gt; object on the stack top. Here is&lt;br/&gt;the implementation.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;	int ExecutionEngine::ExecuteNew(Frame* pFrame)&lt;br/&gt;	{&lt;br/&gt;		pFrame-&amp;gt;sp++;&lt;br/&gt;		u1 *bc=pFrame-&amp;gt;pMethod-&amp;gt;pCode_attr-&amp;gt;code;&lt;br/&gt;		u2 index=getu2(&amp;amp;bc[pFrame-&amp;gt;pc+1]);&lt;br/&gt;		if(!pFrame-&amp;gt;pClass-&amp;gt;CreateObject(index, this-&amp;gt;pObjectHeap, pFrame-&amp;gt;stack[pFrame-&amp;gt;sp].object))&lt;br/&gt;			return -1;&lt;br/&gt;		return 0;&lt;br/&gt;	}&lt;br/&gt;&lt;br/&gt;	BOOL JavaClass::CreateObject(u2 index, ObjectHeap *pObjectHeap, Object&amp;amp; object)&lt;br/&gt;	{&lt;br/&gt;		char *cp=(char*)this-&amp;gt;constant_pool[index];&lt;br/&gt;		ASSERT(cp[0] == CONSTANT_Class);&lt;br/&gt;		ASSERT(pObjectHeap);&lt;br/&gt;		if(cp[0] != CONSTANT_Class)&lt;br/&gt;			return FALSE;&lt;br/&gt;&lt;br/&gt;		u2 name_index=getu2(&amp;amp;cp[1]);&lt;br/&gt;		CString strClassName;&lt;br/&gt;		if(!this-&amp;gt;GetStringFromConstPool(name_index, strClassName))&lt;br/&gt;			return FALSE;				&lt;br/&gt;&lt;br/&gt;		JavaClass *pNewClass=this-&amp;gt;m_pClassHeap-&amp;gt;GetClass(strClassName);&lt;br/&gt;		if(pNewClass == NULL) return FALSE;&lt;br/&gt;		object=pObjectHeap-&amp;gt;CreateObject(pNewClass);&lt;br/&gt;		return TRUE;&lt;br/&gt;	}&lt;/pre&gt;&lt;br/&gt;&lt;h3&gt;Setting or getting value in object&lt;/h3&gt;&lt;br/&gt;The &lt;code&gt;putfield&lt;/code&gt; instruction is used to set a value (from stack) of a field and&lt;br/&gt;the &lt;code&gt;getfield&lt;/code&gt; instruction is used to load a variables value on the&lt;br/&gt;stack. When the execution engine needs to execute a &lt;code&gt;getfield&lt;/code&gt;&lt;br/&gt;instruction it pops two values from the stack. One value is the object pointer&lt;br/&gt;another is field position (zero based index). Here is my implementation:&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;	// Gets value or reference from stack and set in object&lt;br/&gt;	void ExecutionEngine::PutField(Frame* pFrameStack)&lt;br/&gt;	{&lt;br/&gt;		u2 nIndex = getu2(&amp;amp;pFrameStack[0].pMethod-&amp;gt;pCode_attr-&amp;gt;code[pFrameStack[0].pc+1]);&lt;br/&gt;		Variable obj=pFrameStack[0].stack[pFrameStack[0].sp-1];&lt;br/&gt;		Variable value=pFrameStack[0].stack[pFrameStack[0].sp];&lt;br/&gt;		Variable *pVarList=this-&amp;gt;pObjectHeap-&amp;gt;GetObjectPointer(obj.object);&lt;br/&gt;		pVarList[nIndex+1]=value;&lt;br/&gt;	}&lt;br/&gt;&lt;br/&gt;	//Gets the value from variable and push on stack&lt;br/&gt;	void ExecutionEngine::GetField(Frame* pFrame)&lt;br/&gt;	{&lt;br/&gt;		//TODO: Bug check for long and double&lt;br/&gt;		u2 nIndex = getu2(&amp;amp;pFrame-&amp;gt;pMethod-&amp;gt;pCode_attr-&amp;gt;code[pFrame-&amp;gt;pc+1]);&lt;br/&gt;		Variable obj=pFrame-&amp;gt;stack[pFrame-&amp;gt;sp];&lt;br/&gt;		Variable *pVarList=this-&amp;gt;pObjectHeap-&amp;gt;GetObjectPointer(obj.object);&lt;br/&gt;		pFrame-&amp;gt;stack[pFrame-&amp;gt;sp]=pVarList[nIndex+1];&lt;br/&gt;	}&lt;/pre&gt;&lt;br/&gt;&lt;h3&gt;Invoking method&lt;/h3&gt;&lt;br/&gt;When execution engine requires a method invocation it needs to creates a new 'Stack Frame' and&lt;br/&gt;the &lt;code&gt;pc&lt;/code&gt; or Program Counter is set to the first byte of the methods byte code. Before that,&lt;br/&gt;the execution engine must save the current methods &lt;code&gt;pc&lt;/code&gt; so that it can come back to&lt;br/&gt;resume method execution after the callee method returns. Here is our implementation. Please note how&lt;br/&gt;we handle static method invocation - simply we do not have the &lt;code&gt;this&lt;/code&gt; reference on our stack.&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;	void ExecutionEngine::ExecuteInvoke(Frame* pFrameStack, u2 type)&lt;br/&gt;	{&lt;br/&gt;		u2 mi=getu2(&amp;amp;pFrameStack[0].pMethod-&amp;gt;pCode_attr-&amp;gt;code[pFrameStack[0].pc+1]);&lt;br/&gt;		Variable objectRef = pFrameStack[0].stack[pFrameStack[0].sp];&lt;br/&gt;		char *pConstPool = (char *)pFrameStack[0].pClass-&amp;gt;constant_pool[mi];&lt;br/&gt;&lt;br/&gt;		ASSERT(pConstPool[0] == CONSTANT_Methodref);&lt;br/&gt;&lt;br/&gt;		u2 classIndex = getu2(&amp;amp;pConstPool[1]);&lt;br/&gt;		u2 nameAndTypeIndex = getu2(&amp;amp;pConstPool[3]);&lt;br/&gt;&lt;br/&gt;		//get class at pool index&lt;br/&gt;		pConstPool = (char *)pFrameStack[0].pClass-&amp;gt;constant_pool[classIndex];&lt;br/&gt;&lt;br/&gt;		ASSERT(pConstPool[0] == CONSTANT_Class);&lt;br/&gt;&lt;br/&gt;		u2 ni=getu2(&amp;amp;pConstPool[1]);&lt;br/&gt;&lt;br/&gt;		CString strClassName;&lt;br/&gt;		pFrameStack[0].pClass-&amp;gt;GetStringFromConstPool(ni, strClassName);&lt;br/&gt;&lt;br/&gt;		JavaClass *pClass=pClassHeap-&amp;gt;GetClass(strClassName);&lt;br/&gt;		pConstPool = (char *)pFrameStack[0].pClass-&amp;gt;constant_pool[nameAndTypeIndex];&lt;br/&gt;&lt;br/&gt;		ASSERT(pConstPool[0] == CONSTANT_NameAndType);&lt;br/&gt;&lt;br/&gt;		method_info_ex method;&lt;br/&gt;		method.name_index = getu2(&amp;amp;pConstPool[1]);&lt;br/&gt;		method.descriptor_index = getu2(&amp;amp;pConstPool[3]);&lt;br/&gt;		method.access_flags = 0; // set later&lt;br/&gt;&lt;br/&gt;		CString strName, strDesc;&lt;br/&gt;		pFrameStack[0].pClass-&amp;gt;GetStringFromConstPool(method.name_index, strName);&lt;br/&gt;		pFrameStack[0].pClass-&amp;gt;GetStringFromConstPool(method.descriptor_index, strDesc);&lt;br/&gt;&lt;br/&gt;		JavaClass *pVirtualClass=pClass;&lt;br/&gt;		int nIndex=pClass-&amp;gt;GetMethodIndex(strName, strDesc, pVirtualClass);&lt;br/&gt;&lt;br/&gt;		memset(&amp;amp;pFrameStack[1],0,sizeof(pFrameStack[1]));&lt;br/&gt;		pFrameStack[1].pMethod = &amp;amp;pClass-&amp;gt;methods[nIndex];&lt;br/&gt;&lt;br/&gt;		method.access_flags = getu2((char *)pFrameStack[1].pMethod);&lt;br/&gt;		if( ACC_SUPER &amp;amp; method.access_flags)&lt;br/&gt;		{&lt;br/&gt;			pFrameStack[1].pClass = pVirtualClass-&amp;gt;GetSuperClass();&lt;br/&gt;		}&lt;br/&gt;		else&lt;br/&gt;		{&lt;br/&gt;			pFrameStack[1].pClass=pVirtualClass;&lt;br/&gt;		}&lt;br/&gt;&lt;br/&gt;		int params=GetMethodParametersStackCount(strDesc)+1;&lt;br/&gt;&lt;br/&gt;		//invokestatic - there is no this pointer&lt;br/&gt;		if(type==invokestatic) params--;&lt;br/&gt;		// else invokevirtual has this pointer&lt;br/&gt;&lt;br/&gt;		int nDiscardStack =params;&lt;br/&gt;		if(pFrameStack[1].pMethod-&amp;gt;access_flags &amp;amp; ACC_NATIVE)&lt;br/&gt;		{&lt;br/&gt;		}&lt;br/&gt;		else&lt;br/&gt;		{&lt;br/&gt;			nDiscardStack+=pFrameStack[1].pMethod-&amp;gt;pCode_attr-&amp;gt;max_locals;&lt;br/&gt;		}&lt;br/&gt;&lt;br/&gt;		pFrameStack[1].stack =&lt;br/&gt;			&amp;amp;Frame::pOpStack[pFrameStack-&amp;gt;stack-Frame::pOpStack+pFrameStack[0].sp-params+1];&lt;br/&gt;		pFrameStack[1].sp=nDiscardStack-1;&lt;br/&gt;&lt;br/&gt;		this-&amp;gt;Execute(&amp;amp;pFrameStack[1]);&lt;br/&gt;&lt;br/&gt;		//if returns then get on stack&lt;br/&gt;		if(strDesc.Find(_T(")V")) &amp;lt; 0)&lt;br/&gt;		{&lt;br/&gt;			nDiscardStack--;&lt;br/&gt;		}&lt;br/&gt;		//Before we return to caller make the stack of caller right&lt;br/&gt;		pFrameStack[0].sp-=nDiscardStack;&lt;br/&gt;	}&lt;/pre&gt;&lt;br/&gt;&lt;h4&gt;Invoking native method&lt;/h4&gt;&lt;br/&gt;In a java class a method may be marked as native-&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;	public class Test&lt;br/&gt;	{&lt;br/&gt;		public native void Print(string message);&lt;br/&gt;	}&lt;/pre&gt;&lt;br/&gt;In byte code &lt;code&gt;ACC_NATIVE&lt;/code&gt; is set in the &lt;code&gt;access_flags&lt;/code&gt; field of the&lt;br/&gt;&lt;code&gt;method_info&lt;/code&gt; structure. We decide here like this:&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;	if(pFrame-&amp;gt;pMethod-&amp;gt;access_flags &amp;amp; ACC_NATIVE)&lt;br/&gt;	{&lt;br/&gt;		ExecuteNativeMethod(pFrame);&lt;br/&gt;		return 0;&lt;br/&gt;	}&lt;/pre&gt;&lt;br/&gt;Each native method usually has a fixed predefined prototype. Here is the type definitation for our&lt;br/&gt;JVM:&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;	typedef Variable (*pNativeMethod)(RuntimeEnvironment* pRuntimeEnvironment);&lt;/pre&gt;&lt;br/&gt;Here is how we handle native methods in the JVM:&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;	u4 ExecutionEngine::ExecuteNativeMethod(Frame* pFrameStack)&lt;br/&gt;	{&lt;br/&gt;		ASSERT(pFrameStack);&lt;br/&gt;&lt;br/&gt;		ASSERT(pFrame-&amp;gt;pMethod-&amp;gt;access_flags &amp;amp; ACC_NATIVE);&lt;br/&gt;		Frame* pFrame=&amp;amp;pFrameStack[0];&lt;br/&gt;&lt;br/&gt;		JavaClass *pClass = pFrame-&amp;gt;pClass;&lt;br/&gt;		CString strClassName, strMethod, strDesc, strSignature;&lt;br/&gt;		strClassName=pClass-&amp;gt;GetName();&lt;br/&gt;		pClass-&amp;gt;GetStringFromConstPool(pFrame-&amp;gt;pMethod-&amp;gt;name_index, strMethod);&lt;br/&gt;		pClass-&amp;gt;GetStringFromConstPool(pFrame-&amp;gt;pMethod-&amp;gt;descriptor_index, strDesc);&lt;br/&gt;		DbgPrint(_T("Execute At Class %s Method %s%s  n"),strClassName , strMethod, strDesc);&lt;br/&gt;		strSignature=strClassName+_T("@")+strMethod+strDesc;&lt;br/&gt;		pNativeMethod pNativeMethod=GetNativeMethod(strSignature);&lt;br/&gt;		RuntimeEnvironment rte;&lt;br/&gt;		rte.pFrameStack=pFrameStack;&lt;br/&gt;		rte.pClassHeap= pClassHeap;&lt;br/&gt;		rte.pObjectHeap= pObjectHeap;&lt;br/&gt;&lt;br/&gt;		if(pNativeMethod == NULL)&lt;br/&gt;		{&lt;br/&gt;			// what should I do here??&lt;br/&gt;			// System Panic??&lt;br/&gt;			ASSERT(FALSE);&lt;br/&gt;			return -1;&lt;br/&gt;		}&lt;br/&gt;		else&lt;br/&gt;		{&lt;br/&gt;			//Here we go native&lt;br/&gt;			Variable retVal = pNativeMethod(&amp;amp;rte);&lt;br/&gt;&lt;br/&gt;			//if returns then get on stack&lt;br/&gt;			if(strDesc.Find(_T(")V")) &amp;lt; 0)&lt;br/&gt;			{&lt;br/&gt;				pFrame-&amp;gt;stack[0]=retVal;&lt;br/&gt;			}&lt;br/&gt;		}&lt;br/&gt;		return 0;&lt;br/&gt;	}&lt;/pre&gt;&lt;br/&gt;Here is the implementation of &lt;code&gt;Print&lt;/code&gt; method of Test class:&lt;br/&gt;&lt;pre&gt;&lt;br/&gt;&lt;br/&gt;	//Signature: _T("Test@Print(Ljava/lang/String;)V")&lt;br/&gt; 	Variable Print(RuntimeEnvironment* pRuntimeEnvironment)&lt;br/&gt;	{&lt;br/&gt;		Variable returnVal;&lt;br/&gt;		Frame *pFrame=&amp;amp;pRuntimeEnvironment-&amp;gt;pFrameStack[0];&lt;br/&gt;		Object object=pFrame-&amp;gt;stack[pFrame-&amp;gt;sp].object;&lt;br/&gt;		Variable *pVar=pRuntimeEnvironment-&amp;gt;pObjectHeap-&amp;gt;GetObjectPointer(object);&lt;br/&gt;		if(pVar)&lt;br/&gt;		{&lt;br/&gt;			CString *pString = (CString *)pVar[1].ptrValue;&lt;br/&gt;			if(pString)	wprintf(_T("%s"),*pString);&lt;br/&gt;		}&lt;br/&gt;&lt;br/&gt;		returnVal.intValue=0;&lt;br/&gt;		return returnVal;&lt;br/&gt;	}&lt;/pre&gt;&lt;br/&gt;It is the native methods responsibility to correctly operate on stack. The java instruction is&lt;br/&gt;here out of scope. Everything is running on real machine here.&lt;br/&gt;So, here we pop the string type object reference from stack, convert it to &lt;code&gt;CString&lt;/code&gt;&lt;br/&gt;object and do our native printing to console. This way we can handle any native operation like&lt;br/&gt;creating new window, drawing or do network operation. All these things are done in the&lt;br/&gt;implementation of &lt;a href="http://morpheus.kuashaonline.com/" target="_blank"&gt;Morpheus&lt;/a&gt; project.&lt;br/&gt;&lt;h2&gt;The Garbage Collector&lt;/h2&gt;&lt;br/&gt;Java language does not have memory release mechanism. So the JVM must take the responsibility to release&lt;br/&gt;memory when some objects are out of scope no longer required or referenced by the application. To do this&lt;br/&gt;the JVM may take a number of strategy like reference count, mark and sweep etc. I used mark and sweep method&lt;br/&gt;because of its simplicily and accuracy. We start from the stack. We mark each object that is being referenced&lt;br/&gt;from the stack references. Then we mark all the objects that is being referenced by the marked objects and so&lt;br/&gt;on recursively. After the mark operation we know which objects are connected and which are out of scope. Then&lt;br/&gt;we take each object one by one and release its memory from heap. Before that we must call the &lt;code&gt;finalize&lt;/code&gt;&lt;br/&gt;method of that object to do any cleanup required by the object itself programetically.&lt;br/&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;&lt;br/&gt;Thats all about to say for now about how we can implement a simple JVM. The JVM I present here is very&lt;br/&gt;limited implementation - though most of the java instructions are supported. It lacks heavily&lt;br/&gt;for library and native interface. Please look at the seminar&lt;br/&gt;presentation downloadable above for a visual description of JVM and how instructions are executed in&lt;br/&gt;a JVM. Full screen view of the presentation is best viewed with spacebar to go to next slide.&lt;br/&gt;I am busy with the&lt;br/&gt;implementation of &lt;a href="http://morpheus.kuashaonline.com/" target="_blank"&gt;Morpheus&lt;/a&gt; project at my free time&lt;br/&gt;and wish to come with that as well as with a new JVM with a new Window subsystem implementation having&lt;br/&gt;Windows Vista and Office 2007 look and feel (ok, ok, thats not technically a big deal but good to have&lt;br/&gt;for user interface degign) and oh yes also with a .NET Virtual Execution System with Morpheus for .NET&lt;br/&gt;support also. The .NET VES is similar except the complex onfile structure is really painfull when I&lt;br/&gt;decode them.  All these things I do because I love to do- so I do not try to make a zero bug system.&lt;br/&gt;I leave when it seems to work for 'Hello World ++' applications.&lt;br/&gt;&lt;br/&gt;&lt;hr /&gt;&lt;br/&gt;This article is also published in Codeproject. Click &lt;a href="http://www.codeproject.com/KB/cpp/jvm.aspx" target="_blank"&gt;here &lt;/a&gt; to view.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-8305781369040737680?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/8305781369040737680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/8305781369040737680'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2008/03/home-made-java-virtual-machine.html' title='Home Made Java Virtual Machine'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-6642051277736881122</id><published>2008-03-29T06:20:00.000-07:00</published><updated>2010-05-29T01:38:40.942-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Picnic'/><category scheme='http://www.blogger.com/atom/ns#' term='Adventures'/><title type='text'>Kaza Coralina</title><content type='html'>&lt;img src="http://www.kaz.com.bd/blog/userpic/kazacoralina/blogV.JPG" border="0" /&gt;&lt;br/&gt;We had our annual picnic (codenamed "kaza coralina") this year at the &lt;a href="http://en.wikipedia.org/wiki/St._Martin's_Island" title="St. Martin "&gt;St. Martin island&lt;/a&gt;. A huge surge of techies in a coral island must have distorted local space time structure. But whatever distortion it was, it must have been positive for humans. We had a grand time!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-6642051277736881122?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/6642051277736881122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/6642051277736881122'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2008/03/kaza-coralina.html' title='Kaza Coralina'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-8239574113607740680</id><published>2008-01-22T04:38:00.000-08:00</published><updated>2010-05-29T01:38:40.945-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Picnic'/><category scheme='http://www.blogger.com/atom/ns#' term='Adventures'/><title type='text'>Kaza Coralina</title><content type='html'>Coral hunt in the St. Martin Island for all the long "party-less work, work and work" suffering Kazites. At last the fun is back! Big decisions have to be made (should we have bbq by the sea or take a cook with us to cook us biriyani?) and big sacrifices have to be made (should I miss the beautiful traffic jams in Dhaka?).&lt;br/&gt;&lt;br/&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2008/01/kazacoralina.JPG" title="kazacoralina.JPG"&gt;&lt;img width="438" src="http://www.kaz.com.bd/blog/wp-content/uploads/2008/01/kazacoralina.JPG" alt="kazacoralina.JPG" height="304" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-8239574113607740680?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/8239574113607740680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/8239574113607740680'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2008/01/kaza-coralina.html' title='Kaza Coralina'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-8779240893778224980</id><published>2007-09-22T04:21:00.000-07:00</published><updated>2010-05-29T01:38:40.947-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Adventures'/><category scheme='http://www.blogger.com/atom/ns#' term='Anniversary Party'/><title type='text'>Lets go, lets go, lets goa!</title><content type='html'>With our anniversary party “Odyssey” over we are having a post party depression. Life should have been just an endless stream of back to back parties!&lt;br/&gt;&lt;br/&gt;Anyway, Odyssey was a supreme success. Tweleve days of non-stop furti! Check out some the places we’ve been to on the google map &lt;a target="_blank" href="http://www.kaz.com.bd/blog/usercontent/goamap/map.html" title="Odyssey locations"&gt;here&lt;/a&gt;. But before you do that here are a few interesting but random trivia about Goa:&lt;br/&gt;&lt;br/&gt;1. Goa became independent from Portugal in 1961! So Goa has been a part of Portugal from 1510 to 1961!&lt;br/&gt;&lt;br/&gt;2. 40,000 Indian troops walked in to Goa on "Operation Vijay" to make Goa independent.&lt;br/&gt;&lt;br/&gt;3. Goa became a full blown state as late as 1987. It was a "union territory" before that, since it never wanted to part of Maha Rashtra.&lt;br/&gt;&lt;br/&gt;4. Mangoes of Goa can rival that of Bangladesh and goans have passions about mango almost on the same level as ours.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-8779240893778224980?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/8779240893778224980'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/8779240893778224980'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2007/09/lets-go-lets-go-lets-goa.html' title='Lets go, lets go, lets goa!'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-1137642149583869992</id><published>2007-07-06T05:11:00.000-07:00</published><updated>2010-05-29T01:38:40.950-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Adventures'/><category scheme='http://www.blogger.com/atom/ns#' term='Anniversary Party'/><title type='text'>Go Goa</title><content type='html'>There is one high priority thread running at KAZ now. Dev rooms to hallways to rec room - just a single thread. The thread hangs once in a while to stop everything. Not a masterpiece in design but none of the superstar developers seems to mind!&lt;br/&gt;&lt;br/&gt;The thread has just one constant “Goa”!&lt;br/&gt;&lt;br/&gt; &lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/goa1.jpg" title="Goa"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/goa1.jpg" alt="Goa" /&gt;&lt;/a&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/goa.jpg" title="Goa"&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;This year’s anniversary party at KAZ will be at &lt;a target="_blank" href="http://en.wikipedia.org/wiki/Goa" title="Goa on wikipedia"&gt;Goa&lt;/a&gt;. The party is codenamed “Odyssey”. A lot of planning is going on to make odyssey a success. There must be something for everyone (since anniversary party also means friends and families) and there must be enough fun to talk about for a whole year (until the next party at least!). A lot of pressure on the odyssey team. &lt;br/&gt;&lt;br/&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/odyssey.GIF" title="The Project Plan"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/odyssey.GIF" alt="The Project Plan" /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;Oscar Wilde’s last words were reputedly:  &lt;em&gt;“This wallpaper is terrible – one of us have to go”.&lt;/em&gt; I know there is not even the thinnest of relevance for this quote with this post, but somehow I feel it captures the feeling of this trip very much!&lt;br/&gt;&lt;br/&gt;So Go Goa …&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-1137642149583869992?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/1137642149583869992'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/1137642149583869992'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2007/07/go-goa.html' title='Go Goa'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-7388414763583127870</id><published>2007-07-03T08:30:00.000-07:00</published><updated>2010-05-29T01:38:40.953-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spacers'/><category scheme='http://www.blogger.com/atom/ns#' term='RIA'/><category scheme='http://www.blogger.com/atom/ns#' term='Coding'/><title type='text'>Switching on Silverlight</title><content type='html'>“Web is approaching the desktop” – Wahid Bhai said while demonstrating the new &lt;a target="_blank" href="http://www.adobe.com/products/flex/" title="Flex"&gt;Flex&lt;/a&gt; project at KAZ. Flex is Flash but on steroids... well to be truthful Flex is Flash with libraries and an easy programming model and the nicest of all - a good eclipse based  IDE.&lt;br/&gt;&lt;br/&gt;Microsoft has of course an answer to Flex - The &lt;a target="_blank" href="http://silverlight.net" title="Silverlight"&gt;Silverlight&lt;/a&gt; which used to be known as WPF/e for a while.  In Microsoft's wording:&lt;br/&gt;&lt;br/&gt;&lt;em&gt;"Silverlight is Microsoft’s latest technology to design interactive web client with truly object oriented language C# with full support of VB .NET and other .NET citizens.  Microsoft® Silverlight™ is a cross-browser, cross-platform plug-in for delivering the next generation of .NET based media experiences and rich interactive applications for the Web ... Silverlight offers a flexible programming model that supports AJAX, VB, C#, Python, and Ruby, and integrates with existing Web applications. Silverlight supports video to all major browsers running on the Mac OS or Windows.... " (the babble continues promising cure for cancer, food for Sudan and even the impossible - patriotism for the Bangladeshi middle class!)&lt;/em&gt;&lt;br/&gt;&lt;br/&gt;Back on Earth, we the "Psycho group" at KAZ had a week of free time in between projects. So in the time honored way at KAZ we decided to do a &lt;em&gt;spacer&lt;/em&gt; project to try out silverlight in all its Alpha glory and MS’s super hype!  We decided to make a webtop with silverlight that would show an abstracted backend filesystem exposed by WCF.&lt;br/&gt;&lt;br/&gt;This post is about our pains and joys during the project.  Not gifted with great writing skills (apart from the coding kind) I will try putting down disperate items that we learnt or I felt like telling about our project.&lt;br/&gt; &lt;br/&gt;&lt;strong&gt;First principle&lt;/strong&gt;&lt;br/&gt;Starting from Silverlight 1.1 the managed code is supported at client side. We decided to be very strict in this project to use only managed code for programming- no JavaScript.  Like all principles this soon turned out to be a pain in a not so polite place :)&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Installing Silverlight&lt;/strong&gt;&lt;br/&gt;To develop with Silverlight 1.1 you need Visual Studio 2008 (code name Orcas). While writing this downloadable beta version is available from Microsoft site. You also need Silverlight 1.1 plug-in distribution – alpha is available while writing this. Though not necessary the Silverlight 1.1 SDK is highly recommended. The SDK includes controls, samples, documents which may be useful to start. Please note that the Silverlight plug-in is required on any client from where the site is viewed.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Controls that comes from Boss&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;None!&lt;br/&gt;&lt;br/&gt;Well not exactly true, but close enough. Silverlight 1.1 alpha distribution comes with a very limited set of controls. It has controls like rectangle, ellipse and label, canvas. It does not include button, edit box, scroll bar or any other advanced control. The SDK includes some controls like scrollbars.&lt;br/&gt;&lt;strong&gt; &lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Our Architecture&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;With no major controls available and no infrastructure for a shell, we soon realized that we need a petzold like approach to the project. We actually need to create a windowing system and the bare basics of message management.&lt;br/&gt;&lt;br/&gt;Our final designe came out with 3 layers. Top layer is the application layer where user applications run. Middle layer is kernel which controls the events and communication between applications. It also provides a set of API for application developers. The lowest layer is an abstraction layer to communicate with the web server.&lt;br/&gt;&lt;br/&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/image002.jpg" title="Architecture"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/image002.jpg" alt="Architecture" /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;The system provides API’s for application developers for the platform while hiding the http calls – making the application development similar to desktop application development. Web call abstraction layer does that for user application. &lt;br/&gt;&lt;br/&gt;&lt;strong&gt;The Kernel&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;The controller behind the scene controls form events, focus of controls, controls and windows to common file operations. The kernel has four main parts:&lt;br/&gt;•          Messaging System and Focus Manager&lt;br/&gt;•          Window Manager&lt;br/&gt;•          Process Manager&lt;br/&gt;•          File system Driver&lt;br/&gt;•          Resource Manager&lt;br/&gt;&lt;br/&gt; &lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/image010.jpg" title="Kernel"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/image010.jpg" alt="Kernel" /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Messaging System and Focus Manager&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;An event first comes to this manager and depending on the type routed to controls. If the user clicks on a control the focus manager updates the focus of controls. It keeps track of current on focus control. If it finds a change in focus it send OnLostFocus call to old control and OnSetFocus call to new focused control. With this exception most messages are routed to the focused control on arrival.&lt;br/&gt;&lt;strong&gt; &lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Window Manager&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;The window manager keeps track of each window that is created on the system. At any time window manager provides the list of windows currently available in the system. A utility application like TaskManager or TaskBar can use the list for display and control the windows. In our case the TaskBar buttons are created from the list and user can control minimize or restore operation from the TaskBar application. To keep track of the windows the window manager uses an internal generic Window list. When a new window is created the window is registered with window manager and when a window is disposed the window is unregistered.&lt;br/&gt;&lt;strong&gt; &lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Process Manager&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;The SilverlightDesktop applications that are created by implementing the IApplication interface in the main class are managed by the process manager. The process manager exposes a service to create a new process. It accepts class name as its first parameter and other parameters are passed through a Parameter object that can contain strings. On success the process manager returns a Instance object that can identify the process. Simplified version of Instance class is like this –&lt;br/&gt;&lt;blockquote&gt;public class Instance&lt;br/&gt;{&lt;br/&gt;      public int Handle;&lt;br/&gt;      public int ParentHandle;&lt;br/&gt;      public string Name;&lt;br/&gt; }&lt;/blockquote&gt;&lt;br/&gt;The returned interface object can uniquely identify the process and it is required to handle the process.&lt;br/&gt;&lt;br/&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/image011.jpg" title="Lifecycle"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/image011.jpg" alt="Lifecycle" /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Designing a new control&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;ControlBase class can be extended to design a custom control. The control may have a xaml also.  The ControlBase getter ResourceName of type string should be overirden to specify the name of the xaml resource in the assembly. It is also possible to set the assembly of the control. The constructor of ControlBase class iterates through each resource and look for the specified resource to get the right xaml resource. Same technique is used in the Silverlight SDK. For example we want to have a icon control that has a image and text. Our xampl file would be similar to this:&lt;br/&gt;&lt;blockquote&gt;&amp;lt;Canvas xmlns="&lt;a href="http://schemas.microsoft.com/client/2007"&gt;http://schemas.microsoft.com/client/2007&lt;/a&gt;"&lt;br/&gt;        xmlns:x="&lt;a href="http://schemas.microsoft.com/winfx/2006/xaml"&gt;http://schemas.microsoft.com/winfx/2006/xaml&lt;/a&gt;"&lt;br/&gt;        Width="32"&lt;br/&gt;        Height="50" x:Name="_container"&lt;br/&gt;        &amp;gt;&lt;br/&gt;  &amp;lt;Canvas x:Name="_icon" Width="32" Height="32" Canvas.Left="0" Canvas.Top="0"/&amp;gt;&lt;br/&gt;  &amp;lt;TextBlock x:Name="_name" Width="80" Height="15" Canvas.Left="-24" Canvas.Top="32" /&amp;gt;&lt;br/&gt;&amp;lt;/Canvas&amp;gt;&lt;/blockquote&gt;&lt;br/&gt;We used a Canvas for icon, a TextBlock for label and a container canvas to hold them both.&lt;br/&gt;And our code back for the control would be:&lt;br/&gt;&lt;blockquote&gt; public class Icon : ControlBase&lt;br/&gt;{&lt;br/&gt;        Canvas icon;&lt;br/&gt;        TextBlock text;&lt;br/&gt;        Canvas container;&lt;br/&gt;        protected override void OnInitialized()&lt;br/&gt;        {&lt;br/&gt;            icon = actualControl.FindName("_icon") as Canvas;&lt;br/&gt;            text = actualControl.FindName("_name") as TextBlock;&lt;br/&gt;            container = actualControl.FindName("_container") as Canvas;&lt;br/&gt;        }&lt;br/&gt;        protected override string ResourceName&lt;br/&gt;        {&lt;br/&gt;            get { return "Icon.xaml"; }&lt;br/&gt;        }&lt;br/&gt;}&lt;/blockquote&gt;&lt;br/&gt;Now if we add some getter/setter we get the icon control ready to be used.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;The Window&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;Window is a customized control- but is different from others. It uses mouse events to implement feature like drag/ drop, has a title bar and sizing buttons for minimize to system taskbar, maximize to cover full user desktop area or close button to close and dispose the control from the system.&lt;br/&gt;&lt;br/&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/image009.jpg" title="Window"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/2007/07/image009.jpg" alt="Window" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-7388414763583127870?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/7388414763583127870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/7388414763583127870'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2007/07/switching-on-silverlight.html' title='Switching on Silverlight'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-5264097165198839582</id><published>2007-06-17T04:20:00.000-07:00</published><updated>2010-05-29T01:38:40.957-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Adventures'/><title type='text'>The pilgrimage to the land of mangoes</title><content type='html'>&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/06/mangoes.jpg" title="Mango Garden"&gt;&lt;/a&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/06/mangoes-at-kaz.jpg" title="The loot"&gt;&lt;/a&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/06/mangoes-at-kaz.jpg" title="The loot"&gt;&lt;/a&gt;I belong here. I was designed for this. This was my intended use. This was supposed to be my platform. This is my OS.&lt;br/&gt;&lt;br/&gt;This is of course the land of mangoes – the great Chapai Nawabgonj.&lt;br/&gt;&lt;br/&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/06/mangoes.jpg" title="Mango Garden"&gt;&lt;img align="middle" src="http://www.kaz.com.bd/blog/wp-content/uploads/2007/06/mangoes.jpg" alt="Mango Garden" title="Mango Garden" /&gt;&lt;/a&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/06/mangoes-at-kaz.jpg" title="The loot"&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;Last Friday few of the mango crazed KAZ members (I among them) went out for the ultimate trip to Chapai. Nothing was strong enough to stop us - the hardship of waking up at the ungodly hour of five in the morning (a personal record for one guy at least), the unthinkable scenario of being away from a computer for two whole days… nothing! We were unstoppable, we were out to win and we were out to meet our love.&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/2007/06/mangoes-at-kaz.jpg" title="The loot"&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;Why are mangoes so good? Why do even the most timid of the human race – the techies - become the gladiators when it comes to mangoes? Is there any answer to these questions?&lt;br/&gt;&lt;br/&gt;Some things in this world are just without equations – this I am sure is one of them.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-5264097165198839582?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/5264097165198839582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/5264097165198839582'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2007/06/pilgrimage-to-land-of-mangoes.html' title='The pilgrimage to the land of mangoes'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-6298782952156623944</id><published>2007-06-12T04:53:00.000-07:00</published><updated>2010-05-29T01:38:40.959-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Designing'/><title type='text'>Patterns in workspace design</title><content type='html'>&lt;font face="Times New Roman"&gt;With the designer workspace project in progress at KAZ, I was revisiting the principles for achieving the perfect design of workspaces. These patterns as they are formally called were the guiding light when we were planning the Nirvana (our office space).&lt;/font&gt;&lt;font face="Times New Roman"&gt; &lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;Software has patterns. Patterns are tried and tested ways of architecting systems that just work perfectly for a broad set of similar problems. Made famous by the gang of four (GOF) in the early 90s when they published their book &lt;a href="http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612"&gt;Desgin patterns&lt;/a&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;Interestingly the idea of patterns comes not from software but from architecture. We all have felt that some buildings or houses just feels more comfortable from others. There are some places where an adda is always a good adda. The person who put this into concrete form was &lt;a href="http://en.wikipedia.org/wiki/Christopher_Alexander"&gt;Christopher Alexander&lt;/a&gt; &lt;/font&gt;&lt;font face="Times New Roman"&gt;in his book &lt;a href="http://www.amazon.com/Timeless-Way-Building-Christopher-Alexander/dp/0195024028/ref=pd_bxgy_b_text_b/103-1551294-6483037"&gt;The Timeless Way of Building&lt;/a&gt;. &lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;Since I can’t possibly describe this better than the great guy himself, let me quote from the book itself:&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;“There is one timeless way of building. It is a thousand years old, and the same today as it has ever been. The great traditional buildings of the past, the villages and tents and temples in which man feels at home, have always been made by people who were very close to the center of this way. It is not possible to make great buildings, or great towns, beautiful places, places where you feel yourself, places where you feel alive, except by following this way. And, as you will see, this way will lead anyone who looks for it to buildings which are themselves as ancient in their form, as the trees and hills, and as our faces are. ” &lt;/em&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;As the quote sort of hints, the book was more philosophy than practical hints about the patterns. The next book was the practitioners handbook for the patterns – the analogy of the GOF book in architecture: &lt;/font&gt;&lt;font face="Times New Roman"&gt;&lt;a href="http://www.amazon.com/Pattern-Language-Buildings-Construction-Environmental/dp/0195019199"&gt;A Pattern Language: Towns, Buildings, Construction&lt;/a&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt;. One of my all time favorites, this book is worth reading just for your soul.&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;img align="right" width="250" src="http://www.kaz.com.bd/blog/userpic/a_pattern_lang.gif" alt="Pattern Language Cover" height="360" /&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;Before being carried away let me pin down a few patterns that is very relevant to workspaces and that we are definitely consulting during the planning. All of the following are stolen from the great book. &lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;Note that the numbers represent the pattern number used in the book (there were 253 catalogued). You can get a whole list of patterns &lt;a href="http://downlode.org/etext/patterns/"&gt;here&lt;/a&gt;.&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;strong&gt;134 Zen View&lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt; &lt;/em&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;font face="Times New Roman"&gt;If there is a beautiful view, don't spoil it by building huge windows that gape incessantly at it. Instead, put the windows which look onto the view at places of transition- along paths, in hallways, in entry ways, on stairs, between rooms.&lt;/font&gt; &lt;/em&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;strong&gt;135 Tapestry of Light and Dark&lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;Create alternating areas of light and dark throughout the building, in such a way that people naturally walk towards the light, whenever they are going to important places: seats, entrances, stairs, passages, places of special beauty, and make other areas darker, to increase the contrast.&lt;/em&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt; &lt;/font&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;strong&gt; &lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;strong&gt;146. Flexible Office Space&lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;Lay out the office space as wings of open space, with free standing columns around their edges, so they define half-private and common spaces opening into one another. Set down enough columns so that people can fill them in over the years, in many different ways- but always in a semipermanent fashion.&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt; &lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;strong&gt;152 Half-Private Office&lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt; &lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;Avoid closed off, separate, or private offices. make every workroom, whether it is for a group of two or three people or for one person, half-open to the other workgroups and the world immediately beyond it. At the front, just inside the door, make comfortable sitting space, with the actual workspace(s) away from the door, and further back.&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt; &lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;strong&gt;183 Workspace Enclosures&lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt; &lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;Build each workspace an area of at least 60 square feet. Build walls and windows round each workspace to such an extent that their total area (counting windows at one-half) is 50 to 75 per cent of the total enclosure that would be there if all four walls around the 60 square feet were solid. Let the front of the workspace be open for at least 8 feet in front, always into a larger space. Place the desk so that the person working at it has a view out either to the front or to the side. If there are other people working nearby, arrange the enclosure so that the person has a sense of connection to two or three others; but never put more than eighth workspaces with view or earshot of one another.&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt; &lt;/font&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;strong&gt; &lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;strong&gt;185 Sitting Circle&lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt; &lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;font face="Times New Roman"&gt;Place each sitting space in a position which is protected not cut by paths or movement, roughly circular, made so that the room itself helps to suggest the circle- not too strongly- with paths and activities around it, so that people naturally gravitate toward the chairs and cushions loosely in the circle, and have a few too many.&lt;/font&gt; &lt;/em&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;strong&gt; &lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;strong&gt;250 Warm Colours&lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt; &lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;Choose surface colours which, together with the colour of the natural light, reflected light, and artificial lights, &lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;create a warm light in the rooms.&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt; &lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;strong&gt; &lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;&lt;strong&gt;252 Pools of Light&lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt; &lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;font face="Times New Roman"&gt;&lt;em&gt;Place the lights low, and apart, to form individual pools of light which encompass chairs and tables like bubbles to reinforce the social character of the spaces which they form. Remember that you can't have pools of light without the darker places in between.&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-6298782952156623944?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/6298782952156623944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/6298782952156623944'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2007/06/patterns-in-workspace-design.html' title='Patterns in workspace design'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8000681016804453978.post-3717762308358621039</id><published>2007-06-10T06:35:00.000-07:00</published><updated>2010-05-29T01:38:40.962-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Designing'/><title type='text'>A designer’s work space</title><content type='html'>&lt;p &gt;working as a graphics designer for quite a long time now but when Wahid (CTO of &lt;a href="http://www.kaz.com.bd"&gt;KAZ software&lt;/a&gt;) told &lt;a href="http://www.zahidur59.net" title="Zahid's Website"&gt;me&lt;/a&gt; and &lt;a href="http://www.studiomaqs.com"&gt;Maq&lt;/a&gt; (my designer buddy) to do an interior design for the new design team room, the exact sound came through my through was “Glip’. I have some rough idea about interior designers but no clue about their actual work. But Wahid was pretty serious about this project. His exact words were “&lt;em&gt;You designers act like you are from a different planet. Like you are some different species. A better one you claim. Well … prove it. I want people to walk into your room and say … WOW&lt;/em&gt;”. So, after spending some quality time in our recreation room, me and Maq decided that we really should start planning.&lt;/p&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/roompic1.jpg" target="_blank"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/roompic1.jpg" alt="The Room" style="width: 450px; height: 337px" title="The Room" border="0" height="337" width="450" /&gt;&lt;/a&gt;&lt;br/&gt;&lt;/font&gt;&lt;br/&gt;&lt;H3&gt;The theme&lt;/H3&gt;&lt;br/&gt;&lt;P&gt;We were given an 11.3 by 10 feet room. Now all we need to do is visualize the WOW part. The rooms should imply that it’s the designer’s room. Only the dumbest should walk into the room and wonder if this is the designing section. We want the room as comfy as possible. To us, that means a lot of free space. Which is our challenge number two as the room is not big enough to fit all our ideas that are yet to come. Challenge number one is to decorate without giving it a cheep Chinese restaurant look.&lt;/P&gt;&lt;br/&gt;&lt;H3&gt;The budget&lt;/H3&gt;&lt;br/&gt;&lt;p&gt;Wahid said don’t think of the budget. Just visualize whatever you want to do with the room. I don’t mind. I have scissors.&lt;/p&gt;&lt;br/&gt;&lt;H3&gt;So what dose a designer needs to do his things&lt;/H3&gt;&lt;br/&gt;&lt;P&gt;On my first day at work in here, Wahid asked what I need to setup my workstation. Before I can answer that, Jewel from Java team jumped in and said “That’s easy. All a designer need is a big fat TV set”.&lt;span&gt;  &lt;/span&gt;I guess he was referring to my 19 inch monitor. Yes what would we do without it? Plus a sketch table would be nice. Through in a couch and&lt;span&gt;   &lt;/span&gt;two Bose speakers and .. well this list will never end so let just stick with the desktop and the sketch board for now.&lt;/P&gt;&lt;br/&gt;&lt;H3&gt;The visual presentations&lt;/H3&gt;&lt;br/&gt;&lt;P&gt;After some struggle we came up with some visual presentations. The very first sketch looks like this &lt;/P&gt;&lt;br/&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;font face="Times New Roman"&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/sch1.jpg" target="_blank"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/sch1.jpg" alt="sketch1" style="width: 450px; height: 434px" title="sketch1" border="0" height="434" width="450" /&gt;&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;&lt;br/&gt;&lt;p&gt;And the layout diagram-&lt;/P&gt;&lt;br/&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/sch5.jpg" target="_blank"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/sch5.jpg" alt="Layout Diagram" style="width: 450px; height: 396px" title="Layout Diagram" border="0" height="396" width="450" /&gt;&lt;/a&gt; &lt;font face="Times New Roman"&gt; &lt;/font&gt;&lt;br/&gt;&lt;p&gt;With a little help of Adobe Photoshop -&lt;/p&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/sch2.jpg" target="_blank"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/sch2.jpg" alt="Visualiztion of the design " style="width: 450px; height: 434px" title="Visualiztion of the design " border="0" height="434" width="450" /&gt;&lt;/a&gt; &lt;/font&gt;&lt;br/&gt;&lt;p&gt;Here is a dimmed version -&lt;/p&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/sch3.jpg" target="_blank"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/sch3.jpg" alt="Visualization Dark version" style="width: 450px; height: 434px" title="Visualization Dark version" border="0" height="434" width="450" /&gt;&lt;/a&gt; &lt;/font&gt;&lt;br/&gt;&lt;p&gt;Ok we do agree it looks pretty common so where is the struggling part? First let us explain our ideas and restrains.&lt;/p&gt;&lt;br/&gt;&lt;font face="Times New Roman"&gt;&lt;a href="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/sch6.jpg" target="_blank"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/sch6.jpg" alt="Elements" style="width: 450px; height: 434px" title="Elements" border="0" height="434" width="450" /&gt;&lt;/a&gt; &lt;/font&gt;&lt;br/&gt;&lt;p&gt;The room has couple of windows that really don’t go with our theme. Plus Maq and I decided to have a rather dimmed room. So we decided to put a shade on those windows. But not with those dull, boring ones. We want something visually more pleasant. So we though it would be great to find a shade with a great painting on it. Wahid said this would be almost impossible. Let’s see.&lt;/p&gt;&lt;br/&gt;&lt;p&gt;We want a double plated glass frame for a wall painting. This should have an irregular shape and an easy mechanism to install the painting. We want to change it frequently. A light source mounted on top will illuminate the artwork. One of our shelves will be made out of a tree with its original shape preserved. An aquarium for out pet turtles will be placed in the other triangular shelf. Originally, Maq wants to have some snakes but that might be too disturbing for some people so we settle with turtles. Well these are our startup ideas.&lt;/p&gt;&lt;br/&gt;&lt;p&gt;So where is the struggling part again? Well I guess that's hidden in the implementation phase.&lt;/p&gt;&lt;br/&gt;&lt;p&gt;Oh … another great idea is to blog about this project on step by step progress so you can expect to see more updates on this soon.&lt;/p&gt;&lt;br/&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;&lt;br/&gt;&lt;p style="margin: 0in 0in 0pt" class="MsoNormal"&gt;&lt;font face="Times New Roman"&gt;&lt;img src="http://www.kaz.com.bd/blog/wp-content/uploads/userpic/sch1.jpg" alt="sketch 1" style="width: 0px; height: 0px" title="sketch 1" border="0" /&gt;&lt;/font&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8000681016804453978-3717762308358621039?l=blog.kaz.com.bd' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/3717762308358621039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8000681016804453978/posts/default/3717762308358621039'/><link rel='alternate' type='text/html' href='http://blog.kaz.com.bd/2007/06/designers-work-space.html' title='A designer’s work space'/><author><name>KaZeitgeist</name><uri>http://www.blogger.com/profile/06086679851374940061</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>
