ASP.NET Flies

There is an old Turkish saying that

The fly is small but it nauseates

There are few development flies in ASP.NET platform such this fly story. In general these issues slow down the web development processes and produce dirtiness in code and HTML output. I think interpreted server side scripts like PHP can deal this problems more clearer and cleaner way.

Fly Comic

Initial Post-Compilation Delays

If you work in small projects i doesn’t disturb so much at the begining but when your project get more enterprise with O/R mappings, logging libraries, security enviroment and web services testing your code with continues bug fixes become a real pain. Every time you compile your code it costs lots of seconds with initial execution and finally these seconds take your so valuable time. It’s a well known and common issue but it disturbs if your code has growed a lot.

Session Variables Losts

If your web project is released and used by many users, some critical and important data in session variables losts by an urgent update or bug fix in application, even when you make a change in .aspx files. This effects users experience with your application and it’s a disturbing issue too.

Postaback Design Issue

In traditional web development data transfers supplied by various form POST and url GET methods by a simple usage. They have cleaner way to sending data to server side. But when postback pattern in ASP.NET came into our life which simply combines javascript and encrypted form data states stay in hidden form inputs named viewstate, all our simple data transfer methodologies blured and became more complex. You lost in the questions such “Should i use querstrings or POST data or postback data?”. Think that you have a relational database project such an e-commerce application and you want to reference a product in Products page with a link from Orders page. If you all use postback pattern in your design, your code become more complex with a few code additions for querystring parameterizing. Probably you felt into these doubts such these problems.

On the fly Updates and Critical Bug Fixes

Suppose that it’s Sunday and you’re getting a calm day on the sofa by the televison, but suddenly you got news that your application felt down at that night and you have to get over that crash as soon as possible. You don’t have any chance or boss tolerance for any customer lost. But the real bad thing is your all source code is at work with your favourite IDE Visual Studio and you don’t have a chance to debug your application unless you get to work with office’s key. If your application was a PHP project the only thing you need is FTP keys. This is a small example, and can be produced more over on likely situations.

Web Standarts and AJAX

It’s very important point that web developers want to take control over the pure HTML input and output. With ASP.NET, it’s structure and it’s web controls always force to use us postbacks, viewstates, none sense table datas, invalid XHTML output. There is an option in web.config about XHTML conformce but it’s not enough. You will say that you can implement postbackless applications but it is again time consuming. And again if you want to use pure AJAX / JSON callbacks or use javascript frameworks like Prototype or JQuery, postback structure that forced you to use by ASP.NET doesn’t let you make things clearer and cleaner. It plays with it’s own rules like ATLAS etc.

Although all these problems for me seems small , they cause big headeches if they iterate a lot and you may get tired of coding web applications with ASP.NET like me. I really get bored of developing web applications in ASP.NET such jumping variables on postbacks one to one and binding data to that useless grids. I now hate postbacks and viewstates and i think the clearest and cleanest way for web development seems PHP with new OO features.

All around these thoughts, neither PHP nor Ror can be as powerful as dotnet platform. I will be waiting for ASP.NET MVC Framework. At least when it shiped to us we won’t have to play with postbacks, and have full control over HTML.

LINQ To Sql tutorial Series By Scott Guthrie (Pdf Book Format)

Linq To Sql Pdf

Scott Guthrie’s great ‘LINQ To Sql’ tutorial series in PDF book format. You can download it from here.

kick it on DotNetKicks.com

Microsoft .NET Framework Libraries Are Now Source Free

About ten days ago Scott Guthrie announced on his this blog that .net framework libraries will be entirely visible to developers under Microsoft Reference License. This is so exciting news from Microsoft that this gives it one more bonus point where things will be more clean for developers who follows Microsoft platform software stacks.

If you’ re familiar .net framework development you should know that Lutz Roeder’s Reflector has provided this functionality for years. It simply disassembles .net framework class libraries to c# or vb.net code so we could become aware of how things done within the libraries. But now developers are be able to debug their applications through .net framework source code and browse free with Visual Studio 2008. Follow Scott Guthrie’s blog post for details.

Visual Studio Aims Independent Eclipse Community

VsxWith the upcoming release of Visual Studio 2008 comes with new software development ecosystem named Visual Studio Shell. Infact it’s not new at all. Visual Studio only exposes it’s shell enviroment freely to various software development vendors and individual software developers. Here the word ‘new’ points that suprisingly Microsoft’s revolution strategy speeded up for breaking the idea of anti-Microsoft approach that disperses from OPEN SOURCE sympathizers to the whole world.

In brief Visual Studio Shell let software vendors add new features (plug-ins) to Visual Studio or use it as an enviroment in their individual projects. This means that will not suprise us coding pure JAVA (not J#) in Visual Studio enviroment. It should be a dream!

The shell comes with integrated and a new isolated mode. Integrated mode provides visual studio enviroment to extend existing instance of developer’s Visual Studio 2008 installation. There is better news that isolated mode exactly works as a seperate instance and interface uses Visual Studio Shell without the requirement of visual studio installation. I can hear you… Yes it is an Eclipse core feature. If you are not familiar to famous open source Eclipse IDE platform mostly used by JAVA developers, it entirely exposes it’s shell enviroment (workbenchs, views etc…) to plug-ins or for other standalone softwares. For example Adobe provides Flex development enviroment as either a standalone Eclipse based IDE (using Eclipse RPC) or plug-ins (Eclipse PDE) that can be added to an existing Eclipse installation. This shows us Microsoft’s idea is certainly inspired from Eclipse and it aims to gain whoever Eclipse’s commercial and non-commercial ISV’s anyway.

Finally i want to share a quote from an interview with Anders Hejlsberg who is chief architect of the Visual C# language and has been a key developer of the company’s .Net application development technology. His answers followed like below against the questions from InfoWorld.

InfoWorld: What is your take on Eclipse and the Eclipse Foundation and Eclipse IDE? At this point Eclipse has Sun and Microsoft not participating and everybody else pretty much is. What does that mean?

Hejlsberg: Eclipse is an open source project built around the Java platform, so I don’t think it’s so surprising that we’re not partaking there. I would say we’re competing there, and I think we’re competing quite well with Visual Studio. A lot of the features you see in Visual Studio 2005 bring us not just neck to neck, but ahead of Eclipse, and I think it’s healthy to have competition. As always, it’s going to keep us on our toes and it’s going to keep them on their toes.

InfoWorld: But you have to spend money for Visual Studio and you can download Eclipse for nothing.

Hejlsberg: That all depends on how you look at it. You can download the Visual Studio 2005 Express Editions for nothing, and I would argue that in many ways they are better, more deeply integrated tools than some of the stuff you can do with Eclipse. And conversely, with Eclipse you typically end up paying money anyway because you buy a particular distribution of it and you buy it as part of [IBM] WebSphere or whatever and you actually do pay money. So it’s not that clear, it’s a bit of a fallacy that everything is free in that space and everything costs money with our platform.

Is the word Open Source itself a shell? Is used for marketing goals by some profit-units in software industry? Is Microsoft really a capitalism idol? How do you gonna live without any salary or profit while writing code only for world wide human beings? Are this these topics too heavy for us to lift? :)

What do you think?

Microsoft CRM 3.0 Web Service Calls With Generic Methods

While working in my cms project, my dirty code pushed me some refactoring for Microsoft Crm 3.0 web service calls. So i decided to write one wrapper class for accessing crm. If you worked with crm web services i guess that you’d probably tired of writing queries with QueryExpression and QueryByAttribute classes.

Since, when an idea of using generic methods blinked above by head, i began to code against BusinessEntity based classes of crm api. It was flowed like this:

    public T[] FindEntities(string[] attributes, object[] values, ConditionOperator[] operators, string[] columns) where T : BusinessEntity
    {
        QueryExpression query = new QueryExpression();
        ConditionExpression[] conditionExpressions = null;

        if (attributes != null && values != null)
        {
            conditionExpressions = new ConditionExpression[attributes.Length];

            for (int i = 0; i < conditionExpressions.Length; i++)
            {
                ConditionExpression conditionExpression = new ConditionExpression();
                conditionExpression.AttributeName = attributes[i];
                conditionExpression.Operator = operators == null ? ConditionOperator.Equal : operators[i];
                conditionExpression.Values = new object[] { values[i] };

                conditionExpressions[i] = conditionExpression;
            }
        }

        FilterExpression filterExpression = new FilterExpression();
        filterExpression.FilterOperator = LogicalOperator.And;
        filterExpression.Conditions = conditionExpressions;
        query.Criteria = filterExpression;

        ColumnSetBase columnSet = null;

        if (columns == null)
        {
            columnSet = new AllColumns();
        }
        else
        {
            columnSet = new ColumnSet();
            ((ColumnSet)columnSet).Attributes = columns;
        }

        query.ColumnSet = columnSet;
        query.EntityName = typeof(T).Name;

        BusinessEntityCollection result = _crmService.RetrieveMultiple(query);

        T[] entities = new T[result.BusinessEntities.Length];
        Array.Copy(result.BusinessEntities, entities, entities.Length);
        return entities;
    }

When finished base method, take it more easy by overriding it, below there are some more helper methods using base method

    public T[] FindEntities<T>(string attribute, object value) where T : BusinessEntity
    {
        return FindEntities<T>(new string[] { attribute }, new object[] { value });
    }

    public T[] FindEntities<T>(string attribute, object value, ConditionOperator op) where T : BusinessEntity
    {
        return FindEntities<T>(new string[] { attribute }, new object[] { value }, new ConditionOperator[] { op });
    }

    public T[] FindEntities<T>(string attribute, object value, string[] columns) where T : BusinessEntity
    {
        return FindEntities<T>(new string[] { attribute }, new object[] { value }, columns);
    }

    public T[] FindEntities<T>(string attribute, object value, ConditionOperator op, string[] columns) where T : BusinessEntity
    {
        return FindEntities<T>(new string[] { attribute }, new object[] { value }, new ConditionOperator[] { op }, columns);
    }

    public T[] FindEntities<T>(string[] attributes, object[] values) where T : BusinessEntity
    {
        return FindEntities<T>(attributes, values, null, null);
    }

    public T[] FindEntities<T>(string[] attributes, object[] values, string[] columns) where T : BusinessEntity
    {
        return FindEntities<T>(attributes, values, null, columns);
    }

    public T[] FindEntities<T>(string[] attributes, object[] values, ConditionOperator[] operators) where T : BusinessEntity
    {
        return FindEntities<T>(attributes, values, operators, null);
    }

And that’s it, don’t give up work and write some more helper overridings and improvements. For example it’s a good idea to write FindAll, FindEntity, FindEntityById and any CRUD methods. In my project my method calls looked like this instead of lines of code caused by QueryBase implementations.

    public static account FindAccountOfUser(Guid contactId)
    {

        return Crm.Instance().FindEntity<account>("primarycontactid", contactId);
    }

Finally my project code looks like more&more simplistic and clean. Please give me feedback for any improvements.

kick it on DotNetKicks.com

« Previous Entries  Next Entries »
Valid XHTML 1.0 Strict Valid CSS!