Your Ad Here
Sep 26

For the software, itself, it is easier to discuss its quality by measuring its performance, memory usage, number of the bugs etc. But what if we talk about the code file, how can we write code that we are proud of.

  • Clarity
  • Number of Lines
  • Performance
  • Comments
  • Exception Management

 

And many other topics can be added to this list for code quality measurement. But we will focus on these five now.


Clarity

Probably you have seen a really “smart” code like the one below:

   1:    public static int GetNextSize(int i)
   2:    {
   3:      //multiply it by four and make sure it is positive
   4:      return i > 0 ? i << 2 : ~(i << 2) + 1;
   5:    }


At least we have a comment line; well we will discuss the comments later on. But as you see you should really focus and evaluate the code before understanding what it is doing. So hiding the code in this way, especially if you work in a team, will create big headaches for your team members and after a while, for you, too. Code should always be clear and transparent for everyone just like the one below.

 

   1:    public static int GetNextSize(int i)
   2:    {
   3:      return Math.Abs(i * 4);  
   4:    }

Steve McConnell : "Good code is its own best documentation."
 

Number of Lines 

Some developers are proud of their big number of code lines. Because this is a proof to show how big the project is. But in the other hand, this is not true. Because more lines of code means more complex, harder to maintain code base or even worse; a sing to the wrong implementation of object orientation or code reuse.  

If you consider two software which function the same, the well structured one has always the less lines of code. The one has less lines of code is easier to maintain and fix the bugs. Which means the lighter is the better. Let me quote Bill Gates: “Measuring programming progress by lines of code is like measuring aircraft building progress by weight“. 

Performance  

Of course a fast functioning program is better than its slow versions and the performance considerations are always in the front lines of the development process. But changing a clearly readable code to its complicated and fast equivalent lines is not always the brilliant idea and there is always a way to implement the same algorithm in a clearer way.  

Well, I don’t mean don’t think about performance optimization but there is always bigger chance in the overall system to optimize. It is more important to focus on the big picture and solve performance problems that are system wide, or refactor code so that changes can be made much faster, than it is to solve a performance problem in a single line of code...unless of course that line of code is being called millions times. 

Comments 

Again I am pretty sure you have seen so many uncommented or not enough commented codes. Even code, itself, is readable or not, comments are important substances. You should always keep in mind to write clear comments like telling it to someone else. Don’t type them in your way but in a common language. 

Exception Management 

Although we are just focusing on the code quality (not the architecture or the software quality) still we need to discuss the exception management. Any unexpected situation can cause the exceptions. Normally the newly started developers go to the solution directly but prefer not to think about any abnormal situation can occur in their solution. So any missing control or a direct assumption can cause a crash in your application.  

In the worst case (probably the simplest) you can catch any exception on Application Domain level and show a common error message screen. But in any case, you shouldn’t let your software crash!  

As you already figured it out, it is not really easy to balance and find the most correct way of coding. If you don’t like the code you’ve written take a step back, review it, fix it, refactor it till you are proud of. Fixing the problems in early stage will have massive returns in the long term.  Searching for the perfect coding will lead you to a better understanding of what you are doing.  

And one more quote from Martin Fowler : “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”
 

credits goes to CodeThinked

kick it on DotNetKicks.com
 
Tags:
Jan 15

Microsoft will soon release version 2.5 of its .NET Micro Framework platform for low-end embedded processors. The new release adds support for networking via a native TCP/IP stack, and for Web Services on Devices (WSD), according to postings on the .NET Micro Framework Team's blog.

Microsoft first released .NET Micro Framework (.NET MF) in 2006, aiming it at wireless remote controls, watches, and other cost-sensitive devices with constrained processor and memory resources. The .NET MF grew out of Microsoft's Smart Personal Objects Technology (SPOT) initiative, with embryonic versions variously dubbed .NET Embedded and TinyCLR.

According to Microsoft, .NET MF supports low-end embedded processors and doesn't require an MMU (memory management unit). A typical runtime image is only about 300 KB in size, the company says.


.NET MF grew out of Microsoft's work with SPOT Watches

 

Microsoft released .NET MF version 2.0 in February 2007, and .NET MF 2.0, Service Pack 1 in September. However, these releases still did not include a native TCP/IP stack, which was listed as "coming soon." Therefore, networking a .NET MF device has required calling through to an underlying operating system with sockets support, according to the company.

Version 2.5 of .NET MF will now offer a stack that is available even when running directly on the hardware. Device makers need only provide a driver for the network interface. This will result in a wider selection of network-capable hardware development platforms for developers to choose from, Microsoft says.

The company adds that the new version of .NET MF will also include client and server support for Web Services on Devices, also known as Device Profile for Web Services (DPWS). Already part of Windows Vista and Windows CE 6.0 Release 2, this "enables a USB-like level of plug-and-play for networked devices," in the company's words. DPWS-enabled devices on a network can discover one another, then invoke the functionality each device provides.

Further specifics of .NET MF, version 2.5, were not provided, nor has a release date been announced. However, according to the .NET MF team, the new version should appear in "early 2008."

For further information, see the blog posting, here.

Tags:
Jan 04

21.11.2005 tarihinde yazgelistir'e AJAX kullanarak Google Suggest Box tipi kontrollerin gelistirilmesi ile ilgili bir makale yazmistim. O zamanlar ancak ClientCallBack'ler ile islemlerimizi yapabiliyorduk. O gunlerden bu gune cok sey gelisti. Atlas'tan AJAX'a, yepyeni kontrollerimiz var artik.

Yine de, benim makaleme 
    http://www.yazgelistir.com/Makaleler/1000000796.ygpx  linkinden
yeni kontroller ve Ajax Tool Kit kullanilarak gelistirilen bir ornegine ve detayli makaleye de
    http://mattberseth.com/blog/2007/12/creating_a_google_suggest_styl.html
adresinden ulasabilirsiniz

Tags:
Jan 03

I developed projects with NHibernate in couple of years before and at that time I searched and read many articles on advantages or disadvantages of ORM or ADO.NET / Stored Procedures. There were so many technical discussions and comparisions between those technologies.

Later on when I started to study on LINQ I thought the performance and any comparisions between those three. But I hadn't got enough time to test. I have just found a guy, Maximilian Beller, has written two nice articles compare the performances and properties of those technologies.

Recommendation: NHibernate, Linq or ADO.NET?

Performance comparison between Linq, NHibernate and ADO.NET / Stored Procedures
Tags: |
Dec 24

Team Foundation Power Tools for VS2008 is out. New in this Release:

• Find in Source Control tool is an addition to the Team Explorer menu that provides the ability to locate files and folders in source control by the item’s status or with a wildcard expression.

• Open a selected folder in Windows Explorer straight from Team Explorer. This feature allows you to jump straight to the mapped folder location from within Source Control Explorer.

• Quick Label feature that allows labels to be easily applied to a given selection of files and folders in the Source Control Explorer.

• Build Notification tool that runs in the Windows task bar notification area monitoring the status of the build definitions you have specified. It can be configured to show notifications when builds are queued, started, or completed for multiple build definitions spanning multiple Team Foundation Servers.

• Additional TFPT.EXE commands for configuring Team Explorer connection settings (tweakui) and for destroying Work Items and Work Items Type Definitions (destroyWI, destroyWITD).

• Updates to the TFS Best Practices Analyzer for use with a Visual Studio Team System 2008 Team Foundation Server deployment.

• The Process Template Editor is updated for use with Visual Studio Team System 2008 Team Foundation Server. It also has several improvements, including: the ability to launch standalone w/o a Visual Studio installation, performance improvements, improved discoverability and bug fixes.

• Bug fixes and removal of Power Tools that are now included within Team Foundation Server:

• Annotate and Treedif are now included in Visual Studio Team System 2008 Team Explorer; however, Annotate remains is still available in the command-line tool (TFPT.EXE).

• TestToolsTask is included in Visual Studio Team System 2008 Team Foundation Server as part of Team Foundation Build.

 

from Brian Harry's blog

Tags:
Dec 20

Parallel Extensions to the .NET Framework is a managed programming model for data parallelism, task parallelism, and coordination on parallel hardware unified by a common work scheduler. Parallel Extensions makes it easier for developers to write programs that scale to take advantage of parallel hardware by providing improved performance as the numbers of cores and processors increase without having to deal with many of the complexities of today’s concurrent programming models.

Microsoft Parallel Extensions to .NET Framework 3.5 is almost ready and CTP can be downloaded here

Tags:
Dec 17

There is a new site that focus on software factories, domain specific languages and Visual Studio Extensibility.

http://sf.devrevolution.com/

Tags:
Dec 12

The preview version of ASP.NET 3.5 Extensions is released. The Extensions are a new set of tools and controls that will be added onto existing release of ASP.NET with .NET 3.5. This will make possible for web developers to get the latest updates on ASP.NET without having to wait 1-2 years more for the next release of .NET Framework.
It also includes ADO.NET Entity Framework Beta 3, which you can also download as a separate file here (you do not need to download it if you have ASP.NET 3.5 Extensions Preview installed already).


What’s in the Extensions Release?

ASP.NET MVC
ASP.NET MVC provides model-view-controller (MVC) support to the existing ASP.NET 3.5 runtime, which enables developers to more easily take advantage of this design pattern. Benefits include the ability to achieve and maintain a clear separation of concerns, as well as facilitate test driven development (TDD).

The ASP.NET MVC Toolkit provides HTML rendering helpers and dynamic data support for MVC.

ASP.NET Dynamic Data
ASP.NET Dynamic Data helps developers build a fully customizable, data-driven app quickly. It provides a rich scaffolding framework that allows rapid data driven development without writing code, yet it is easily extendible using the traditional ASP.NET programming model.

ASP.NET AJAX
New additions to ASP.NET AJAX include support for managing browser history (Back button support).

ADO.NET Entity Framework
ADO.NET Entity Framework is a new modeling framework that enables developers to define a conceptual model of a database schema that closely aligns to a real world view of the information. Benefits include easier to understand and easier to maintain application code that is shielded from underlying database schema changes.

ADO.NET Data Services
ADO.NET Data Services provide new services that find, manipulate and deliver data over the web using simple URIs. Benefits include an easy and flexible way to access data over the web, while enabling the separation of presentation and data access code.

Silverlight Controls for ASP.NET
You can integrate the rich behavior of Microsoft Silverlight into your Web application by using two new ASP.NET server controls: a MediaPlayer server control that enables easy integration of media sources such as audio (WMA) and video (WMV) into your Web application, and a Silverlight server control that allows an ASP.NET page to reference both XAML objects and their event handlers.

Tags:
Nov 30

Here is a very nice acticle from msdn on Service Factories.
The Web Service Software Factory: Modeling Edition (also known as the Service Factory) is an integrated collection of resources designed to help you quickly and consistently build Web services that adhere to well-known architecture and design patterns. These resources consist of patterns and architecture topics in the form of written guidance and models with code generation in the form of tools integrated with Visual Studio 2005.

check that link :  http://msdn2.microsoft.com/en-us/architecture/bb931187.aspx

 

Tags:
Nov 01

Microsoft announced Visual Studio 2008 and .NET Framework 3.5 will be released at the end of this month. From the beta releases (we have beta 2 now) and .NET 3.0 we saw so many improvements on framework and languages.  From now on, we become capable to use Domain Specific Languages (DSLs) like LINQ and we can focus on the domain of the problem space. And we can do Domain Driven Design (DDD) in language level.

 

DDD is still one of the hardest design issues in many languages and development disciplines, but LINQ is a really nice approach to that problem. So languages are evolving into higher level. But what is next step for languages? In .NET environment or any other frameworks it is still very difficult to parallelize applications. Few programmers, seniors can write multi-threaded code and very few of them really enough capable to debug. In somehow, the operation theory is totally different than human brain.     As commonly known our hardware, computers are ready for those programs for couple of years. Dual core, multi-core processors stand in our laptops, PCs for years. As Aaron Coday from Intel mentioned in Istanbul Bilisim Kongresi 2007, “Software should fallow and support hardware”. Thoughts from the development zone are almost the same. Bill Gates announced in MVP Global Summit 2007, “…..take multiple processors and use them in parallel has been a programming challenge going back many, many decades, so now it's important that we actually solve that problem, and make it possible for developers of all types to take advantage of these multi-core devices….

So, in my opinion; first step of language evaluation will be in multi-core application development and may be the second one multi-computer (computing-grid) . The name of the first step and opportunities on it are ready : Parallel LINQ or PLINQ.

Tags: |
Sep 20

Mistakes are not always a bad thing. Making mistakes is a natural way to learn. However, the cost of such 'learning' in the development cycle can be pretty high. This is especially true for mobile applications, where a programmer battles against so many issues that desktop developers can't even remember any more.

There are a number of things that are most harmful for mobile developers to do. I present several of the most common troubles worth reviewing in this article. I start with strategic issues.

Different Platforms are Different

The very first and probably most important fact mobile developers must remember is that Windows CE operating system is by far not like its big brother the desktop operating system. They have common features and share common philosophy, but there is a big difference in development approaches used for each. This is due to different form factors, resources that are available, supported APIs and so forth. Regardless of whether you use C++, Visual Basic, Java or C#, you will be lucky if the same code will run on both the desktop and on a PDA in the same way. Thus if you're considering the porting of your existing desktop application to WinCE or considering the development of new applications, remember that the mobile operating system is not the same as a desktop operating system.

Operating Systems, Devices and Frameworks

In addition to knowing that mobile operating systems are different from desktop operating systems, you should also note that there are different mobile operating systems as well as different devices and frameworks. You need to properly plan for the device types and operating system you would like to target.

For example, if you have developed an applications for devices using Windows Mobile, then your application might not run good on PDAs with CE.NET inside. This lack of support could cut your target devices in half. Similarly, if your product uses specific features of a specific device, then there may be devices that can't support your application as well. For this reason, you should ask yourself if targeting specific device features is a right decision. Of course, if you are device vendor, such problems are out of scope! For application developer, however, generic code you produce as better for the whole project, i.e. you application will be able to run almost everywhere.

Another issue from the same family is the use of various frameworks, libraries and technologies. For example, the Pocket PC SDK contains MFC library but the Smartphone SDK does not. As such, if you want to target both Pocket PC Devices and Smartphone devices, then you need to think twice. Another example can be seen with ADO CE. In addition to many differences with desktop version, Microsoft has decided to discontinue its support in Windows Mobile 5.x. So be double careful there!

Application Structure

That is enough regarding issues with strategy, now consider the structure of a mobile application. There are at least two polar approaches: to make an application solid -- do you always have the one and only executable or do you divide your application into a main executable and number of DLLs?

Both structures have well-known pros and cons. I've seen many projects (very complicated and fat enough to be honest), which used COM objects and huge number of DLLs. I have to state here that such approach doesn't work well on Windows Mobile platform. One executable and few DLLs are ideal though. This is obviously true for desktop systems as well, but there you are in much more comfortable situation with resources. In case of Windows CE application performance will be reduced dramatically.

Another issue with DLLs on Windows CE is that if you store resources, (e.g. to support multiple languages in your application), it may cause significant problems because the application may switch resource handles at runtime. The resulting behavior may be quite unpredictable. Eugene Tilman and I have spent a number of sleepless nights trying to detect why a big application sporadically crashes on a device but works like a charm in desktop emulation. There are different methods for avoiding the need for many DLLs. For example, when implementing internationalization, you might 'translate' resources within the executable rather than keep them in a separate DLL. There are a number of references on the web describing similar techniques.

Application Configuration

How you configured your application is also important for avoiding mistakes. Again, there are many different ways to configure a mobile application, so we will not dig into specific mistakes. Rather, there are two possible configurations issues you should consider: Registry use and code reusability.

There are big desktop systems which use the Registry in much the same way as a database in that it is used to store hundreds (if not thousands) of parameters. For Windows Mobile application such tricks just won't work due for a very simple reason: mobile devices suffer from hard resets from time to time. If a hard reset occurs, you have a good chance that all data in the registry will be reset as well and thus lost. Regardless, maintenance of such configuration storage can be a real nightmare, although it can be done by purchasing additional tools such as Pocket Controller .

If your application needs a lot of parameters then consider suitable method to store them -- a method such as XML, binary files or something else.

One of the best things in development is code reusability. That's why we all create libraries, frameworks and so forth. This helps us to develop faster, better, ... (you can continue as much as you want to).

You have to be careful using such libraries. For example, the MFC framework can cause you problems when used incorrectly on mobile devices. No doubts, it helps a lot where you can utilize it; however, there many classes that are implemented for mobile usage with much less efficiency than in desktop version. This includes classes like CSocket and the WinInet stuff. Additionally, some functionality available through the API are unavailable for mobile usage. But this is not the worst trouble. Such problematic parts of the library are obviously subject to improve. Programmers simply do not use ineffective classes. Hence, Microsoft has decided to discontinue some of them in newest MFC version for Windows CE. For example, the WinInet classes are being discontinued. If you've the bad luck to have used them in your projects, then you will have to rewrite them. In rarer cases, some GUI classes may be dropped, but I believe it should be treated as an accident rather than common case.

I/O, Memory, Stack & Co.

Finally, there are programming issues that can be the cause of mistakes in mobile applications.

I/O operations are the very first point to talk about from a performance and device resources point of view. For desktop systems the normal receipt is simple: read by blocks rather than by bytes. For mobile applications it is not as straightforward. If data is stored on a flash card (SD, CF etc.), then access time may be painfully long. Suppose that data is kept in a flat files with no matter binary or text (like XML). It is a good thing if you can read it all in one shot to memory and then process as needed. In the case of huge amounts of data, however, this is simply impossible. In those cases, you have to allocate chunks here and there. It is a really bad thing that memory allocation strategies may vary from one version of an OS to next one. You can easily test on a Pocket PC 2002, 2003 and Windows Mobile 2003 SE. On Pocket PC 2002 you benefit from big allocations, but on later versions smaller chunks are allocated faster. With Windows CE 5.0 the situation changed once again, because there is no RAM anymore. Storage Cards are still there, but as you see, it might be a particular magic to choose the best method to reach the best I/O performance.

Not all PDAs are loaded with resources or have lots of resources available. This fact hits you first of all with the stack size that is available for applications. Many mobile applications uses Dialog-based architecture because it is simple. It is well-known that big allocations on the stack, e.g. BYTE arr[65536], are inapplicable because you have by default only a 64KB for stack. Less intuitive effects can occurs when you have a number of dialogs created on the stack and open simultaneously. It appears that critical number is balancing on the boundary of 3 to 4 dialogs only. If your program tries to pop up more, a Stack Overflow exception will be the best thing you can get. Usually it just crashes at some arbitrary place.

The last but not the least thing regarding programming mistakes is in exception handling. Earlier versions of Windows CE did not support exception handling extensively. Now the situation is quite different. Normal C/C++ handling is allowed, TRY and CATCH macros may be forgotten. Exception handling is extremely important for mobile applications, because an environment is less friendly than the desktop. Applying exception handling in the correct way will make your product much more robust, but don't be too excited with it, otherwise you can loose the performance.

In Conclusion...

You've now seen many of the biggest mistakes! I hope reviewing them will help you to avoid them and thus lead to better decisions in your own mobile applications. With mobile technology growing so rapidly, doing mobile development is getting better with every new operating system release. So who knows, maybe soon mobile programming will become as regular as desktop development.

Source : http://www.developer.com

Tags:
Aug 13

Bugunlerde biraz "coding for fun" arastirmalari yapiyorum. Windows Mobile 5.0 icin gercekten hosuma giden bir Channel 9 videosunu sizlerle paylasmak istiyorum. http://channel9.msdn.com/ShowPost.aspx?PostID=209787

Tags:
May 02

Birkac saatimi harcayıp kendi kendime "neden yapamıyorum ya, boyle sacma bişi mi olur?" diye söylenirken SQL Server Books Online ' ı daha dikkatli okudum, ve araya sıkıştırılmış bir cümleyle kendime geldim. Gerçekten isnull T-SQL de yalnizca "null mı değil mi" kontrolünü mü yapar?

Returns the same type as check_expression.

Books Online, Isnull için bunu söyluyor. Yani, isnull kontrol ettiginiz parametreleri, aynı zamanda ilk kontrol ettiginizin tipine ceviriyor.
Örneğin

declare @param1 nvarchar(50), @param2 nvarchar(50),@param3 nvarchar(25)
set @param1 =' 25 karakterden  uzun   bir metin'
set @param2 = @param1

print isnull(@param3,@param1)

-- 25 karakterden  uzun   b    (Print'in output'u)

param3'ün tipi nvarchar(25) oldugu için textin kalanı kesilip atılıyor.    :) ilginc dimi?

Peki, birde bulmak için bu kadar uğrastıgım querynin nasıl birsey olduguna, ve dondurmediği sonuca bakalım.

select * from sysobjects
where @param1 = isnull(@param3,@param2)

Parametre tanımlamalarında gördüğünüz üzere, @param3 null oldugu için, isnull'ın @param2'yi döndürmesini, @param2 ve @param1 de birbirine eşit olduğu için tablodaki tüm kayıtları görebilmeyi umuyordum. Fakat, malesef, elimizde kocaman bir boş küme :)

Aklımızda, bloğumuzda bir yerlerde kalsın. Unuttukça açıp bakarız.
İyi & Dikkatli çalışmalar.

Tags:
May 01

SilverLight’ın Beta sürümü Microsoft.NET destekli olarak ilgi ve alakanıza sunuldu. http://silverlight.net/ adresinden örneklere ve videolara erişebilirsiniz.

Geliştirme ve dökümanlarla ilgili download’lara http://www.microsoft.com/silverlight/tools.aspx adresinden ulaşabilirsiniz.

Tags:
Jan 23

   Fikir hoş ama pek orjinal degil :) Sevgili arkadasim Coskun Sunali'dan calinti bir fikir.. ama madem işe yarayacak, neden olmasin.. "Bana makale yaz. Aradim taradim bi turlu bir yerde bulamadim" dediğiniz konulari buraya yazin, makaleniz kapiniza gelsin.

   Bir cogunuz bana msn'den ya da mail yoluyla bir cok soru soruyor, ama .NET in ögrenebilirliliği ve paylaşımın artışı için boyle bir yontem cok daha etkili olacak sanirim. Konulari bekliyorum.!

Tags:
Oct 14

   Şu anda o kadar çok kavram birbiriyle karışmak üzere ki, :) adlandırmalar, harfler, versiyon numaraları, yeniden adlandırmalar... Bugun Microsoft'ta yaptığımız toplatıda bile birçok öğrenci arkadaşımın kafası fazlasıyla karışmıştı. ".NET Framework 3.0 geliyor, içinde C# 3.0 olacak, Orcas ne öyleyse? LINQ nerede?" :) herkesin gözlerinde bir miktar "neler oluyor" dehşeti vardı.

Kısaca açıklamaya calışalım :

.NET Framework 3.0 aslında şu anda kullandığımız 2005 ile birlikte gelen .NET Framework 2.0 mimarisinin biraz daha genişletilmiş halidir. (Özellikle "geliştirilmiş" kelimesini kullanmadım, çünkü tam anlamıyla genişletilmiştir.) Şöyle ki, programatik olarak, compiler ve alt yapı olarak tamamen .NET 2.0 kullanılan ve Windows Workflow Foundation, Windows Communication Foundation, Windows Presentation Foundation kütüphanelerinin eklenmiş halidir aslında fw 3.0. Bu bahsettiğimiz kütüphaneleri daha önceden WinFX olarak duymuştuk. Bunlar tamamen .NET Framework 2.0 üzerinde calışmakta ve tamamen vs.net 2005 ile kullanabileceğimiz, C# 2.0 ve diğer diller ile kodlayabilecegimiz işlerimizi kolaylaştıran kütüphanelerdir. Resimde .NET Framework 3.0 ı görmektesiniz.



Peki öyleyse C# 3.0 nerede?
Aslında C# 3.0 daha ileride bir adım. Çünkü C# 3.0 kodlarının derlenebilmesi için yeni bir compiler, kütüphanelerin kullanıldığı daha da yeni bir Framework gerekli, işte bu da Orcas. Orcas, .NET Framework 3.0 değildir kesinlikle. 2007 sonlarına doğru çıkacak yeni bir .NET FW olacak ve Visual Studio 2007 ile desteklenecektir. LINQ ve benzeri dil gelişimleri de Orcas ile birlikte hayatımıza girecek ve çalışmalarımıza yenilikler katacaktır.

Bu arada, söylemeden geçmeyelim, artık "ATLAS" yok :) orjinal ve bence daha güçlü olan adı geri verildi. Yaşasın "AJAX".

 

Tags:
Software Blogs TopOfBlogs