Posts Tagged ‘.NET’

Linq to NHibernate, Version 1.0

Thursday, September 10th, 2009

A few weeks ago, Oren Eini (Ayende Raihan or, as is often referred to) communicated the release of version 1.0 of the Linq provider for NHibernate, a feature highly demanded by users since the advent of integrated query language. NET.

Although it will be included as part of NHibernate product in future versions, have decided to release the current release of the supplier as separate package so you can start to be used from now. It is being tested in many applications in production for several years, and apparently the performance is just right.

And how can help the supplier, if you’re user of NHibernate? The following example from Caffeinated Coder demonstrates how to query database can be simplified and made more readable using Linq and also benefit from strong typing, intellisense and compile-time checks:

Using NHibernate API:

public IList<Call> GetCallsByDate(DateTime beginDate, int interpreterId)
{
    ICriteria criteria = Session.CreateCriteria(typeof(Call))
        .CreateAlias("Customer", "Customer")
        .Add(Restrictions.Gt("StartTime", beginDate))
        .Add(
            Restrictions.Or(
                Restrictions.Lt("EndTime", DateTime.Now), Restrictions.IsNull("EndTime"))
            )
        .Add(Restrictions.Eq("Interpreter.Id", interpreterId))
        .AddOrder(Order.Desc("StartTime"))
        .AddOrder(Order.Desc("Customer.Name"));
        return criteria.List<Call>() as List<Call>;
}

Using Linq:

public IList<Call> GetCallsByDateWithLinq(DateTime beginDate, int interpreterId)
{
    var query = from call in Session.Linq<Call>()
        where call.StartTime > beginDate
            && (call.EndTime == null || call.EndTime < DateTime.Now )
            && call.Interpreter.Id == interpreterId
        orderby call.StartTime descending, call.Customer.Name
        select call;

    return query.ToList();
}

You can download both binaries and source code from the SourceForge project page.

The 10 most important skills for future programmers

Sunday, September 6th, 2009

It is important to ensure that we are benefiting as much as possible when we invest time and effort to train and learn new things.

The following list will see the 10 we should learn skills that our curriculum is relevant for the next 5 years. This list is not complete and covers some niche markets (such as mainframes). However, if you learn at least seven items in this list you will not miss it.

1. One of the “Big 3″ (Java, . NET & PHP)

Barring a radical change in the world of development (such as an asteroid falling on Redmond), most developers will need to know any of the three major systems development: Java,. NET (VB.NET or C #) or PHP. Nor enough to know the main language. As projects grow and are grabbing more functionality, we will need to know the frameworks and libraries associated with depth.

2. Rich Internet Applications (RIA – Rich Internet Applications)

They can love or hate, but in recent years, Flash is being used for something other than funny animations. Flash also gained additional functionality in the form of Flex and AIR. Competitors of Flash, as JavaFX and Silverlight are also improving in performance. The browsers are improving their JavaScript engine, which is emerging as a web application platform. To make things more complicated, HTML 5 is going to incorporate lots of RIA functionality, including connection to the database, thus the formal seal of the W3C to AJAX. In the near future, have experience of RIA will be a determining factor in our curriculum.

3. Web Development

Web development will not disappear in the future. Many developers were happy so far ignored the web, or just staying with “the basics” that gave them their framework. But companies are demanding more and more to those who really know how to work with the underlying technologies. So we should improve our knowledge of JavaScript, CSS and HTML to succeed in the next five years.

4. Web Services

“REST or SOAP? JSON or XML? Although the election and the answers depend on the project, it is increasingly difficult to be a developer without having to consume Web Services (even if our development is not a Web application). Even the land area used to be ODBC, COM or RPC are now moving to Web services of some kind. Developers who can not work with Web services will end up relegated to maintenance on legacy code.

5. Human skills

There is a trend that has occurred some time ago: the increasing visibility of IT within and outside the organization. The developers are taking more and more meetings that are not development and process for obtaining feedback from them. For example, the CFO can not change the accounting rules without working with IT to update the system. And an operations manager can not change the process of call without IT center update the CRM work-flow. Similarly, customers often need to work directly with development teams to ensure their needs are met. Will it be necessary for all developers to consider how to win friends and influence people? No. But the developers that they will do will be much more valuable to their employers – and are highly sought after in the market.

6. A dynamic programming language and / or functional

Languages like Ruby, Python, F # and Groovy are not yet very popular – but so are the ideas behind them. For example, the LINQ system. NET is a direct descendant of functional programming techniques. Both Ruby and Python are becoming increasingly popular in some quarters, thanks to the Rails framework and Silverlight respectively. Learn one of these languages will not only improve our curriculum, but also will expand our horizon. All great developers recommend learning at least one dynamic or functional languages to make learning new ways of thinking.

7. Agile Methodologies

As time passes, the ideas behind Agile become more defined and better expressed. Many organizations are adopting Agile or proofs of concept for doing Agile. Although Agile is no silver bullet to avoid failure in a project definitely has its place in many projects. Developers who have experience in working and understanding Agile environments will be increasingly in demand in the next five years.

8. Domain Knowledge

Hand in hand with the agile methodologies, development teams are increasingly viewed partners in the project definition. This means that developers who understand the problem domain will be able to contribute to the project in a very visible and valuable. With Agile, a developer can say “From here, we can very easily add this functionality, and you get great value,” or “Hey, this requirement is not in keeping with the pattern of use that the logs show. No matter how many developers resist the idea of knowing anything about the problem domain, it is undeniable that more and more organizations prefer (if not even require) developers to at least understand the basics of the business.

9. “Hygiene” development

Until a few years ago, many (if not all) organizations had no access to bug tracking systems, version control and other tools, all developers are summarized and their preferred IDE. But thanks to the creation of new integrated development environments and the explosion of free software environments of high quality, since there are almost no organizations without these tools. Developers have to know much more than just do a checkout of the code. You need to have a rigorous hygiene habits to ensure they are properly coordinated with the team. The “solitary programmers” that keep everything local, non-document changes and others will not be welcome in traditional organizations, and will be aa directly out of place in Agile environments, where you use a strong coordination between equipment to operate.

10. Mobile Development

During the late 1990 web development grew and gained widespread adoption, so begin to displace traditional desktop applications. In 2008, development for mobile devices eventually took off, and over the next five years will grow steadily. Of course, there are several approaches to mobile development: web applications designed to run on mobile devices, RIAs aimed at this market, and applications that run directly on the devices. No matter what path we choose, we will serve add mobile development skills to our group.

Mono project brings .NET platform to the iPhone

Friday, August 14th, 2009


Video: MonoTouch iPhone Hello World [05:14 min]

Apple made several conditions to develop applications on its iPhone platform, one of them is unable to use any type of virtual machine execution engine or script as a basis for applications, only native code. This condition leaves no contests or sweepstakes to developers with extensive experience in Java and. NET, reducing the universe of developers who have knowledge in Objective-C, without being able to reuse their skills in other languages are more widespread.

But did not have the cunning of the Mono Project, the implementation of the open source platform. NET. A feature of Mono that is relevant in this context is the ability to compile code-compatible. NET code in native, he is called AOT (Ahead of Time). The idea is very similar to what GNU Compiler for Java (GCJ), part of GNU Compiler Collection (GCC) and is making the source code and compile it instead of a virtual machine to compile the code Machine-specific, if iPhone is ARM code.

With AOT, laid the groundwork that makes sense to create MonoTouch, framework that has everything necessary for developers to create applications in C # and. NET for the iPhone.

MonoTouch access to all the potential of the iPhone’s APIs as well as the code and libraries that have been created around Mono. This will allow those with skills in C # and. NET can now start to use them in this exciting platform.

.NET: Checking whether an Internet connection is available

Wednesday, May 20th, 2009

The method using ping checks whether there is an internet connection or not?

In C#.NET

The following namespace is required:

using System.Net.NetworkInformation;
/// <Summary>
/// Checks whether an Internet connection is available.
/// </Summary>
/// <Returns>
/// True / false
/// </Returns>
/// Site: WiseCodes.Com

public static bool wcCheckInternetConnectionStatus()
{
 Ping pingSender = new Ping();

 try
 {
PingReply pReply = pingSender.Send("www.microsoft.com", 100);

 return pReply.Status == IPStatus.Success;
 }
 catch
 {
 return false;
 }
}

Link: System.Net.NetworkInformation Namespace (Via MSDN)

Happy Programming!! ;-)

.NET: Check links (http, https, ftp, news etc …)

Thursday, May 14th, 2009

In this article we show how we can know what kind of address is an address. We will use the URI class, which does not allow URLs to work. The class belongs to the URI name space System.

The URI class has property “Scheme” that indicates the type of URI scheme today. The schemes that detects the URI class are:

* UriSchemeFile: tells us that points the direction in which our class is a file URI.
* UriSchemeFtp: the scheme is FTP (File Transfer Protocol)
* UriSchemeGopher: specifies that we can access through URI using the Gopher protocol.
* UriSchemeHttp: access is a URI using the HTTP protocol.
* UriSchemeHttps: the address is https, http secure.
* UriSchemeMailto: tells us that the address is an e-mail, which can be accessed via SMTP.
* UriSchemeNetPipe: tells us that the identifier URI is NetPipe.
* UriSchemeNetTcp: can access through URI using the protocol NetTCP.
* UriSchemeNews: URI is the address of a newsgroup or News.
* UriSchemeNntp: a newsgroup is accessed via NNTP.

The fields above are just reading.

In the following example, create a constant that contains the address from which we obtain information and identify which type of management is our constant.

In Visual Basic:

Const strURL As String = “http://www.wisecodes.com”
Dim strDir As New Uri(strURL)
Select Case strDir.Scheme
Case Uri.UriSchemeFile
'Code for when the address is a file
Case Uri.UriSchemeFtp
'Code for when the address is ftp
Case Uri.UriSchemeGopher
'Code for when the address is a file Gopher
Case Uri.UriSchemeHttp
'Code for when the address is http
Case Uri.UriSchemeHttps
'Code for when the address is https
Case Uri.UriSchemeMailto
'Code for when the address is an e-mail
Case Uri.UriSchemeNetPipe
'Code for when the address is NetPipe
Case Uri.UriSchemeNetTcp
'Code for when the address is NetTcp
Case Uri.UriSchemeNews
'Code for when the address is a newsgroup
Case Uri.UriSchemeNntp
'Code for when the address is a newsgroup
'accessible via NNTP.
End Select

In C Sharp

const string strURL = “http://www.wisecodes.com”
Uri strDir = new Uri (strURL);
switch (strDir.Scheme)
{
case Uri.SchemeFile:
//Code for when the address is a file
case Uri.UriSchemeFtp:
//Code for when the address is ftp
case Uri.UriSchemeGopher:
//Code for when the address is a file Gopher
case Uri.UriSchemeHttp:
//Code for when the address is http
case Uri.UriSchemeHttps:
//Code for when the address is https
case Uri.UriSchemeMailto:
//Code for when the address is an e-mail
case Uri.UriSchemeNetPipe:
//Code for when the address is NetPipe
case Uri.UriSchemeNetTcp:
//Code for when the address is NetTcp
case Uri.UriSchemeNews:
//Code for when the address is a newsgroup
caseUri.UriSchemeNntp:
//Code for when the address is a newsgroup
//accessible via NNTP.
}

Link: Via Microsoft
Happy Programming!! ;-)