Spot the web RSS 2.0
# Thursday, December 27, 2007

Partial methods are a new feature available in C# 3.0 that don't seem to get enough credit. I think there was a lot of confusion early on about what partial methods were and how they were used.

Partial methods are intended to solve a major problem that is not only caused by code-generation tools and also affects those same tools. For instance, you are writing a code-generation tool but want to provide a way for the developers that are using your generated classes to hook in to specific areas of the code. As such, you don't want them editing your generated code since those customizations will be lost the next time the tool runs. On the flip side of this scenario is the developer who needs to write the code that hooks into those specific areas and doesn't want that code being lost the next time the tool runs.

Delegates are one solution to this type of problem. In the generated code, you declare a delegate method that you then call at the appropriate areas. If no one has implemented a concrete version of the delegate, the call will not do anything. However, if someone has implemented am instance of that delegate then the call will run the code in that instance. This sounds like a pretty good solution, and, until partial methods it really was the only solution. The drawback is that the code for the delegate is always compiled in to the runtime of your application and add to the runtime overhead of application (granted, that overhead is minimal but it's still there).

Partial classes helped with this problem by allowing the code-generation tools to isolate the generated code in a partial class. This allowed the developer to add their own methods to the class without fear that they would be overwritten the next time the tool ran. However, it only helped partially. In order to accomplish our scenario, you still needed to provide a delegate to allow the developer to hook into your process.

If we take this a step further and look at partial methods, you will start to see how they work and what the benefit is of using them. The following rules govern how partials methods can be declared and used:

  1. Must be declared inside a partial class.
  2. Must be declared as a void return type.
  3. Must be declared with the partial.
  4. Cannot be marked as extern.
  5. Can be marked static or unsafe.
  6. Can be generic.
  7. Can have ref but not out parameters.
  8. Cannot be referenced as a delegate until they are implemented
  9. Cannot have access modifiers such as public, private or internal.
  10. Cannot be declared as virtual.

Partial methods are implicitly marked as private. This means they cannot be called from outside the partial class.

Now that we have the rules out of the way, let's take a look at an example. This is a completely contrived example, as you typically wouldn't declare both portions of the partial class yourself.

   1: // This is the class that would normally have been autogenerated.
   2: public partial class CustomTypedCollection
   3: {
   4:     partial void BeforeAddingElement(CustomElement element);
   5:  
   6:     public void AddElement(CustomElement element)
   7:     {
   8:         BeforeAddingElement();
   9:     }
  10: }
  11:  
  12: public partial class CustomTypedCollection
  13: {
  14:     partial void BeforeAddingElement(CustomElement element)
  15:     {
  16:         Console.WriteLine("Element " + element + " is being added.");
  17:     }
  18: }
  19:  
  20: class Program
  21: {
  22:     static void Main(string[] args)
  23:     {
  24:         CustomTypedCollection c = new CustomTypedCollection();
  25:         c.AddElemeent(new CustomElement());
  26:     }
  27: }

In this example, the code-generation tool declares a partial method BeforeAddingElement. It is declared as just a function prototype with no implementation. Effectively, this tells the developer that if they want to hook in to the AddElement process, they can do so by declaring an implementation of the BeforeAddingElement method. If an implementation is declared, the implementation and the call inside AddElement will be compiled in to the runtime code. However, if no implementation is declared the call will be optimized by the compiler and it will be entirely eliminated in the runtime code.

This mechanism provides a lot of the same flexibility as delegates without the runtime overhead. It also allows the developer to work with a much smaller implementation of their portion of the partial class that contains only the few partial methods that have been implemented.

Thursday, December 27, 2007 7:53:47 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [0] - Trackback
.Net | Programming | Visual Studio
# Wednesday, December 26, 2007

What does Assembla do?
Assembla provides tools and services for building software quickly using global teams.

Is the service free?
Yes, the online service is free for individuals and small groups. We make money when we have larger groups that need premium tools, portfolios, and private servers.

500MB of SVN for free…

I have been using Subversion for project work for some time now, and it seems that most agree that it is the best Open Source solution available. I have enjoyed the use of SVN provided by clients or employers, but only recently started considering replacing my old local VSS server with a web-enabled SVN server of my own. My motivation is to get code that I own off-site and have some redundancy along with improved accessibility. I am also interested leveraging the benefits of the continual development and refinement of SVN as an Open Source project. TortoiseSVN is a good example of that.

I started by researching the requirements for installing SVN server. Installation on a local Windows host seemed doable, but I wanted to install it on my web server. Since my host doesn’t support applications, I’m on my own. I don’t even know what OS the server is running. From what I’ve read, installing SVN on a site would be a chore. Plus it would compete for space with site content. An alternative would be to pay for a specialized SVN hosting service. Hard to justify the continual overhead for that.

So I Googled for free SVN. One result stood out as promising: Assembla. They give away a 500mb SVN account with unlimited users and an integrated bug tracking setup (Trac). For the quick, small projects I am looking to use it for, I can accept the risk that Assembla flakes out as a business entity. Worst case I will still have my latest build on my local. Assembla’s business model seems pretty sound to me anyway - a successful freelance coder will eventuallly need more space if they get cosy using the free service and will become a paying customer.

Here aro some of the Assembla tools:

Subversion

Subversion is the most popular centralized source code repository and version control system.  Our subversion includes email alerts on commit, Trac code browsing, and a post-commit hook to trigger.  And, we know that reliability is important for subversion users, so we backup to failover servers in real time.  Learn more.

Trac

Trac is a popular open source ticketing system, with the mission to "help developers write great software while staying out of the way."   You can import and export trac projects from Assembla.  We enhance trac with simplified team management, HTML alerts (called "notifications" in trac), and hourly and weekly alert summaries.  We support a few trac plugins, including XML-RPC for Eclipse integration.

Scrum

The scrum tool collects reports from your team members in the stand-up meeting format:  "What did I do, What will I do, What do I need."

Chat

The chat tool provides a persistent chat room that you can use for daily meetings or just to drop in.

Wednesday, December 26, 2007 8:11:34 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [0] - Trackback
Programming | Project Management | Site Reviews | SVN | Web 2.0
# Sunday, December 23, 2007

Taken From: TechDune

Internet Explorer has cool add-ons which make the job of website designers and developers much easier. Here is my list of 20+ excellent Firefox add-ons that every web developer and designer should know about.


Internet Explorer Developer Toolbar
Variety of tools for quickly creating, understanding, and troubleshooting Web pages.

IE Watch
Allows you to view and analyze HTTP/HTTPS headers, Cookies, GET queries and POST data.

IE Web Developer
Allows you to inspect and edit the live HTML DOM, evaluate expressions and display error messages, explore source code of Web page and monitor DHTML Event and HTTP Traffic.

IESpy
Allows one to inspect or manipulate the DOM of any IE Web browser control.

DebugBar
Brings new services to surfers and professionals. Surfers: zoom, direct Web search, e-mail page screenshots, and color picker. Developers: view HTML code, cookies, JavaScript, HTTP/HTTPS headers, and miscellaneous information.

Virtual Machine
Allows you to view java applets on Web pages.

Microsoft Fiddler
Logs all HTTP traffic between your computer and the Internet.

Tangram Xtml Designer
Visual designer for IE Band Object, activeX Control and .NET user control.

Http Watch
HttpWatch shows you HTTP and HTTPS traffic from within IE allowing you to quickly debug, fix and optimize your Web site.

Embedded Web Browser
The package contains all the programmer need to extend the development of a Web browser.

CGToolbar
Must have tool for CG Artists, Animators, VFX and 3d professionals.

Site Studio 6
Build rich content Web sites, with no HTML skills required.

Haptek Player
An ActiveX control and Netscape Navigator Plugin that allows any webpage or application (with ActiveX support) to include Haptek’s Autonomous characters.

Flash2X Flash Hunter

Save Flash movies from web pages.

iOpus iMacros
Check the same sites every day,data upload, online marketing and functional testing and regression testing Web sites:

Telerik RadToolBar
A flexible component for implementation of tool and button strips, needed in most web applications.

UltraEdit-32
Powerful Text, HEX, HTML, PHP and Programmer’s Editor.

Bytescout Post2Blog
Freeware powerful blog editor for WordPress, Typepad, MovableType and other blogs.

Search Monster
Free Flash Web Directory & Internet Search Engine is the Flash-remoting Web directory instant content for you Web site.

Zend Studio
Encompasses all the development components necessary for the full PHP application.

DbaBar
Integrated toolbar enabling Oracle Database Administrators to browse their databases from within Internet Explorer within minutes after installation.

Explorer Toolbar Maker
lets you create your own Explorer bar from any HTML page, picture, Macromedia Flash file, or Microsoft Office document.

Sunday, December 23, 2007 1:40:15 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [0] - Trackback
CSS | Design | Javascript | Programming
Navigation
Archive
<December 2007>
SunMonTueWedThuFriSat
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Guy Levin
Sign In
Statistics
Total Posts: 63
This Year: 0
This Month: 0
This Week: 0
Comments: 14
Themes
All Content © 2010, Guy Levin