Dotmad.netDotmad.netMy thoughts on software developement using .Net. Articles
Catching unhandled exceptions
2010-08-18 16:46:00 As a rule, in every application I write, I always implement both the Application.Thread Exception and AppDomain.UnhandledException events, to catch exceptions which were not caught by a try..catch block. There are three reasons behind this: Present a custom failure message to the user (something like Twitter’s fail whale message) instead of the default ugly (and unclear) error dialog, ... More About: Programming , Mode , Policy
So you got over a million followers on Twitter
2009-09-20 13:22:00 ( * Originally posted as “The Million Followers Fallacy” on “Pravda on Media and Tech” ) Twitter is getting more and more attention from “old media” lately. Whether it’s a news-story mentioning Twitter, a Twitter competition between a celebrities, or using Twitter to gather reports on the Iran elections, the average person sees the word “Twitter” ... More About: Technology , Analyzer
Looking back on social media and myself
2009-08-20 22:40:00 More than 2 years ago, Ayelet Noff (AKA Blonde 2.0) wrote a post on social networks vs. blogs (with Myspace as an example for a social network). She claimed there is room for both in the life of a blogger. I disagreed with her: “Blogging takes effort, time and at least a little talent. MySpace requires choosing a ... More About: Social , Media , Social Networks , Back
Rotating Graphics
2009-03-29 19:12:00 This is a fairly simple issue, but I had to rotate a drawn shape recently. Initial searches led me to the Translate Transform method, but I learned there is a simpler way to achieve this, using the Rotate At method of the Matrix class: Graphics g = this.CreateGraphics(); //get a graphics object for the form g.DrawRectangle(new Pen(Color.Black), 50, 50, 100, 100); //normal ...
The role of Clients and Services in WCF
2009-02-13 19:08:00 I have seen this question in Stackoverflow.com, and I want to answer it here: Greetings readers! So I am trying to develop a client server system.. Since I have not designed a client server system before, I thought that I would post a question and see what the experts here have to say. Requirements: .NET 3.5 WCF ... More About: Services , Clients , Role
Garbage collector, gen2 and memory abuse
2009-01-28 21:43:00 There are limits most application developers never encounter. One of them is the 2GB memory limit for applications running on a 32bit operating system. But what happens if your application is a memory consumer (and most GIS applications are)? You may find out your application tends to crash and burn once reaching a memory signature of a ... More About: Windows , Programming , Abuse , Memory , Garbage
Juval Lowy and .NET Service Bus
2009-01-12 21:21:00 I have recently been to an Israeli user group meeting in which iDesign’s Juval Lowy gave a lecture about the new Azure .Net Service Bus for web services written in WCF. Basically a service bus is a router, similar to the one you use in your office network. Instead of needing to update the configuration for ... More About: Programming , Technology , Cloud
Visual Studio 2009 is out, welcome VS2010
2008-12-22 22:26:00 Some time ago, frustrated with my RSS reader being overrun by VS2008 beta announcements, I wrote a short post announcing the release of VS 2009 beta 1. And although there are some calls to re-brand the most recent service pack, I doubt we’ll see this version. Instead we got Visual Studio 2010, with new features such ... More About: Programming
The dangers of static members
2008-12-15 00:30:00 (If you use Visual Studio 2003 or you tend to ignore compiler warnings, this post is for you) Static classes and members have their uses. However, I recently encountered a dangerous pitfall regarding their usage. Consider the following code: public static class MyClass { public static int myVal = MyClass.myVal; public static MyOtherClass myClass = MyClass.myClass; public static Color ... More About: Programming
Live Blogging from TechEd Eilat (Israel)
2008-04-07 13:52:00 Due to lack of time I'm currently focusing my posting on my other blog (will port post here later), so you can find my posts here:http://blogs.microsoft.co.il/blogs/d otmad/archive/tags/TechEd/default.aspx More About: Israel , Blogging , Live , Eilat
Live Blogging from Israel Startup Weekend, Day 3
2008-04-05 13:44:00 Current status:Technologies used are ASP.NET, NHibernate, and MS Sql Server as a database. GoDaddy had been selected as hoster. (We also purchased a domain)The user experience design is mostly done, the marketing are working on creating several (very entertaining) videos for viral propagation.Architecture is set, but the development is still under work, with expectations for integration between the 3 layers later today, including running some tests of the site. We had some problems implementing NHibernate, but we solved them.We are using Youtube and Picasa to host videos and photos externally.After today we'll continue working on the application in parallel to our day job, with some focus on social marketing. More About: Israel , Blogging , Weekend , Live , Startup
Nhibernate: Use virtual properties
2008-04-05 11:23:00 Another thing from the Nhibernate quick start which led to confusion: we only got the thing to work after changing all properties for the .Net class to Virtual . More About: Properties
NHibernate: Could not find schema information
2008-04-05 11:14:00 If you receive this error:"Could not find schema information for the element 'urn:nhibernate-mapping-2.0:hibernate-map ping'", And you used the quick start guide:Change the mapping from "2.0" to "2.2". More About: Information , Find
Live Blogging from Startup Weekend, day two
2008-04-04 11:32:00 The morning began with an Israeli breakfast (bread, cheese, vegetables), and than to a discussion about how/what to implement.The chosen idea from yesterday (suggested by Maya Klug) is a time bank application (something like Timebank.org.uk), maybe combined with videos (each member creating a short video detailing what he/she is willing to contribute).There are about 50 people here, and the group is about equally divided between technical people (developer and similiar) and bussiness people (bizdev, etc). Many people here are entrepreneurs themselves.The main discussion so far was about creating a web site vs. a Facebook application, and the decision was to create a web site combined with a Facebook application.From the developers perspective, we chose using ASP.NET (majority of the coders know it), SQL server (express) as a database, and creating a 3-layered (DAL, BL, pages renderer) application (web server). We'll try implementing the DAL using NHibernate, connecting to Facebook ... More About: Blogging , Weekend , Live , Startup
Live Blogging from Startup Weekend (3)
2008-04-03 21:19:00 The story so far: 15 ideas had been selected5 most popular ideas had been selected (by vote)Possible problems had been raised for each contestant2 ideas had been selected (by vote)Each contestant answered questionsThe finalist had been selected (again, by vote) More About: Blogging , Weekend , Live , Startup
Live Blogging from Startup Weekend (2)
2008-04-03 19:51:00 First a clarification: Netwise is donating the office space, but is not the company organizing the evnet. The event is being organized by several private people who encountered the idea (no, it was not invented in Israel) and decided to organize it.After some delays the event finally began. The founders started with an introduction, basically explaining "what" and "how" of the event, and than they introduced firms that helped with the creation of the event, among them Netwise, IBM (GTU group) and a small startup called "Sharp mind solutions" (developing games aimed to boost personal attributes).And than people started giving short presentation of their ideas.So far most of the ideas come from the area of web 2.0 and revolving around the word "share", but I haven't heard many unique idea so far, but there are few gems in the suggestions. The audience (the rest of the group) is participating with the idea owner with questions and suggestions. More About: Blogging , Weekend , Live , Startup
Live Blogging from Startup Weekend
2008-04-03 18:37:00 I registered myself to this event few weeks ago, and today is the first day.The idea: a group of IT professionals getting together for a weekend (2.5 days) to create a new startup company, based on a web product. This group is divided to sub-groups (backend, client, architects, business development, etc), each sub-group in charge of a specific section of the product. Each participant receives a certain number of "shares" based on his/her contribution (based on the number of days in attendance).The event is hosted by Netwise, a company specializing in building web portals and selling products to build such products.So far the event is still being organized, each participant receives upon registration few complimentary items (notebook, shirt, food), and now we are sitting around chatting among ourselves.The first item on the agenda: Have a brainstorming and choose a product to develop.Being a long time developer, I'm already guessing the second item: Selecting technology to use for c... More About: Blogging , Weekend , Live , Startup
Generic Singleton Risks
2008-03-31 18:35:00 The Singleton pattern is very well known to .Net developers, especially the static implementation.Lately I have encountered several versions of the generic Singleton, among them the one described in Arnon's post.However, there is one possible pitfall to this approach, as it makes this code possible:Singleton<myclass> obj = Singleton<myclass>.Instance;MyClass obj2 = new MyClass();While I personally like the idea of having the freedom to use the same class in two different ways throughout the application, I know some people like their Singletons - well, single.On the other hand, if you write a class from the start as a Singleton this is not an issue.There is an inherit risk in decoupling a class from it's expected behavior, so take this into consideration before using this pattern. More About: Generic
Webbrowser.Documentcompleted and the ReadyState property
2008-03-29 21:04:00 I had previously tried using the WebBrowser class to retrieve a web page for analysis (using the DocumentText property).The problem was determining the state of the page load (since a page requires several hits before completion on average).Turns out I need to check on track backs to my post, as Anthony Stevens (you should read his "about" page) found a solution to my problem:Once the page load is complete WebBrowser.ReadyState property will be set to Complete, and then you can take the loaded page and wreak havoc on it. More About: Property
Windows, Unix and Hebrew, Oh my!
2008-03-22 16:24:00 As a .Net developer you are not bothered by trivialities such as character encoding, since the framework uses Unicode by default.But what happens when you need to encode your text so someone else (non .Net) will decrypt it, and that someone uses a single byte per character?Let's start with few definitions:ASCII - a standard that uses a single byte for each character, but only defines 128 possible symbols. There is no such thing as "Hebrew ASCII".ANSI - Same idea, but here you can use the remaining bits (out of a byte) to encode non-English specific characters. The problem is every language uses a specific version. The ANSI character table may look different on different computers, depending on the configuration.Unicode, UTF-8, etc - Using 2 or more bytes for each character, allowing room for all languages (as long as both sides agree to use the same encoding)(If you wish to learn more, you should read Joel Spolsky's "The Absolute Minimum Every Software Developer Absolutely, Positi... More About: Windows , Unix
How to Get a Job at Google
2008-03-18 19:22:00 Steve Yegge wrote a loooong post with tips for finding a job at Google .He gave all sort of tips, most of them self-explainatory (you should know about Hashtables, Algorithms etc).But there was one golden advice:Don't let the Interview Anti-Loop get you down.But what is the Interview Anti-Loop?Every single employee E at any company has at least one "Interview Anti-Loop": a set of other employees S who would not hire E.The solution is simple: "The bottom line is, if you go to an interview at any software company, you should plan for the contingency that you might get genuinely unlucky, and wind up with one or more people from your Interview Anti-Loop on your interview loop. If this happens, you will struggle, then be told that you were not a fit at this time, and then you will feel bad. Just as long as you don't feel meta-bad, everything is OK. You should feel good that you feel bad after this happens, because hey, it means you're human.And then you should wait 6-12 months and re-a...
What are YOU going to do for the planet this week?
2008-03-18 18:31:00 When you leave work this weekend, turn off your computer, light and air conditioner - and try to keep doing this every day.And there are other ways to help the environment.More info - on the Earth Hour 2008 web site. More About: Planet , Week , The Planet
.Net Performance Pointers
2008-03-14 13:11:00 After going this week to the Microsoft performance open house, here are few things to consider:Create performance counters of your own to measure various statistics.Try to avoid using interfaces and virtual methods to supports inlining.If you use a "Contains" method of a collection on structs, be sure to override the "Equals" method, since the default Object.Eqauls method used boxing twice - once for the parameter and the once for "this".Similarly, you should override the GetHashCode methods for structs, since the default implementation for a struct is very inefficient.Use Perfmon.exe to monitor the "% time in GC" - a high value may indicate mid-life crisis. More About: Performance , Pointers
Generic Singleton Factory
2008-03-09 23:03:00 This is a great way to create a Singleton instance of an exiting class without needing to specifically design it as a singleton:// Singleton factory implementation public static class Singleton where T : class { static Singleton() { // create the single instance of the type T using reflection Instance = (T)Activator.CreateInstance(typeof(T), true); } public static T Instance { private set; get; } }class Program{ public static void Main() { // test Console.WriteLine(Object.ReferenceEquals( Singleton.Instance, Singleton.Instance)); }} More About: Factory , Generic
Random.NextBytes Performance Issues
2008-03-04 13:07:00 I have became aware recently to a performance problem with the Random class, specifically the Random.NextBytes method.As it turns out this is an expansive operation:The graph displays the number of milliseconds used to perform 10,000,000 operations.The NextBytes method handle a byte array containing only 4 bytes.This is linear - using an array of 4000 bytes will take 1000 times longer to complete the operation!However, there may be a work-around using the BitConverter class.Use BitConverter.GetBytes(Random.NextDouble() ) to get a randomized array of 8 bytes.Here are the results:As you can see, generating an array of 8 bytes this way takes half the time of generating it using the NextBytes method. More About: Performance , Issues
Using XmlSerializer for Serialization/Deserialization
2008-03-03 22:16:00 This is something I wrote a while ago to allow easy way to serialize/deserialize various objects to and from XML by creating an adapter around the XmlSerializer class.Since I don't know how this XML is going to be used this class stores it inside a string.Serialize usage:string s = SimpleSerializer.Instance.ToString(myObje ct);XmlDocument xDoc = new XmlDocument();xDoc.LoadXml(s);Deserialize :MyClass obj = SimpleSerializer.Instance.FromString(xDoc .OuterXML); /// <summary> /// Objects serializer/deserializer /// </summary> public class SimpleSerializer { private static readonly SimpleSerializer instance = new SimpleSerializer(); //Singleton /// <summary> /// Gets the class's instance. /// </summary> /// <value>The instance.</value> public static SimpleSerializer Instance { get { return instance; } } /// <summary> /// Private constructor - prevents t...
The Problem With Crutches
2008-03-01 22:20:00 Coffee is good for you, as long as you don't drink too much.But how many of you can't pass the day without drinking too many cups?How many of you are addicted to coffee? In the recent bloggers meeting in Microsoft Israel I complained about the pain it is to add a picture to a blog post using the Community server.The reply?"Why don't you use Live Writer to publish posts instead of the online control panel?"In a recent post Doron wrote about his love for ReSharper:"I honestly can't work without it anymore. It has changed the way I code, and I will never attempt a serious refactoring without it"There are many great tools out there that can make you more productive. No argument about that. The problem starts when you become dependant of those tools.That's the problem with crutches - if you ever lose them, you become handicapped. More About: Problem
If Search Engines Where Girls
2008-02-28 04:26:00 From the SEO article "On-page SEO for small Companies": Google is the bombshell who everyone drools over. She knows this and lords it over everyone. You’ve really got to work to get Google’s trust. She also has a weird fascination with blogging. Yahoo is wild and erratic. MSN is the world’s cheapest date, who will practically faint if you show any interest in her at all. More About: Girls , Search Engines , Search , Engines
New Technologies Trends
2008-02-25 20:49:00 I have written before a short comparison between "old" and newer technologies, but at the beginning of that post I state that part of the choice of a new technology is the market trend towards that technology.After reading Justin's post showing that moving to ASP.NET is beneficiary because it's becoming a prominent technology I decided to implement his research methods (using Google) on different technologies.I began by searching for file typesHowever, this reflects only on files shared on the web, and since JAVA is a web technology (unlike Delphi) the results don't say much.But Google trends provides a clearer picture - while C# remains stable, other programming languages are on the decline:Focusing on the .Net world, you can clearly see new technologies are dominant in Google searches:WPF vs. WinformsWCF vs. RemotingThe rise of .Net Framework 3.0 technologiesWith Silverlight being the "Hot New Thing" (maybe because it's a web-based technology)So maybe choosing a new technology... More About: Trends , Technologies
Microsoft Goes Open Source?
More articles from this author:2008-02-23 13:09:00 In a recent announcement Microsoft declared a "Strategic Change" in their relationship with the open source community:Publishing on MSDN over 30,000 pages of documentation for Windows client and server protocols and API. Protocol documentation for additional products, such as Office 2007, will be published in the upcoming months.Microsoft is providing a covenant not to sue open source developers for development or non-commercial distribution of implementations of these protocols. These developers will be able to use the documentation for free to develop products. Microsoft will design new APIs for the Word, Excel and PowerPoint applications in Office 2007 to enable developers to plug in additional (OS?) document formatsHowever, although the company said developers will not need to take a licence or pay a royalty or other fees to access this information, those covered by patents will still be subject to a royalty from developers who want to use them for commercial applications (Micro... More About: Open Source , Open , Source , Open-Source 1, 2, 3 |



