quinta-feira, 24 de outubro de 2013

Condorcet's paradox

The voting paradox (also known as Condorcet's paradox or the paradox of voting) is a situation noted by the Marquis de Condorcet in the late 18th century, in which collective preferences can be cyclic (i.e. not transitive), even if the preferences of individual voters are not. This is paradoxical, because it means that majority wishes can be in conflict with each other. When this occurs, it is because the conflicting majorities are each made up of different groups of individuals.
For example, suppose we have three candidates, A, B, and C, and that there are three voters with preferences as follows (candidates being listed in decreasing order of preference):
Voter First preference Second preference Third preference
Voter 1 A B C
Voter 2 B C A
Voter 3 C A B

terça-feira, 15 de outubro de 2013

Placing too much reliance on tools


Placing too much reliance on tools—If you listen to the big tool vendors, and even some open source ones, you can buy SOA governance. Just buy their SOA registry and you have a SOA governance solution. Unfortunately, that isn’t the case. Tools can help immensely in applying SOA governance, but they’ll always support the policies that have been designed, the reference architecture that has been defined, and the processes that have been put into place.

IT project failures


In the previous sidebar I used Enron as an example of why governance within a company is needed. IT projects also have a tendency to go seriously wrong if there isn’t a good governance or control mechanism in place. One of the most talked-about examples is the Denver International Airport’s automated baggage system. This baggage system, created for the new airport, was designed to route all the passenger’s bags to and from aircraft without human intervention. Even though this system was eventually completed ($55 million over budget) it didn’t work. The carts that were used to automatically transfer the bags couldn’t cope with sharp corners, sensors lost track of where bags were in the system, and more problems were present in the system.
All this caused the Denver airport to open 16 months late so that the system could be fixed and added a total of $560 million to the cost of the airport. After a couple of years, though, the system was abandoned completely. Another example is the automated fulfillment system developed for Sainsbury’s, a British supermarket. Sainsbury’s wanted a new system for its main distribution center. This barcode-based system was designed to save a huge amount of money and increase efficiency because a lot of human tasks could be automated. In the end though, the system, installed in 2003, failed because of apparent barcode-reading errors. After two years of bug fixing, Sainsbury’s wrote that the system worked as intended.In 2007,  however, the complete system was scrapped. Total write off: £150 million.

segunda-feira, 14 de outubro de 2013

% Failed Projects


SOA/Governance - One of the main reasons governance has become an important part of how a business operates

The Enron scandal

One of the main reasons governance has become an important part of how a business operates is because of the scandals at the beginning of the last decade. The most prominent was the Enron scandal. Enron, which was an energy corporation from Houston, at its peak had a value of $111 billion; a year later it filed for bankruptcy. In the nineties the energy market in California was deregulated, and Enron quickly became
one of the largest energy companies in the United States. But in 2001 investigations were initiated to look into the financial position of Enron, and all kinds of fraudulent practices were discovered. For instance, Enron stored its debts in foreign accounts and used its political influence to raise the price of energy. To makes matters even worse, high-ranking Enron executives sold most of their stock when the shares were at $90, the highest the shares reached. They did this because they knew Enron was accruing massive losses. On the other hand, the public was encouraged to buy Enron stock, which within a few months dropped to 30 cents per share. The Enron executives were charged with bank fraud, securities fraud, wire fraud, money laundering, conspiracy, and insider trading. As a result of the Enron scandal, the federal government passed the Sarbanes-Oxley act (SOX for short), which forces companies to follow a set of policies with regard to reporting information to their investors and mandates that companies have strict internal financial control mechanisms in place.

sexta-feira, 11 de outubro de 2013

XMLDocument - Going through ChildNodes.


This example is really simple.

The taks is to get the books from the XML.

What I did.

1 - I created a internal class called Book.
2 - A declaration of a list of books
3 - The XML we're gonna use.
4 - Instantiating the XMLDocument class.
5 - LoadXML
6 - Using the method GetElementsByTagName. Very usefull to get lists inside XMLs.
7 - A for to go through the items. It's weird that ChildNodes is after Item(0), but that's the way it is.
8 - Each item is a node of nodes. To access each node of a item, you have to use SelectSingleNode.
9 - Fill the class object with the Nodes' values.
10 - Fill the list of books.
11 - End.

using System.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Data;
using System.Collections;

namespace ConsoleApplication1
{
    /// <summary>
    ///
    /// </summary>
    class Program
    {
        class Book
        {
            public Int32 Number = 0;
            public string Name = "";
            public Decimal Price = 0.0M;
        }
        static void Main(string[] args)
        {

            List<Book> lstBooks = new List<Book>();

            string lStrXML = "";
            lStrXML += "<Library>";
            lStrXML += "<Address type='String'>Washington D.C.</Address>";
            lStrXML += "<Books>";
            lStrXML += "<item>";
            lStrXML += "<Number type='Integer'>1</Number>";
            lStrXML += "<Name type='String'>The Game Of Thrones</Name>";
            lStrXML += "<Price type='Decimal'>7.0</Price>";
            lStrXML += "</item>";
            lStrXML += "<item>";
            lStrXML += "<Number type='Integer'>2</Number>";
            lStrXML += "<Name type='String'>Dune</Name>";
            lStrXML += "<Price type='Decimal'>4.0</Price>";
            lStrXML += "</item>";
            lStrXML += "<item>";
            lStrXML += "<Number type='Integer'>3</Number>";
            lStrXML += "<Name type='String'>The Mists Of Avalon</Name>";
            lStrXML += "<Price type='Decimal'>6.0</Price>";
            lStrXML += "</item>";
            lStrXML += "</Books>";
            lStrXML += "</Library>";

            XmlDocument lobj = new XmlDocument();

            lobj.LoadXml(lStrXML);

            XmlNodeList lObjBooks = lobj.GetElementsByTagName("Books");

            foreach (XmlNode lObjXBook in lObjBooks.Item(0).ChildNodes)
            {
                Book lObjBook = new Book();
                Int32.TryParse(lObjXBook.SelectSingleNode("Number").InnerText, out lObjBook.Number);
                lObjBook.Name = lObjXBook.SelectSingleNode("Name").InnerText;
                Decimal.TryParse(lObjXBook.SelectSingleNode("Price").InnerText, out lObjBook.Price);

                lstBooks.Add(lObjBook);
            }

           

        }


    }
}

sexta-feira, 4 de outubro de 2013

Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding . The base address schemes are [ http , https ] .

Hi!

If you are receiving this error when you try to access your webservice, something like http://www.you.com/yourservice.svc?wsdl. The solution might be simple.
 

Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding . The base address schemes are [ http , https ] .Description : An unhandled exception occurred during the execution of the current web request Please review the stack trace for more information about the error and where it originated in the code .
Exception Details : System.InvalidOperationException : Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding . The base address schemes are [ http , https ] .
Source Error :Unhandled exception was generated during the execution of the current web request Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace :
[ InvalidOperationException : Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding . The base address schemes are [ http , https ] . ]
   
System.ServiceModel.ServiceHostBase.MakeAbsoluteUri ( Uri relativeOrAbsoluteUri , Binding binding , UriSchemeKeyedCollection baseAddresses ) +12349612
   
System.ServiceModel.Description.ConfigLoader.LoadServiceDescription ( ServiceHostBase host ServiceDescription description , ServiceElement serviceElement , Action ` 1 AddBaseAddress ) +12346965
   
System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal ( ConfigLoader configLoader , ServiceDescription description , ServiceElement serviceSection ) +67
   
System.ServiceModel.ServiceHostBase.ApplyConfiguration ( ) +108
   
System.ServiceModel.ServiceHostBase.InitializeDescription ( UriSchemeKeyedCollection baseAddresses ) +192
   
System.ServiceModel.ServiceHost.InitializeDescription (Type serviceType , UriSchemeKeyedCollection baseAddresses ) +49
   
System.ServiceModel.ServiceHost .. ctor (Type serviceType , Uri [ ] baseAddresses ) +151
   
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost (Type serviceType , Uri [ ] baseAddresses ) +30
   
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost ( constructorString String , Uri [ ] baseAddresses ) +422
   
System.ServiceModel.HostingManager.CreateService ( String normalizedVirtualPath ) +1461
   
System.ServiceModel.HostingManager.ActivateService ( String normalizedVirtualPath ) +44
   
System.ServiceModel.HostingManager.EnsureServiceAvailable ( String normalizedVirtualPath ) +651
[ ServiceActivationException : Can not activate service ' / Fibra.Barramento.Calculo / Motor.svc ' due to an exception during compilation . The exception message is : Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding . The base address schemes are [ http , https ] ..]
   
System.Runtime.AsyncResult.End ( IAsyncResult result ) +688590
   
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End ( IAsyncResult result ) +190
   
System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest ( IAsyncResult ar) +310694
   
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion ( IAsyncResult ar) +94



Maybe, all you have to do is enable the protocol. The default protocol is http. Net.tcp must be enabled manually. So, add net.tcp, clicking on advanced settings and that's it.
 



Could not load type System.ServiceModel.Activation.HttpModule assembly System.ServiceModel, Version = 3.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089.

Well, this error took me a lot of time to understand. The message is completely misleading.
In my case the problem was that IIS had two versions of ServiceModel. For some reason the application was trying to load System.ServiceModel.dll version 3.0.0.0 , but was "suprised" by the version 4.0.0.0.
So, what was my solution? I removed the version 3. Did something crash? Not at all. Everything is working fine.
Never had the error again.
Há!