tag:blogger.com,1999:blog-37035312024-03-07T22:35:38.105+01:00Redsolo's blog siteGeneric blog gripes and raves, mostly about java, C# and software development.redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comBlogger40125tag:blogger.com,1999:blog-3703531.post-20486484946078858852017-05-17T19:03:00.000+02:002017-05-17T19:03:05.725+02:00Stack Overflow merge<div dir="ltr" style="text-align: left;" trbidi="on">
Please merge account https://stackoverflow.com/users/28553/redsolo and https://stackoverflow.com/users/8019481/redsolo</div>
redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-38474276534741658382009-11-23T21:35:00.004+01:002009-11-23T22:37:52.865+01:00Reply to an "Android vs Windows Mobile" post<span class="Apple-style-span" style="font-family:arial;"><div>This is a response for the <a href="http://jkontherun.com/2009/11/23/windows-mobile-vs-android-winmo-is-better-than-you-think">"Windows Mobile vs. Android: WinMo Is Better Than You Think"</a> blog post. That blog post might at first look unbiased but it isn't; the author must have skimmed the android #101 class and missed vital parts.</div><div><br /></div><div><b>Multi-tasking - Big advantage: Windows Mobile</b></div><div><i>"Anyone who has run an Android phone for more than a few minutes should fire up a task manager and have a look. You’ll likely see 20 or more tasks running in the background, not unlike WinMo."</i> </div><div>Yes, you will see the applications which consists of services and Activities (ie a Form, Dialog or Window), but the big difference is that those activities are NOT running at the same time as your main activity (the one that is on the front). If you want multitasking, then look at the running services. On WinMo they background applications are still RUNNING, they are consuming both memory and CPU, that is one big difference between Android and WinMo.</div><div><br /></div><div><i>"WinMo automatically changes memory allocation based on the needs of each app, and if the system memory starts to get stretched thin, the OS shuts down background tasks automatically."</i></div><div>How is the priotization done? For Android it is a clear priority path, first all activities that are not showing is killed, then it starts killing of services and lastly the activity in the front. On WinMo, it is not soo clear. How will WinMo distinguish an application for checking emails from the Chess application you stopped playing 2 days ago? </div><div><br /></div><div>The post also forgets to mention that the android framework will bring your activities back into memory after they have been swapped out. That way the user will not notice that an application (or actually activity has been swapped out because of the lack of memory. Does WinMo do anything even close to bring an application back up? No! Android has framework support for making it seamless. </div><div><br /></div><div>About memory, the Windows Mobile 6.5 (and all older versions) has an application memory limit of 32MB. Shared DLLs will eat up that memory if they have been loaded in a bad way. Please read http://msdn.microsoft.com/en-us/library/ms836325.aspx for more info on how one application can reduce the available memory for another application. It is amazing that an OS in 2009 can have this limitation. </div><div><br /></div><div>Multitasking on android is a more modern approach than WinMo has (or PocketPC as nothing has really changed). It helps the developer of creating a never ceasing, seamless user experience. I have NEVER had the phone freeze so it has to be rebooted because of a faulty application. That happens on WinMo now and then. Why is it even possible for an application to nuke an OS? </div><div><br /></div><div>Yes, Android has a big problem with the SD card issue, but comparing that to multitasking is like comparing apples and bees. </div><div><br /></div><div><b>Available apps - Advantage: Windows Mobile</b></div><div><i>"Not a lot of apps are in there yet, which is not surprising given how new the store is to the market. " </i></div><div>iPhone had 3,000 applications after the first month. How many does marketplace have today? 400, 500? It is time for MS to put their money where their mouth is. When iPhone started saying that they have so and so many apps in their appstore, MS boasted that there were over 20,000 apps available for WinMo. But where are they? Why don't the developers deliver the applications to the best place to sell and advertise an application? You also forget to mention that the marketplace has a 10mb limit, what does that do to real games? </div><div><br /></div><div><i>"Opera Mobile 10 is as good as any mobile browser out there on any platform, and it is free for Windows phone users. It is so exceptional that HTC has been using it as the default browser on its WinMo phones for years, and with good reason. It demonstrates the quality and quantity of apps available for the WinMo platform"</i></div><div>Android has opera as well, AND a web browser based on the webkit engine (google it, if you dont know it). Opera is a great software, but it does not equal that all other apps for WinMo is great. Im not saying that Android applications are of a higher quality as there are a few ones that will crash and burn but thankfully they dont bring the OS down with them.</div><div><br /></div><div><b>User interface - Advantage: Windows Mobile </b></div><div><i>"Spb Mobile Shell has been out for years, and the latest version is for WinMo what Sense is for Android. The difference is that Mobile Shell is user obtainable, where HTC Sense must be installed on a phone as purchased."</i></div><div>I guess you have missed the other Home replacements? There are several ones that allows the user to custom design their front ends, search in the android market for "Home" and you shall find.</div><div><br /></div><div><i>"Android phones with the stock interface are pretty plain Jane, as is the WinMo interface."</i></div><div>It is not possible to say, with a straight face, that vanilla WinMo is as good as vanilla android if you have used the two of them next to each other. None of them of course looks as good as the iPhone.</div><div><br /></div><div><i>"The end result is that a WinMo phone running Sense is as good as an Android phone running it."</i></div><div>Yes, Touchflo and Sense are great front ends and really responsive, but as soon as you get one or two steps away from it, you see the ugliness of the old WinMo UI. HTC has done a lot to hold WinMo under its arms, as they have been working mainly on the front end that is the only thing the user sees when looking for a new phone. </div><div><br /></div><div>Then if someone could explain to me why the HTC Sense is more responsive than the WinMo 6.5 start menu when they are run on the same hardware? I have tried the HD2, and when you scroll up and down in the WinMo start menu it will do some strange jumps, which you cant see when using HTC Sense. Also, there is another problem here with a nice front end over the WinMo UI. The user will use fingers gestures to go back and forth from views to other views (which all modern phones should do),but as soon as you go into the WinMo UI you have to bring out the stylus to check a checkbox or something. Unfortunately the next WinMo 6.5.3 will not fix this, as just increasing the size of every control isnt the solution.</div><div><br /></div><div><b>Computer desktop integration: Advantage: Tie</b></div><div>This section nails it, it all depends on if you are using exchange or gmail. I am a gmail user and Im quite happy, and I know HTC Hero users that use exchange and are happy with it. Of course using gmail on WinMo is now a viable option thanks to the Google exchange synchronization.</div><div><br /></div><div><b>Last </b></div><div>I am a software developer that mostly work with the WinMo platform, and it doesnt go a week without me implementing work arounds for some undocumented change in an API. Especially today as the software is targeting Pocket PC 2003 to Windows Mobile 6.5.3. Add Smartphone to the mix and it is even more fun.</div><div><br /></div><div>For a nice read on the HD2, check this out <a href="http://www.sanneblad.com/2009/11/22/htc-hd2-worst-windows-mobile-device-yet/">this review</a>.</div></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-7259182886064038402008-11-24T13:25:00.009+01:002008-11-25T10:10:47.486+01:00Sending WM_WININICHANGE message on device with HTC TouchFlo 3D will crash the device<span class="Apple-style-span" style="font-family:arial;">Today I finally solved a very strange bug in a Windows Mobile project Im currently working on. The bug would only show up on HTC devices, and not our HTC devices we had at our location. After the application was installed and the user started it, the whole device would freeze and reboot itself after a minute or so.<br /><br />After some digging around, rebuilding, re-installing for way too many times; we found out that if the HTC TouchFlo 3D today plugin was enabled the device would crash. With that knowledge I was able to pin point the location of the failure which was that the installation DLL sends a </span><span style="font-weight:bold;"><span class="Apple-style-span" style="font-family:arial;">WM_WININICHANGE </span></span><span class="Apple-style-span" style="font-family:arial;">message to refresh the PocketPc Today plugins.<br /><br />As many </span><a href="http://www.pocketpcdn.com/articles/changetodaytheme.html"><span class="Apple-style-span" style="font-family:arial;">sites</span></a><span class="Apple-style-span" style="font-family:arial;"> and </span><a href="http://forum.xda-developers.com/archive/index.php/t-398285.html"><span class="Apple-style-span" style="font-family:arial;">forum posts</span></a><span class="Apple-style-span" style="font-family:arial;"> states, this is the only way to refresh the Today plugins.<br /><br /><tt>::SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);</tt><br /><br />Of course, this is not documented anywhere within MS documentation; and the </span><a href="http://msdn.microsoft.com/en-us/library/ms725499(VS.85).aspx"><span class="Apple-style-span" style="font-family:arial;">documentation</span></a><span class="Apple-style-span" style="font-family:arial;"> that exists states that the </span><span style="font-weight:bold;"><span class="Apple-style-span" style="font-family:arial;">wParam </span></span><span class="Apple-style-span" style="font-family:arial;">isnt used at all </span><span style="font-style:italic;"><span class="Apple-style-span" style="font-family:arial;">(which in fact it is)</span></span><span class="Apple-style-span" style="font-family:arial;">.<br /><br />It seems that the HTC TouchFlo 3D isnt capable of handling the </span><span style="font-weight:bold;"><span class="Apple-style-span" style="font-family:arial;">WM_WININICHANGE </span></span><span class="Apple-style-span" style="font-family:arial;">properly, and even just opening the calendar application after that sending that message will crash the device. So if your WindowsMobile application sends that message, I would advise you to look into this. Using the replacement message </span><span style="font-weight:bold;"><span class="Apple-style-span" style="font-family:arial;">WM_SETTINGCHANGE</span></span><span class="Apple-style-span" style="font-family:arial;"> does not change anything, the device will still crash.<br /><br /><br />One solution is to check if the HTC TouchFlo Today plugin is enabled, which can easily be retrived through the regkey </span><span style="font-style:italic;"><span class="Apple-style-span" style="font-family:arial;">"HKLM\Software\Microsoft\Today\Items\TouchFLO 3D\Enabled"</span></span><span class="Apple-style-span" style="font-family:arial;">. If it is enabled, then do not send the <span style="font-weight:bold;">WM_WININICHANGE</span> message.</span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-44518540572944501522008-11-04T21:01:00.009+01:002008-11-04T22:03:26.597+01:00Trying out SimplifyMedia on DebianI just noticed <a href="http://www.simplifymedia.com/">SimplifyMedia</a>, and wanted to start sharing music from my home media server. The server is running Debian etch (4.0), and there is no debian repository for it (not surprinsgly as it is not open source). Here's a short description on how I got it to work on my Debian machine.<br /><br /><b>Startup</b><br /><ol><br /><li>Download the package from <a href="http://www.simplifymedia.com/download.html">SimplifyMedia Downloads</a>.</li><br /><li>Unpack the contents to a folder<br /><br /><tt>tar zxfv simplifymedia.tar.gz</tt></li><br /><li>Install all necessary debian packages to get the SimplifyMedia server running<br /><tt>aptitude install libavahi-client3 libavahi-common3 libavahi-compat-libdnssd1 libavahi-core5 libc6 libdaemon0 libdbus-1-3 libfreetype6 libgcc1 libidn11 libpng12-0 libssl0.9.8 libstdc++6 libx11-6 libxau6 libxdmcp6 libxext6 zlib1g</tt></li><br /><li>First you need to register for an account, start the SimplifyMedia GUI and enter all needed details. After registering close the GUI.<br /><br /><tt>simplifymedia/SimplifyMedia</tt></li><br /><li>Start the simplifymedia server using the newly created credentials<br /><br /><tt>simplifyserver/simplifyserver.sh -n USER -l HomeTest -p PASSWD -s /home/media/Music/</tt></li><br /><li>Now the server will start scanning your folders, and soon publish the location.<br /></li><br /></ol><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdChov8kfjB6DPwMvckyMkCp50XlgqRfYK85w6UgVsVf5ElBsfNKQTzJWo5GXPcw_-z8p5VJIc1Wwk7RHX4pwTMgj8AiPG67j3n1mSCp7PsBpeNukzKTUV0qM20ceinZWMqw-I7w/s1600-h/SimplifyMedia-1.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 228px; height: 282px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdChov8kfjB6DPwMvckyMkCp50XlgqRfYK85w6UgVsVf5ElBsfNKQTzJWo5GXPcw_-z8p5VJIc1Wwk7RHX4pwTMgj8AiPG67j3n1mSCp7PsBpeNukzKTUV0qM20ceinZWMqw-I7w/s400/SimplifyMedia-1.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5264907426546721026" /></a><br /><br /><b> Gotchas/Problems</b><br /><ul><br /><li>I'm using the Winamp plugin on my Windows XP laptop, and many of the files does not played when selected. This is a major issue, but I'm hoping it will be fixed soon.</li><br /><li>The server did not find all my mp3's, it's currently missing 15% of my files.</li><br /><li>Even though I'm almost sitting next to the server (using Wlan) the playback stutters sometimes.</li><br /><li>There is no daemon support, so I need to fix something.</li><br /><li>The password is shown in clear text when doing a <tt>ps aux</tt></li><br /></ul><br /><br /><b>Impression</b><br />I was more impressed when reading about it than now after I've used it. The problems that it can not find all files, not able to play all files on a client; are a little too much for me to accept. But hopefully it will improve and become something great!redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-32041980204500212112008-07-15T10:17:00.001+02:002008-07-15T23:36:55.874+02:00Hudson now supports Team Foundation Server<span style="font-family:arial;">Today I released a plugin that adds support for Microsoft's source control manager <a href="http://msdn.microsoft.com/en-us/library/aa730884%28VS.80%29.aspx">Team Foundation Server</a> to <a href="http://hudson.dev.java.net/">Hudson</a> (a continuous integration server). The plugin makes it possible to retrieve files and poll the server to detect changes on a project. If Hudson detects a change, a new build can be started automatically. Hudson will also </span><span style="font-family:arial;">display the changes that occurred in each build.<br /><br /></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHeuv1Mx8HFoOjllKWjkRBcQvtg6Hdo9bQ9XjGO9LhzcCg-sy7k3Wwtt_9NUe1GxcKcSgkqssySSXsFS-c4BntRIsfuFMj0L_xe2LUiGpyNXW5W7wsNsFtyqeOl6scin5osVI1tw/s1600-h/tfs-changes.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHeuv1Mx8HFoOjllKWjkRBcQvtg6Hdo9bQ9XjGO9LhzcCg-sy7k3Wwtt_9NUe1GxcKcSgkqssySSXsFS-c4BntRIsfuFMj0L_xe2LUiGpyNXW5W7wsNsFtyqeOl6scin5osVI1tw/s400/tfs-changes.png" alt="" id="BLOGGER_PHOTO_ID_5222994422720395698" border="0" /></a><span style="font-family:arial;"><br />Configuring the plugin is easy as it is only requires the server URL and the path to the project. Hudson will take care of the rest, such as creating a workspace and work folder to store the files in. </span> <span style="font-family:arial;"><br /><br /></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAPG2gDWsyYKswOIcLBRtoIs0Auh70yppCptTikCb0oN5KLZAkcrmHUxpaFlZHs9xQyrLzT_PRtmjFTzWdzBuStvsASzXATdNDMMOqWFI03pQcRsYMSZtlpyNGUyqtBCaLdKmmeg/s1600-h/tfs-configuration.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAPG2gDWsyYKswOIcLBRtoIs0Auh70yppCptTikCb0oN5KLZAkcrmHUxpaFlZHs9xQyrLzT_PRtmjFTzWdzBuStvsASzXATdNDMMOqWFI03pQcRsYMSZtlpyNGUyqtBCaLdKmmeg/s400/tfs-configuration.png" alt="" id="BLOGGER_PHOTO_ID_5222991149178886642" border="0" /></a><span style="font-family:arial;">The plugin supports both the command line client in the </span><a style="font-family: arial;" href="http://www.microsoft.com/downloads/details.aspx?familyid=0ED12659-3D41-4420-BBB0-A46E51BFCA86&displaylang=en">Team Explorer package</a><span style="font-family:arial;"> from Microsoft and the </span><a style="font-family: arial;" href="http://teamprise.com/products/clc/">command line client from Teamprise</a><span style="font-family:arial;">. An upcoming version of the plugin will add support for the </span><a style="font-family: arial;" href="http://code.google.com/p/opentf/">opentf command line client</a><span style="font-family:arial;">.</span><br /><br /><span style="font-family:arial;">So if you wanted to give Hudson a whirl but couldn't use it because you were using TFS, now is the chance to try it out! </span><span style="font-family:arial;">For more information about this plugin, <a href="http://hudson.gotdns.com/wiki/display/HUDSON/Team+Foundation+Server+Plugin">check out the wiki</a>. </span><span style="font-family:arial;">There are also several other .NET plugins for <a href="http://hudson.gotdns.com/wiki/display/HUDSON/MSBuild+Plugin">MSBuild</a>, <a href="http://hudson.gotdns.com/wiki/display/HUDSON/NAnt+Plugin">NAnt</a>, <a href="http://hudson.gotdns.com/wiki/display/HUDSON/NUnit+Plugin">NUnit</a>, <a href="http://hudson.gotdns.com/wiki/display/HUDSON/Violations+Plugin">FxCop, StyleCop</a> and <a href="http://hudson.gotdns.com/wiki/display/HUDSON/Warnings+Plugin">compile warnings</a>. I'm currently working on a plugin that integrates <a href="http://codeplex.com/">CodePlex</a> into Hudson.<br /><br /><span style="font-weight: bold; font-style: italic;">Update:</span> The plugin can be downloaded <a href="https://hudson.dev.java.net/servlets/ProjectDocumentList?folderID=9590&expandFolder=9590&folderID=2761">here</a>, or through the <a href="http://weblogs.java.net/blog/johnsmart/archive/2008/06/new_features_in_1.html">update manager</a> in Hudson.<br /></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-26554638718817304902008-05-28T08:15:00.005+02:002008-09-19T08:52:32.928+02:00Hudson adds support for StyleCop<span style="font-family:arial;">Last week <a href="http://blogs.msdn.com/sourceanalysis/">Microsoft</a> released <a href="http://code.msdn.microsoft.com/sourceanalysis">StyleCop</a> (aka Microsoft Source Analysis for C#), a tool that analyzes C# code and enforces a certain code style (similar to <a href="http://checkstyle.sourceforge.net/">Checkstyle</a>). The tool will go through all C# source files and mark the code style violations. Now <a href="http://hudson.dev.java.net/">Hudson</a> <i>(a Continuous Integration server)</i> together with the <a href="http://hudson.gotdns.com/wiki/display/HUDSON/Violations+Plugin">Violations plugin</a> has added support for parsing the StyleCop XML report and display the results for every build.<br /><br />The Violations plugin displays a trend graph over builds so it is real easy to see that your project is progressing in the right direction (decreasing the number of violations). <i>As you can see the plugin also supports FxCop reports.</i><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQumlBVfO54i_hkIfc9S0LY4jPtQ9Gh1DMqPEASpBkYyCp4zOwJJHCOJV_y6BfkTY8DGPmWBoG_cXvp6mHlDH9NJ1m16444lxzYnpzoxzyR8pwp4KHz-k-eoZtfpy9NHy9oGD3eA/s1600-h/stylecop-trend.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQumlBVfO54i_hkIfc9S0LY4jPtQ9Gh1DMqPEASpBkYyCp4zOwJJHCOJV_y6BfkTY8DGPmWBoG_cXvp6mHlDH9NJ1m16444lxzYnpzoxzyR8pwp4KHz-k-eoZtfpy9NHy9oGD3eA/s400/stylecop-trend.png" alt="" id="BLOGGER_PHOTO_ID_5205182114191366594" border="0" /></a><br /><br />Each build will display a listing of the files that are violating the code style, and it is also possible to see the number of fixed (or introduced) violations for every build.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIhHBWlfPOSJew2YKLwtGbH0pLxDAQ135RrlImFIAu4qqnFv1Ko3unrzyAKoaayLnrFse_H-OnWgyS_MOMqOIyifQz7GsFcudRcp4KLtYcq5LY9StNmdDaIJHytHTPyanO5nrcPQ/s1600-h/stylecop-file-listing.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIhHBWlfPOSJew2YKLwtGbH0pLxDAQ135RrlImFIAu4qqnFv1Ko3unrzyAKoaayLnrFse_H-OnWgyS_MOMqOIyifQz7GsFcudRcp4KLtYcq5LY9StNmdDaIJHytHTPyanO5nrcPQ/s400/stylecop-file-listing.png" alt="" id="BLOGGER_PHOTO_ID_5205184034041747954" border="0" /></a><br /><br />Clicking on a file will display excerpts from the C# code showing the violations.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGYFHKPEWFtnhOlzzGEEJX0l4i9B0v5jLo2bRm6JuPBXTLLtm0iQ58PETLdwWMfFUzTU5zOLTnM5wsMOIMka552sYANYIJSrnpqcAVhz_t7czVf04sMJYee6a9yWm8mZVV2Qp8lQ/s1600-h/stylecop-file.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGYFHKPEWFtnhOlzzGEEJX0l4i9B0v5jLo2bRm6JuPBXTLLtm0iQ58PETLdwWMfFUzTU5zOLTnM5wsMOIMka552sYANYIJSrnpqcAVhz_t7czVf04sMJYee6a9yWm8mZVV2Qp8lQ/s400/stylecop-file.png" alt="" id="BLOGGER_PHOTO_ID_5205182122781301202" border="0" /></a><br /><br /><b>Setup</b><br />Follow the <a href="http://blogs.msdn.com/sourceanalysis/pages/source-analysis-msbuild-integration.aspx">guideline here</a> after <a href="http://code.msdn.microsoft.com/sourceanalysis/Release/ProjectReleases.aspx?ReleaseId=1047">downloading</a> StyleCop. Add the <tt><Import Project="$(ProgramFiles)\MSBuild\Microsoft\SourceAnalysis\v4.2\Microsoft.SourceAnalysis.targets" /></tt> to every csproj file that you are building within Hudson. When the VS project is built, StyleCop will store a file named <tt>StyleCopViolations.xml</tt> <i>[Update, if you are using StyleCop 4.2 enter <tt>SourceAnalysisViolations.xml</tt> </i> in the project folder. <i>As of now, there is no way to store it elsewhere.</i> The XML file contains all violations that were found in the Visual Studio project.<br /><br /><b>Hudson Configuration</b><br />To configure the violations plugin, enable the "Report violations" check box. If there are several VS projects in the build, you should use <tt>**/*/SourceAnalysisViolations.xml</tt> as it will find XML files in all sub folders.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJaOlfci3Qb7-ozKUusk7U9A157ldYTr7bZLMZhN9L__eexWm90vB7RWa8uYw-nrqGebkUIbkfMN75MPkEwQ1iTdXefNhyphenhyphenPs0W5iQqVAe86JBdnJSCKyIMj1GoM70Cu4L6Adedpg/s1600-h/stylecop-config.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJaOlfci3Qb7-ozKUusk7U9A157ldYTr7bZLMZhN9L__eexWm90vB7RWa8uYw-nrqGebkUIbkfMN75MPkEwQ1iTdXefNhyphenhyphenPs0W5iQqVAe86JBdnJSCKyIMj1GoM70Cu4L6Adedpg/s400/stylecop-config.png" alt="" id="BLOGGER_PHOTO_ID_5205299117690444290" border="0" /></a><br /><br />After configuration, start a new build to analyze and display the StyleCop results in Hudson. <i>To see a trend graph you need at least two successful builds.</i><br /><br /><b>Tips<br /></b><ul><li>Do not enable all rules, choose those that are valid for your organization and make sense for you.<br /></li><li>Do not activate too many rules at first, as it probably will generate too many violations. Too many violations may be ignored by your co-workers, as it seems to be too much work to fix them all. When the most critical code style violations has been fixed, increase the number of rules.</li></ul></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-16692169857727175242008-05-21T10:07:00.010+02:002008-05-21T10:24:06.543+02:00Advance to the next Eclipse level by using the MouseFeed plugin<span style="font-family:arial;"><a href="http://www.mousefeed.com/">MouseFeed</a> is the best eclipse plugin that I have tested/used in a while. The plugin will make you learn the eclipse keyboard shortcuts and thus be quicker when using Eclipse. If you are using the mouse or the menu bar to select an action, and there is a shortcut for the action, the shortcut will be displayed in a big message box.<br /><br /></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgASp_40pVe6WIDXRXDc59_kYBDFXqNJcOoEFhS3x4DP21qZipCHQ-eaH7QhL4mvHaRuFKij3qs4ZYBPyLdLx1LIDEIQ-NIy_cTmsHDu6lQ2qY1hwnQqYdtFKjD10_5WZ2VdBkLSw/s1600-h/mousefeed-rename.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgASp_40pVe6WIDXRXDc59_kYBDFXqNJcOoEFhS3x4DP21qZipCHQ-eaH7QhL4mvHaRuFKij3qs4ZYBPyLdLx1LIDEIQ-NIy_cTmsHDu6lQ2qY1hwnQqYdtFKjD10_5WZ2VdBkLSw/s400/mousefeed-rename.png" alt="" id="BLOGGER_PHOTO_ID_5202741786083938610" border="0" /></a><span style="font-family:arial;"><br />The message box is not too big, but enough annoying so in order to never see it you are forced to learn the shortcuts. So you learn even if you don't want to!<br /></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-17503464314335441512008-05-14T08:02:00.000+02:002008-05-21T10:25:44.181+02:00Guide to building .NET projects using HudsonIn this guide I'm going to show how to set up a C# project on the Continuous integration server <a href="http://hudson.dev.java.net/">Hudson</a>. I've been using Hudson on .NET projects since september and it works really well. I'm going to use <a href="http://www.team-mediaportal.com/">Media Portal</a> as the example project.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3sVXeQFGlBh3Oemi_rh0dtIyuagholUWmAEFKdOrmjdT8HRo4KL5Tdgwf7BKRTb6NMHTgnql5TOwYGahwbGqj8vJOkp5EP8gh2gAH1QSKll_3Jqe2e27NUSwi0EXMrYW3jC-QzA/s1600-h/cs-main.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3sVXeQFGlBh3Oemi_rh0dtIyuagholUWmAEFKdOrmjdT8HRo4KL5Tdgwf7BKRTb6NMHTgnql5TOwYGahwbGqj8vJOkp5EP8gh2gAH1QSKll_3Jqe2e27NUSwi0EXMrYW3jC-QzA/s400/cs-main.png" alt="" id="BLOGGER_PHOTO_ID_5200207562105770146" border="0" /></a><br />The below goals will be solved in this guide:<br /><ul><br /><li>Get the source code from the Subversion repository</li><ul><li>Link change logs to the repository browser using ViewVC</li></ul><li>Build the project using MBuild</li><br /><li>Run the tests using NUnit and display the results together with a trend graph</li><br /><li>Publish artifacts from the build (nightly builds)</li><br /><li>Run FxCop on an assembly and display warnings (linked with source code) and a trend graph </li><br /><li>Search the source code for TODO, FIXME comments and display the open tasks with links to the source code</li></ul><br /><span style="font-weight: bold;font-size:130%;" >Initial downloads</span><br />The following files are needed besides Java (at least 1.5). Get the latest version of all files and notice that the Hudson file has the extension .war and plugins .hpi. <i>This guide assumes that MSBuild, NUnit and FxCop are already installed and working.</i><br /><ul><li>Hudson server application (<a href="https://hudson.dev.java.net/servlets/ProjectDocumentList?folderID=2761">download)</a></li><br /><li>MSBuild plugin (<a href="https://hudson.dev.java.net/servlets/ProjectDocumentList?folderID=7951&expandFolder=7951&folderID=2761">download</a>)</li><br /><li>NUnit plugin (<a href="https://hudson.dev.java.net/servlets/ProjectDocumentList?folderID=7965&expandFolder=7965&folderID=7951">download</a>)</li><br /><li>Violations plugin (FxCop support among other such as Simian, CPD, PMD and PyLint) (<a href="https://hudson.dev.java.net/servlets/ProjectDocumentList?folderID=7879&expandFolder=7879&folderID=7965">download</a>)</li><br /><li>Open Tasks plugin (<a href="https://hudson.dev.java.net/servlets/ProjectDocumentList?folderID=7892&expandFolder=7892&folderID=7879">download</a>)</li></ul><br /><span style="font-weight: bold;font-size:130%;" >Installation steps</span><br />I'm going to install Hudson into c:\Program Files\Hudson.<br /><ol><br /><li>Copy the hudson.war file to <span style="font-style: italic;">c:\Program Files\Hudson</span></li><br /><li>Start Hudson through <span style="font-style: italic;">"java -DHUDSON_HOME=data -jar hudson.war"</span>. Verify that you can access Hudson through <a href="http://localhost:8080/">http://localhost:8080</a></li><br /><li>Copy the plugins to <span style="font-style: italic;">c:\Program Files\Hudson\data\plugins</span></li><br /><li>Stop Hudson by pressing <span style="font-style: italic;">Ctrl+C</span> in the command prompt where you started Hudson.</li><br /><li>Start Hudson again and you should be set to go.</li></ol><br /><span style="font-weight: bold;font-size:130%;" >Hudson system configuration</span><br />Follow the following steps to configure the tools that Hudson will use in building MediaPortal.<br /><ol><br /><li>Go to the System configuration at <a href="http://localhost:8080/configure">http://localhost:8080/configure</a>.</li><br /><li>MSBuild Builder - Set the path to the MSBuild tool to <span style="font-style: italic;">C:\Windows\Microsoft.NET\Framework\v2.0.50727\msbuild.exe</span></li></ol><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuGCk9hBR6MQLTF7aCnftY5RJOE6kEfkX6SYk5ELVDXfoUpgx3lBvlu8JfIjQvisR9XwZ_QW__d2eUZKXYz8qtfmcpf3iEXjCQUjkUNHBF6cUByHY1d-mamNk6TJOd6DlIjjESXg/s1600-h/cs-msbuild.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuGCk9hBR6MQLTF7aCnftY5RJOE6kEfkX6SYk5ELVDXfoUpgx3lBvlu8JfIjQvisR9XwZ_QW__d2eUZKXYz8qtfmcpf3iEXjCQUjkUNHBF6cUByHY1d-mamNk6TJOd6DlIjjESXg/s400/cs-msbuild.png" alt="" id="BLOGGER_PHOTO_ID_5200208004487401650" border="0" /></a><br /><br /><span style="font-weight: bold;font-size:130%;" >MediaPortal job configuration</span><br /><ol><br /><li>Click the "New job" link at the home page.</li><br /><li>Enter the name <span style="font-style: italic;">"MediaPortal"</span>, check the <span style="font-style: italic;">"Build a free-style software project"</span> and press OK.</li></ol><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt3BK1W7WQPQ-3-s3S6Y-l8gsUDhcjO1z69n55sVLG10mop-rxZbVDL6jzbf0iGfi7FkGi-CS61vUBzwNqXbCyqZbi-hAa9KOHI_SjY6ShD_KW6bQTn2eweMC9BO_jqJFVHPi7EQ/s1600-h/cs-create.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt3BK1W7WQPQ-3-s3S6Y-l8gsUDhcjO1z69n55sVLG10mop-rxZbVDL6jzbf0iGfi7FkGi-CS61vUBzwNqXbCyqZbi-hAa9KOHI_SjY6ShD_KW6bQTn2eweMC9BO_jqJFVHPi7EQ/s400/cs-create.png" alt="" id="BLOGGER_PHOTO_ID_5200208794761384130" border="0" /></a><br /><br /><span style="font-weight: bold;font-size:130%;" >Source code management</span><br />MediaPortal uses a Subversion SCM. Hudson supports CVS and SVN out of the box, but there are many <a href="http://hudson.gotdns.com/wiki/display/HUDSON/Plugins#Plugins-Sourcecodemanagement">plugins for other SCMs</a>. After checking out the files from the repository Hudson will show the new change sets since the previous build in the Build page. A detailed view of change sets can be seen in the Changes page as the name of the developer, files that were changed and the comment for the change. Each change set is linked to the <a href="http://mediaportal.svn.sourceforge.net/viewvc/mediaportal/">MediaPortal subversion repository browser</a>, so it is easy to browse the actual file that changed.<br /><ol><br /><li>Press the Subversion radio button to configure the SCM.<br /></li><li>Repository URL=<span style="font-style: italic;">https://mediaportal.svn.sourceforge.net/svnroot/mediaportal/trunk/mediaportal</span></li><br /><li>Local module directory=<span style="font-style: italic;">.</span></li><br /><li>Press the Advanced button</li><br /><li>Repository Browser=<span style="font-style: italic;">ViewSVN</span>, URL=<span style="font-style: italic;">http://mediaportal.svn.sourceforge.net/viewvc/mediaportal/</span></li></ol><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_sjSgA3E3OrHChHTnxWfwPHE0rqQcSkhKwt3WOY0YUVj0WvVWBw8_2py7ot6dhghpfsFMqLcUNEbLgr-_NBwVNfps1XhpnarzqRygxjYi59HDRJEoOcALx1QnQhkyD7PWQJqidg/s1600-h/cs-config-scm.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_sjSgA3E3OrHChHTnxWfwPHE0rqQcSkhKwt3WOY0YUVj0WvVWBw8_2py7ot6dhghpfsFMqLcUNEbLgr-_NBwVNfps1XhpnarzqRygxjYi59HDRJEoOcALx1QnQhkyD7PWQJqidg/s400/cs-config-scm.png" alt="" id="BLOGGER_PHOTO_ID_5200208983739945170" border="0" /></a><br />To test the configuration, press Save and then Build. The source code will be downloaded from the repository and put into the Workspace. If there were any changes in the SCM repository they can be viewed in the Changes page.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCqohsIBRxewDkCF7Q7Utp2g7NjmGPjSKCBVO-98df0U42k6crEpYu8cnOf4MaU8c-ybN_aWzAVIJbZDRxOFq-QhPAiRYnwEXAKRV2a0DSG1ET5FZ8MkS72-X0DKTZm8rB858lDg/s1600-h/cs-changelog.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCqohsIBRxewDkCF7Q7Utp2g7NjmGPjSKCBVO-98df0U42k6crEpYu8cnOf4MaU8c-ybN_aWzAVIJbZDRxOFq-QhPAiRYnwEXAKRV2a0DSG1ET5FZ8MkS72-X0DKTZm8rB858lDg/s400/cs-changelog.png" alt="" id="BLOGGER_PHOTO_ID_5200200544129208290" border="0" /></a><br />When the build is completed verify that it has checked out the code by going to the Workspace page. Using the Workspace page you can browse and view the files that has been checked out and it doesn't matter if the files are on the master or on a distributed slave!<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcUgVrEFxLGa7bDqEZGeLvVI2TQ4QZb54AyAw8ZfDH3v8Xb5TTerRGYsHxOldCbiFAxkD0jX7brGAlXzYSmRHbQEPo_tKQG4dLwOdTV6tDeMKOxOYf6FwAXCwsNYxUpZ08SgLWzg/s1600-h/cs-workspace.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcUgVrEFxLGa7bDqEZGeLvVI2TQ4QZb54AyAw8ZfDH3v8Xb5TTerRGYsHxOldCbiFAxkD0jX7brGAlXzYSmRHbQEPo_tKQG4dLwOdTV6tDeMKOxOYf6FwAXCwsNYxUpZ08SgLWzg/s400/cs-workspace.png" alt="" id="BLOGGER_PHOTO_ID_5200201235618942962" border="0" /></a><br /><span style="font-weight: bold;font-size:130%;" >Building the project</span><br />Im going to build a Release version of MediaPortal using MSBuild and the mediaportal.sln solution file. Hudson also supports NAnt and many other <a href="http://hudson.gotdns.com/wiki/display/HUDSON/Plugins#Plugins-Buildtools">build tools through plugins</a>.<br /><ol><br /><li>Click the <span style="font-style: italic;">"Add build step"</span> and select <span style="font-style: italic;">"Build a Visual Studio project or solution using MSBuild."</span></li><br /><li>MsBuild Build File=<span style="font-style: italic;">mediaportal.sln</span></li><br /><li>Command Line Arguments=<span style="font-style: italic;">/p:Configuration=Release</span></li></ol><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJfg-oeZ211yfbhkIWPu_ysD3ktBzYdJ7pMP2_QXhXiy-oOoomzFG87TYtp1IAi08z2JJhzj2AyCtmZg6Q2BzGlaldd1-Yw7MM7Un9Y1d_JHm2tc_wtLVug3RxqjX_uFAZsCnreg/s1600-h/cs-build.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJfg-oeZ211yfbhkIWPu_ysD3ktBzYdJ7pMP2_QXhXiy-oOoomzFG87TYtp1IAi08z2JJhzj2AyCtmZg6Q2BzGlaldd1-Yw7MM7Un9Y1d_JHm2tc_wtLVug3RxqjX_uFAZsCnreg/s400/cs-build.png" alt="" id="BLOGGER_PHOTO_ID_5200209383171903714" border="0" /></a><br />To test the configuration, press Save and then Build. Now the source code should be updated if there any changes and then built using MSBuild. While the build is running you can check the Console log that is updated as the build continues.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrIrbuH3L5N75hfnM6I3-aFUtrpWXUcTY3jaR-jKfLo5UPt1JJUdfRnkUhWnvqNTBVSPacLJWrQ5keAvjMhxpixskr-dX_GkyTQnnvE60rLThrgt-r64XQFA6-NR2Vot6yU-_-cQ/s1600-h/CS-console.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrIrbuH3L5N75hfnM6I3-aFUtrpWXUcTY3jaR-jKfLo5UPt1JJUdfRnkUhWnvqNTBVSPacLJWrQ5keAvjMhxpixskr-dX_GkyTQnnvE60rLThrgt-r64XQFA6-NR2Vot6yU-_-cQ/s400/CS-console.png" alt="" id="BLOGGER_PHOTO_ID_5200203554901282866" border="0" /></a><br /><br /><span style="font-weight: bold;font-size:130%;" >Running unit tests and showing the result</span><br />Hudson can read NUnit XML reports and display the results of them for each build. If a test fails, then it will be displayed in the Status page. Hudson will also show how many builds ago a test failed (it's age); that way it is simple to see if a test failed in the current build. If a build has at least one failing unit tests then the build will become Unstable (yellow); otherwise it is marked as Successful (blue). After two builds you will get a trend graph showing the test results over time. To run the NUnit tests, I'm running <span style="font-style: italic;">nunit-console</span> from Hudson after the MSBuild has compiled all files.<br /><ol><br /><li>Click the <span style="font-style: italic;">"Add build step"</span> and select <span style="font-style: italic;">"Execute Windows batch command"</span></li><br /><li>Command=<pre>"c:\program files\nunit\bin\nunit-console.exe" MediaPortal.Tests\bin\RELEASE\MediaPortal.Tests.dll /xml=nunit-result.xml /config=test.config<br />exit 0<br /></pre></li><br /><li>Check the <span style="font-style: italic;">"Publish NUnit test result report"</span> and enter <span style="font-style: italic;">"nunit-result.xml"</span></li></ol><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAUSBt_OEjXxEKGw3fpTtoAOTymxrF3T0K1xd9_QJysxBJta8Tu9ZxUpcyxrkemfDmZFcHX286hI9NwG67uLGuLoGXvxecqej4wDW3mmNJLRx2Y1kBsMEkHpoUmCliOMJtiBt1jg/s1600-h/cs-nunit.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAUSBt_OEjXxEKGw3fpTtoAOTymxrF3T0K1xd9_QJysxBJta8Tu9ZxUpcyxrkemfDmZFcHX286hI9NwG67uLGuLoGXvxecqej4wDW3mmNJLRx2Y1kBsMEkHpoUmCliOMJtiBt1jg/s400/cs-nunit.png" alt="" id="BLOGGER_PHOTO_ID_5200209842733404402" border="0" /></a><br />Start a new build, now the unit tests will be run and their results are collected at the end of the build. When the build is completed, you can see how many tests there were, and how many failed, in the build in the Status page.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqLxYIOLbSwpyT6R9w3DHwsmzg1Rbh02mbDTyd6gn1fGPSIX4qoEQnltGF2TLBsCfhriN4KCbQV7CsRSs8DNLagm0TM-9EVhatm_MAGHZT-RakhqQctbH32eZ4q_Vhc1rCYwyvbg/s1600-h/cs-test.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqLxYIOLbSwpyT6R9w3DHwsmzg1Rbh02mbDTyd6gn1fGPSIX4qoEQnltGF2TLBsCfhriN4KCbQV7CsRSs8DNLagm0TM-9EVhatm_MAGHZT-RakhqQctbH32eZ4q_Vhc1rCYwyvbg/s400/cs-test.png" alt="" id="BLOGGER_PHOTO_ID_5200202339425538050" border="0" /></a><br />More information on namespace detail can be shown in the Test result page.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIotreKFZ74-pi9YbDXuQsGVlRFGfS-StGunXuUcvKweaCM8l84MQCVlQvVC12jVvZqtqbEAGaMRO81BvlJY1Vhvyl1cjLhhReyL-kEIUV2H_LdDJnoM_iwTzLdh9oG02-a63akA/s1600-h/cs-test-detail.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIotreKFZ74-pi9YbDXuQsGVlRFGfS-StGunXuUcvKweaCM8l84MQCVlQvVC12jVvZqtqbEAGaMRO81BvlJY1Vhvyl1cjLhhReyL-kEIUV2H_LdDJnoM_iwTzLdh9oG02-a63akA/s400/cs-test-detail.png" alt="" id="BLOGGER_PHOTO_ID_5200202468274556946" border="0" /></a><br />The test results are then displayed as a trend report. <i>(This trend graph is copied from my python project, as it shows a variation over time)</i><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWjZpoXXjwctDMiGGI7xjPfHYJDzJNNtuHxP7UesMNbtlFruWNUJtl8yECqukx-IHAAIKn9N4Quaq6K4HUlB42lLWc90dr7cOouxX6vKh1CTgVBEyrXfs0D_Kxk_5E-sylezdafQ/s1600-h/cs-test-trend.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWjZpoXXjwctDMiGGI7xjPfHYJDzJNNtuHxP7UesMNbtlFruWNUJtl8yECqukx-IHAAIKn9N4Quaq6K4HUlB42lLWc90dr7cOouxX6vKh1CTgVBEyrXfs0D_Kxk_5E-sylezdafQ/s400/cs-test-trend.png" alt="" id="BLOGGER_PHOTO_ID_5200206634392834194" border="0" /></a><br /><br /><span style="font-weight: bold;font-size:130%;" >Archiving build artifacts</span><br />It is good to archive the outputs (artifacts) from the build, so they can be retrieved later. This way it is possible to get a version of MediaPortal that was built a week ago, and compare the functionality to one built today. Hudson can be configured to store any number of files for each build, it can also be configured so only the latest successful build's artifacts are stored. <i>As I'm not really sure what the output from MediaPortal is, I'm going to show how to archive the files for the MPInstaller.</i><br /><ol><br /><li>Click the <span style="font-style: italic;">"Archive the artifacts"</span>.</li><br /><li>Files to archive = <span style="font-style: italic;">MPInstaller\bin\Release\*</span></li></ol><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2IFdcH99z_KXHCfPwRSSjj4Yjx1oD1ieGtS8FZhjJ6nxvZRCWHoDW_K2RUX4cVBcoemYmRPxR6TthdE1Hq3FDPp5yQHevsFDp2jTLRCobzB1LBzxOzzfZASmuj74m8Z3B1HdTKA/s1600-h/cs-archiving.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2IFdcH99z_KXHCfPwRSSjj4Yjx1oD1ieGtS8FZhjJ6nxvZRCWHoDW_K2RUX4cVBcoemYmRPxR6TthdE1Hq3FDPp5yQHevsFDp2jTLRCobzB1LBzxOzzfZASmuj74m8Z3B1HdTKA/s400/cs-archiving.png" alt="" id="BLOGGER_PHOTO_ID_5200210229280461058" border="0" /></a><br />In the next build, Hudson will store all files in the MPInstaller release folder so it can be retrieved later even if there are newer builds available.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWIU7C_3XX6BlJ1_cMb1Xzb2kmVzFyON_nlDdLX-jhzuThj-wZr_PvPNqJo9cHLrHalh3x2_8wWkmHORi0aGoT7XJL35uguMszYCVn4q2mI3uL1QUa0U9MhzcaftzyJkwxcKVxgg/s1600-h/cs-artifacts.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWIU7C_3XX6BlJ1_cMb1Xzb2kmVzFyON_nlDdLX-jhzuThj-wZr_PvPNqJo9cHLrHalh3x2_8wWkmHORi0aGoT7XJL35uguMszYCVn4q2mI3uL1QUa0U9MhzcaftzyJkwxcKVxgg/s400/cs-artifacts.png" alt="" id="BLOGGER_PHOTO_ID_5200203078159912994" border="0" /></a><br /><br /><span style="font-weight: bold;font-size:130%;" >Analyzing code with FxCop</span><br />Hudson can collect output from several quality metric tools and show them for each build. Similar to the unit tests, they will be displayed in a trend graph. For .NET projects, it is good to use FxCop. FxCop analyzes managed code assemblies and can be very good to use but it may also generate too many warnings at start, in this example I will only use the security rules and analyze the <span style="font-style: italic;">Core.dll</span> assembly.<br /><ol><br /><li>Click the <span style="font-style: italic;">"Add build step"</span> and select <span style="font-style: italic;">"Execute Windows batch command"</span></li><br /><li>Command = <pre><br />"c:\Program Files\Microsoft FxCop 1.35\fxcopcmd.exe" /file:Core\bin\Release\Core.dll /rule:SecurityRules.dll /out:fxcop-result.xml<br />exit 0<br /></pre></li><br /><li>Check the "Violations" check box, and set <span style="font-style: italic;">fxcop=fxcop-result.xml</span></li></ol><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhltmtY-1pdurjlM-paXaum6wvDAyu3iH-b8tI-wO9xZE8KD42_rou70Y8FFDgaErelu8vylrjoC7mque4cvFpzoaIHviwnNOTq2Hl64zs5ygKyB9MsRjLve8cvu4JkNbCx6qKXFw/s1600-h/cs-violation-config.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhltmtY-1pdurjlM-paXaum6wvDAyu3iH-b8tI-wO9xZE8KD42_rou70Y8FFDgaErelu8vylrjoC7mque4cvFpzoaIHviwnNOTq2Hl64zs5ygKyB9MsRjLve8cvu4JkNbCx6qKXFw/s400/cs-violation-config.png" alt="" id="BLOGGER_PHOTO_ID_5200211126928625954" border="0" /></a><br />Next build will take considerate longer time, as FxCop goes through the assembly and analyzes it to find potential problems. When the build finishes, you will see a nice summary on how many violations there are in the current build.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh954BIWKMvuG3UhtMosG6RaTldS0kriLaXXrn4QQWdJ8XqFcTVE4NPaGqMdWHa-N3XXkqjkE3mrrZAvUhFD7Op_m_uIx4mGKJf_aOGo4AODFQcgeLufMgkhksTSwSgKxKLMNwXsA/s1600-h/cs-fxcop.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh954BIWKMvuG3UhtMosG6RaTldS0kriLaXXrn4QQWdJ8XqFcTVE4NPaGqMdWHa-N3XXkqjkE3mrrZAvUhFD7Op_m_uIx4mGKJf_aOGo4AODFQcgeLufMgkhksTSwSgKxKLMNwXsA/s400/cs-fxcop.png" alt="" id="BLOGGER_PHOTO_ID_5200206020212510850" border="0" /></a><br /><span style="font-weight: bold;font-size:130%;" >Finding source code comments</span><br />A nice plugin is the Tasks plugin as it will go through the sources, and find specific comments that should be watched. In this example I'm going to search for TODO or FIXME comments,<br /><ol><br /><li>Click the <span style="font-style: italic;">"Scan workspace for open tasks"</span>.</li><br /><li>Files to scan = <span style="font-style: italic;">**/*.cs</span></li><br /><li>High priority=<span style="font-style: italic;">FIXME</span></li><br /><li>Normal priority=<span style="font-style: italic;">TODO</span></li></ol><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3pwDDCsdtAy2rpu4biT4i6jpkefQm64hzmUXMYHGKZlV2obPKWBBlgOQfdy-Y5gk1KiSEsAokwupWXV80K7TW3FNgRq6W05WVOtFQjBUKdzC1v7703E8WtfSm8NXkvNYiekDl8A/s1600-h/cs-tasks-config.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3pwDDCsdtAy2rpu4biT4i6jpkefQm64hzmUXMYHGKZlV2obPKWBBlgOQfdy-Y5gk1KiSEsAokwupWXV80K7TW3FNgRq6W05WVOtFQjBUKdzC1v7703E8WtfSm8NXkvNYiekDl8A/s400/cs-tasks-config.png" alt="" id="BLOGGER_PHOTO_ID_5200210748971503890" border="0" /></a><br />If the plugin finds any comments in the source they will be displayed in the build page.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicdUU-wN02hfrc57zrjakGybrGdJRBcrXl06xFe_ZuVMCD9gHun1YdI0Tnrvw-nQcvAv9oSIWs1FkRnQFxWpLOa5bHRmX6eFIpMqA_bPVsRj6OPejroa7OmAXvp8GRixQertREkw/s1600-h/cs-tasks.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicdUU-wN02hfrc57zrjakGybrGdJRBcrXl06xFe_ZuVMCD9gHun1YdI0Tnrvw-nQcvAv9oSIWs1FkRnQFxWpLOa5bHRmX6eFIpMqA_bPVsRj6OPejroa7OmAXvp8GRixQertREkw/s400/cs-tasks.png" alt="" id="BLOGGER_PHOTO_ID_5200204448254480450" border="0" /></a><br />There will also be a trend graph so it is possible to monitor that the tasks are decreasing over time. Together with the summary on what comments were found, the full source code can be viewed.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbc793tiHRss3BGpHBeeFwA-CYTgIFBj2zqbmN_MwLRu4WAXdSsPBCYy-Tdny2ldijn28LbYiFP3CyyD4I6yZSKoh-Evc-QqyU8C8ezhaHbfaS0Elfwq9kZrGujmXR9fFEvt0qFA/s1600-h/cs-tasks-detail.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbc793tiHRss3BGpHBeeFwA-CYTgIFBj2zqbmN_MwLRu4WAXdSsPBCYy-Tdny2ldijn28LbYiFP3CyyD4I6yZSKoh-Evc-QqyU8C8ezhaHbfaS0Elfwq9kZrGujmXR9fFEvt0qFA/s400/cs-tasks-detail.png" alt="" id="BLOGGER_PHOTO_ID_5200204856276373586" border="0" /></a><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbN0ee69HOuk_HVqyJ-EDiORy19yVzaa1BAbRT2WPwy6JKCk0nlCqKCDI9SI77ymWMMnlhR8n1hYXPdCgiDu5sZ-f32umfjU7yXT-CCQnT7ijP6pHQo8bcZ0R5BwKFuiWdr-sZLA/s1600-h/cs-tasks-source.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbN0ee69HOuk_HVqyJ-EDiORy19yVzaa1BAbRT2WPwy6JKCk0nlCqKCDI9SI77ymWMMnlhR8n1hYXPdCgiDu5sZ-f32umfjU7yXT-CCQnT7ijP6pHQo8bcZ0R5BwKFuiWdr-sZLA/s400/cs-tasks-source.png" alt="" id="BLOGGER_PHOTO_ID_5200205629370486898" border="0" /></a><br /><br /><br /><span style="font-weight: bold;font-size:130%;" >Summary</span><br />I hope this was a useful guide to start building .NET projects with Hudson, one of the many CI servers. As shown above it does not take much configuration to start building a project using Hudson. The best way to start using continuous integration is to start building the project. Then focus on running unit tests and other quality metrics so you can monitor the quality progress on your project.<br /><br />Currently there are some plugins in the pipeline that could be interesting for .NET developers:<br /><ul><li>A SCM implementation for Microsofts Team System</li><br /><li>Support for CodePlex issues and Wiki words in change set comment. And a very simple configuration to check out code from a CodePlex project</li><br /><li>Support for displaying coverage stats using NCover and MS own coverage tool</li></ul>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-26667525370005868942008-04-08T10:32:00.009+02:002008-04-09T14:42:30.952+02:00Start playing the Continuous Integration game for realI read <a href="http://clintshank.javadevelopersjournal.com/ci_build_game.htm">"The Continuous Integration Build Game"</a> 6 months ago, just when I had found <a href="http://hudson.dev.java.net">Hudson</a>. The idea behind the game seemed so simple and at that time we had problems with people comitting code that broke the build and failed the (very few) unit tests. I thought that the game could help out, as people like competitions and they would try to "win" the game. To win the game the developers have to commit code that is compiling and add unit tests.<br /><br />The rules of the game are:<br />* -10 for breaking a build<br />* +1 for doing a build with no failures<br />* -1 for each new test failures<br />* +1 for each new test that passes<br /><br /><a href="http://hudson.gotdns.com/wiki/display/HUDSON/The+Continuous+Integration+Game+plugin">The plugin</a> is more a proof of concept than a real full fledged plugin that will suit everyone. Thus the points for each rule are hard coded and can not be changed in this release. So if you are finding this plugin useful let me know.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkaRYyXNBIM_rs78SYxRLlZCZqIwqKvFMay3Y43eOSP7CQYGtE3ai2os2so-wPsxKPcanYiFlvoENaLoZIP7UicKaohhkTrE8wO7Ta5nTCTU1wnfkqOYtb7TnBlVzH7uiaAWqNLA/s1600-h/summary.png"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkaRYyXNBIM_rs78SYxRLlZCZqIwqKvFMay3Y43eOSP7CQYGtE3ai2os2so-wPsxKPcanYiFlvoENaLoZIP7UicKaohhkTrE8wO7Ta5nTCTU1wnfkqOYtb7TnBlVzH7uiaAWqNLA/s320/summary.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5186979135367710610" /></a>For each build you will get a summary stating how many points the build was worth, and if you want you can see what rules that were involved.<br /><br />The plugin installs a leader board on the front page, which shows who are on top.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbG1L3kCSY8PgnoUgbTF1_5DSt5vZb9ZYe80TNWao3KYXRdx5p18xprBEZzYQOQeF9zjUdgX3dibxChZPrtkNWhw24KWitt8q4q1KJrWWcy4WHLtgBTiCj8srbR7_ySbf1nh-ZKQ/s1600-h/leaderboard.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbG1L3kCSY8PgnoUgbTF1_5DSt5vZb9ZYe80TNWao3KYXRdx5p18xprBEZzYQOQeF9zjUdgX3dibxChZPrtkNWhw24KWitt8q4q1KJrWWcy4WHLtgBTiCj8srbR7_ySbf1nh-ZKQ/s400/leaderboard.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5186997212885059522" /></a>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-12882475384386771792008-04-07T21:55:00.005+02:002008-04-07T22:19:28.712+02:00Use Mylyn and you will be happy in two monthsI must say that I really like <a href="http://www.eclipse.org/mylyn/">Mylyn</a>. Besides all the <a href="http://www.ibm.com/developerworks/java/library/j-mylyn1/?ca=dgr-eclipse-1">issue tracker integration</a>, the <a href="http://www.ibm.com/developerworks/java/library/j-mylyn2/?ca=dgr-eclipse-1">task context features</a> are great. Today I got a <span style="font-style:italic;">"ahh, this is to good to be true"</span> moment.<br /><br />I was working on my clear case plugin for <a href="http://hudson.dev.java.net">Hudson</a>, and was going to fix a feature request I entered two months ago. So I activated the task, and suddenly two files was opened in the editor. The caret was moved to the method that was going to be involved in fixing the feature. Apparently Eclipse has improved recently and it knew how to fix the feature before I knew. <br /><br />Then it dawned on me that I had started looking into fixing the feature two months ago, and thats why the task context already contained the two files. I just picked up where I left two months ago, and could continue working on the feature request within minutes. That is great functionality that doesn't intrude on the user, it just works! <br /><br />So if you are using Eclipse and haven't tested mylyn, start using it today and you will be happy in two months! (and the time in between!)redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-31510041210645785752007-11-24T13:21:00.001+01:002007-12-03T22:10:04.978+01:00RFC: A mock too far?<span style="font-family:arial;">I love using mocks as it makes it possible to write unit tests for small parts of a bigger system without depending on it. Using mocks is very simple, just create a mock of an interface </span><span style="font-style: italic;font-family:arial;" >(or class, schhhh) </span><span style="font-family:arial;">, set up the expectations on it, and then execute the test. When using mocks it is easy to get 100% coverage without relying on others. But I have come to the conclusion that this can be taken too far, way too far.</span><br /><br /><span style="font-family:arial;">I have tests that do more setting up the mock expectations than actually testing the code. This makes the tests much harder to read, and I'm having problems going back to 6 months old code and understand what a test actually tests. And in my eyes this is a big problem because unit test code should be as simple as possible.</span><br /><br /><span style="font-family:arial;">So what I'm interested in is how should I do mock testing, without drowning in mocking expectations. Does anyone have any ideas on how to do it? Have I gone a mock too far?</span><br /><br /><span style="font-family:arial;">As a simple example I will show my </span><a style="font-family: arial;" href="http://fisheye5.cenqua.com/browse/hudson/hudson/plugins/clearcase/src/test/java/hudson/plugins/clearcase/ClearCaseSCMTest.java?r=MAIN">unit tests</a><span style="font-family:arial;"> of my </span><a style="font-family: arial;" href="http://hudson.gotdns.com/wiki/display/HUDSON/ClearCase+Plugin">Clear case</a><span style="font-family:arial;"> implementation for the </span><a style="font-family: arial;" href="http://hudson.dev.java.net/">Hudson CI</a><span style="font-family:arial;"> server. </span><span style="font-style: italic;font-family:arial;" >(But my production code looks very similar unfortunately)</span><span style="font-family:arial;">.</span><br /><br /><span style="font-family:arial;">I've selected to mock out the clear tool command execution in the test, ie I dont want to issue real commands using the clear case command line tool (and I don't have a Clear case server or client at home). In the below example I want to verify that when the plugin polls the CC server for changes, then it should issue a </span><span style="font-style: italic;font-family:arial;" >"lshistory"</span><span style="font-family:arial;"> method call. But to get it to the point where I can run the tests I have to mock out the Hudson dependencies, ie get the latest build, check the time stamp of it, mock a list of changes that the "</span><span style="font-style: italic;font-family:arial;" >lshistory"</span><span style="font-family:arial;"> should return.</span><br /><blockquote><br /><pre><br />@Test<br />public void testPollChanges() throws Exception {<br /> final ArrayList<object[]> list = new ArrayList<object[]>();<br /> list.add(new String[] { "A" });<br /> final Calendar mockedCalendar = Calendar.getInstance();<br /> mockedCalendar.setTimeInMillis(400000);<br /><br /> context.checking(new Expectations() {<br /> {<br /> one(clearTool).lshistory(with(any(ClearToolLauncher.class)),<br /> with(equal(mockedCalendar.getTime())),<br /> with(equal("viewname")), with(equal("branch")));<br /> will(returnValue(list));<br /> one(clearTool).setVobPaths(with(equal("vob")));<br /> }<br /> });<br /> classContext.checking(new Expectations() {<br /> {<br /> one(build).getTimestamp();<br /> will(returnValue(mockedCalendar));<br /> one(project).getLastBuild();<br /> will(returnValue(build));<br /> }<br /> });<br /><br /> ClearCaseSCM scm = new ClearCaseSCM(clearTool, "branch",<br /> "configspec", "viewname", true, "vob", false, "");<br /> boolean hasChanges = scm.pollChanges(project, launcher,<br /> workspace, taskListener);<br /> assertTrue("The first time should always return true", hasChanges);<br /><br /> classContext.assertIsSatisfied();<br /> context.assertIsSatisfied();<br />}<br /></object[]></object[]></pre></blockquote><span style="font-family: arial;">As you can see the mock expectations take up at least two thirds of the test. Of course I can refactor the tests by adding helper methods that will set up the expections, but many times the expectations are similar but not equal.</span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-91566663697566959732007-11-20T20:50:00.002+01:002008-09-17T14:51:37.415+02:00Hudson embraces Python<span style=";font-family:arial;font-size:100%;" >A few months ago I started using <a href="http://hudson.dev.java.net/">Hudson</a> for my <a href="http://xbmc.ramfelt.se/wiki/TvScreenShots">XBMC TV.com scripts</a> that are written in Python. The Hudson continuous integration server will retrieve the latest sources from subversion, package the sources into a zip file, run a few unit tests, analyze the source using pylint and then display the outcome in a easy navigated web-ui. You can see the result at <a href="http://hudson.ramfelt.se/">http://hudson.ramfelt.se</a> where the latest build is always accessible.<br /><br /><span style="font-weight: bold;">Python unit tests</span><br />Hudson supports JUnit report files, but unfortunately the py-unit framework does not support outputting the unit test results to an XML file. But thanks to </span><span style="font-size:100%;"><a style="font-family: arial;" href="http://www.rittau.org/python/">Sebastian Rittau</a><span style="font-family:arial;">, there is a unit test runner that will write the result into an XML file that can be parsed as a JUnit file. Using the <a href="http://xbmc.ramfelt.se/browser/TV.com/trunk/src/python-test/xmlrunner.py">xmlrunner.py</a> when running my tests I can produce XML files that can be read by Hudson. So now for every commit or forced build the tests are executed and shown in a nice graph.</span><br /><a href="http://ramfelt.se/blog/redsolo/0711/test-result.PNG"><img style="font-family: arial;" WIDTH=350 src="http://ramfelt.se/blog/redsolo/0711/test-result.PNG" /></a><br /><br /><span style="font-family:arial;">The </span><a style="font-family: arial;" href="http://xbmc.ramfelt.se/browser/TV.com/trunk/src/python-test/alltestsuite.py">python code</a><span style="font-family:arial;"> looks like this:</span><br /></span><span style=";font-family:courier new;font-size:100%;" ><span style="font-size:85%;">suite = unittest.TestSuite([<br /> unittest.TestLoader().loadTestsFromTestCase(ShowTestCase),<br /> unittest.TestLoader().loadTestsFromTestCase(VideoTestCase),<br />])<br />if __name__ == '__main__':<br /> runner = xmlrunner.XmlTestRunner(sys.stdout)<br /> runner.run(suite)</span><br /><target name="report-pyunit-xml"><target name="report-pyunit-xml" depends="report-prepare,test-prepare"><exec dir="${build.test}" executable="${python.binary}" output="${report.pyunit.xml}" error="${report.pyunit.xml}.error"><exec dir="${build.test}" executable="${python.binary}" output="${report.pyunit.xml}"><br /><span style="font-family:arial;">In Hudson you must enable JUnit report files by checking the </span></exec></exec></target></target></span><span style=";font-family:arial;font-size:100%;" ><span style="font-style: italic;">"Publish JUnit test result report"</span> and enter the path to the XML reports.</span><span style="font-size:100%;"><br /><img style="font-family: arial;" src="http://ramfelt.se/blog/redsolo/0711/hudson-junit.PNG" /><br /><br /></span><span style="font-weight: bold;font-family:arial;font-size:100%;" >Python code analysis</span><span style="font-size:100%;"><br /><span style="font-family:arial;">Hudson supports the common Java analyzers such as PMD, FindBugs, CPD, checkstyle, etc. It didn't have any support for pylint, but thanks to a </span><a style="font-family: arial;" href="http://hudson.gotdns.com/wiki/display/HUDSON/Violations+Plugin">great plugin</a><span style="font-family:arial;"> it was very easy to </span><a style="font-family: arial;" href="http://fisheye5.cenqua.com/browse/hudson/hudson/plugins/violations/src/main/java/hudson/plugins/violations/types/pylint/PyLintParser.java?r=MAIN">write a parser</a> for pylint reports. Using this plugin, Hudson can now analyze my python files and show a nice <a style="font-family: arial;" href="http://akira:8070/job/XBMC%20TV/violations/">trend graph </a><span style="font-family:arial;">on how many issues there are and for long. It will also produce a </span><a style="font-family: arial;" href="http://akira:8070/job/XBMC%20TV/violations/file/tv.py/">report for each file</a> with code snippets to show where the issue is.<br /><a href="http://ramfelt.se/blog/redsolo/0711/pylint-snippet.PNG"><img style="font-family: arial;" WIDTH=350 src="http://ramfelt.se/blog/redsolo/0711/pylint-snippet.PNG" /></a><br /><br /><br /><a style="font-family: arial;" href="http://xbmc.ramfelt.se/browser/TV.com/trunk/build.xml#L205">Ant target</a><span style="font-family:arial;"> to create the pylint file (important that the pylint output is parseable)</span><br /></span><span style=";font-family:arial;font-size:100%;" ><span style="font-size:85%;"><target name="report-pylint" depends="report-prepare"><br /> <exec dir="${src.python}" executable="${pylint.binary}" output="${report.pylint}"><br /> <env key="PYTHONPATH" path="${build.bin}:${build.bin}/lib/"/><br /> <arg line="-f parseable -i y TVcom.py tvguicontroller.py tvweb.py tv.py settingsmanager.py --output-format=parseable --ignore-comments=y --min-similarity-lines=4 --disable-msg=R0903 --disable-msg=C0301"/><br /> </exec><br /> </target></span><br /><br />Configuring the Violation plugin in Hudson looks like this:<br /><a href="http://ramfelt.se/blog/redsolo/0711/pylint-config.PNG"><img style="font-family: arial;" WIDTH=350 src="http://ramfelt.se/blog/redsolo/0711/pylint-config.PNG" /></a><br /><br /><br /><span style="font-weight: bold;">Verification tests<br /></span>I've also set up Hudson to run the verification tests when ever a build has been completed for the main XBMC TV Script job. This verification job will crawl through the www.tv.com web using the crawling sources to verify that there is no crashes because www.tv.com have changed the html format. This job takes a long time, up too 3-5 hours, and the result will be displayed in a nice trend graph as other unit tests. At the same time I can continue develop the next version and even build a new version while Hudson is running the verification job.<br /><br /><br />I must say that Hudson is a great CI tool, which works with Java, Python and C#. My favorite languages.<br /><span style="font-weight: bold;"></span></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-2539617769978361152007-07-20T22:39:00.001+02:002008-09-17T14:51:37.415+02:00Continuous integration made easy<span style="font-family: arial;">Yesterday I found a great continuous integration server. Its called </span><a style="font-family: arial;" href="http://hudson.gotdns.com/">Hudson</a><span style="font-family: arial;"> and is written in Java and can do loads of stuff with no complex setup. Right out of the box it supports Ant, Maven, Cvs, and Subversion. In 10 minutes I was up and running periodical builds of my XBMC python scripts from my Trac/Subversion </span><a style="font-family: arial;" href="http://xbmc.ramfelt.se/">site</a><span style="font-family: arial;">.</span><br /> <br /> <span style="font-family: arial;">At my previous job at large american hand held manufacturer, they had a really nice build system that was integrated with sharepoint. With it, they could schedule builds through a web page on their separate products. I was pretty amazed by it and it seemed so complex. But now I have a tool that can do the same thing for free.</span><br /> <br /> <span style="font-family: arial;">Hudson has some nice features:</span><br /> <ul style="font-family: arial;"><li>Builds trends - How often does the build break? Does the build time increase for every build?</li><li>Periodical builds Or when someone commits</li><li><a href="https://hudson.dev.java.net/screenshots/5.png">Test trends</a> - Is the number of failed test increasing or decreasing over time? Does the test cover more and more code? (Clover plugin)<br /> </li><li>Emails when a build fails - An email can be sent out when someone checks in code that breaks. Apparently it can even email those responsible for breaking the build (that I havent tested yet)</li><li><a href="http://hudson.gotdns.com/wiki/download/thumbnails/753667/1.png">Multiple jobs</a> that can be shared one or several machines.</li><li>Shell access, you can run any batch file or shell script from the builds; so it is very easy to integrate into your current build situation</li><li><a href="http://hudson.gotdns.com/wiki/display/HUDSON/Plugins">Plugins </a>- To integrate with Trac and other bug reports; Jabber and IRC support, etc.<br /> </li></ul> <span style="font-family: arial;">So far I have used it for a Java, a Python and a .NET project; and all that just in one day!</span><br /> <br /> <span style="font-family: arial;">Take a test drive of it (</span><a style="font-family: arial;" href="https://hudson.dev.java.net/hudson.jnlp">check out the webstart</a><span style="font-family: arial;">) and you will be pleasantry surprised.</span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-31404452475540351782007-01-19T22:33:00.000+01:002007-01-19T22:49:01.558+01:00Continued inconsistencies in .NET<span style="font-family: arial;">Everyone complains that Java has their inconsistencies and then points in .NET direction and says that it is so much greater, and less inconsistencies. Somehow I can understand that java has a few of those as it has evolved since the middle of the 90's to what we have today. But I can not understand how .NET can have those as it has only evolved in the last few years.</span><br /><br /><span style="font-family: arial;">But today, I found one inconsistency that I thought was very strange. This is a very minor inconsistency, but as the two events has been developed at the same time it makes it much worse. These two events must been under development at the same time and it has probably been developed by the same team or perhaps the same people <span style="font-style: italic;">(imaging the horror)</span>.</span><br /><br /><span style="font-family: arial;">On the Form class there are two events, to notify listeners that a Form/Window has received focus/lost focus. There are two events which can be subscribed upon:</span><br /><br /><a style="font-family: arial;" href="http://msdn2.microsoft.com/en-us/library/system.windows.forms.form.activated%28VS.80%29.aspx">Form.Activated</a><br /><a style="font-family: arial;" href="http://msdn2.microsoft.com/en-us/library/system.windows.forms.form.deactivate%28VS.80%29.aspx">Form.Deactivate</a><br /><br /><span style="font-family: arial;">Notice the difference, one is past tense and the other one isn't. C'mon these two events must have been developed at the same time, but somehow they screwed up anyhow. The more I look at the Windows.Forms API, the lesser I think of it. There are so many bad decisions in it, so many rushed things. But of course it is only a small API on top of the windows API, and they can only do so much with it.</span><br /><br /><span style="font-family: arial;">Strange, that Sun managed to a dynamic, layout managed GUI like Swing with the same APIs. It makes you think on who hired the right guys....</span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-19819381860683412132006-12-21T13:46:00.000+01:002006-12-21T14:17:59.354+01:00I need a better "Go to definition" in VS2005 (similar to Eclipse)<span style="font-family: arial;">I wish MS could implement a little smarter/better <span style="font-style: italic; font-family: arial;">"Go to definition" </span><span style="font-family: arial;">feature. Today it almost works as it should. The </span><span style="font-style: italic; font-family: arial;">"Go to definition"</span> feature is used to go to the row where something is defined (a method, a variable, etc). Which is very handy if you are maintaining a project without any code documentation at all. But unfortunately the function will be confused if there are two methods that are named the same, but have different arguments. (</span><a style="font-family: arial;" href="http://en.wikipedia.org/wiki/Method_overloading">It is called method overloading</a><span style="font-family: arial;">) </span><span style="font-family: arial;"><span style="font-family: arial;">Visual Studio 2005 is an <span style="font-style: italic;">"ok"</span> IDE, but it is no way near Eclipse. </span></span><br /><br /><span style="font-family: arial;">With VS2005, it will instead of moving the cursor to the method, it will move focus to a <span style="font-style: italic;">"Find symbol results"</span> view where it displays those methods that have the same name. VS2005 could very easily look into the code and find out the type of method arguments and move focus to the method I wanted to see. But apparently it can not distinguish between an int and an ArrayList.</span><br /><br /><span style="font-family: arial;">Try the below code in Eclipse and VS2005, and try to go the correct method that is used in "anotherMethod". (In Eclipse use "<span style="font-style: italic;">Open declaration"</span>). Eclipse will move you directly to the correct method (<span style="font-style: italic;">method(int,ArrayList)</span>), while VS2005 will just show a simple search result.</span><br /><blockquote style="font-family: courier new;">public void method(int i, int j)<br />{<br />}<br /><br />public void method(int i, ArrayList list)<br />{<br />}<br /><br />public void otherMethod()<br />{<br /> int i = 2;<br /> int j = 2;<br /> method(i, j);<br />}<br /><br />public void anotherMethod()<br />{<br /> int i = 2;<br /> ArrayList list = new ArrayList();<br /> method(i, list);<br />}</blockquote><blockquote><span style="font-size:85%;"><span style="font-family: courier new;"></span></span></blockquote><span style="font-size:85%;"><span style="font-family: courier new;"></span></span><span style="font-family: arial;"><span style="font-weight: bold;">To me it feels like Eclipse is developed by developers for developers</span>. VS2005 is developed by someone for developers. If they had used the IDE on a daily basis they would understand that the current <span style="font-style: italic;">"Go to definition"</span> is not properly implemented. They should be able to do a better implementation than this semi solution.<br />Another good example of that VS2005 is not developed by developers, is the lack of unit testing understanding in VS2005, </span><a style="font-family: arial;" href="http://redsolo.blogspot.com/2006/11/frustration-grows-when-unit-testing.html">which I already blogged about</a><span style="font-family: arial;">.</span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-17285312891749734122006-12-21T11:00:00.000+01:002006-12-21T13:37:40.969+01:00OO Parenting by MS<span style="font-family:arial;">I really love object orientation (<span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_0">OO</span>), because it is so easy to build software using it; and it is so easy to totally screw up using it. Today I was surprised when I was trying to find out some information about the Select method in System.Windows.Forms.Control. The </span><a style="font-family: arial;" href="http://msdn2.microsoft.com/en-us/library/7wt11hea.aspx">documentation for the Select method</a><span style="font-family:arial;"> states what the method does and <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_1">doe<span style="font-family: arial;">sn't</span></span><span style="font-family: arial;"> do, but it also informs what inheriting classes that does not support it. Of course, every parent class should know everything about the inheriting classes; and have documentation on everything</span><br /><br />Excerpt from the documentation:<br /></span><span style="font-style: italic;font-family:courier new;" ></span><span style="font-style: italic;font-family:courier new;" >The Windows Forms controls in the following list are not selectable. Controls derived from controls in the list will also not be selectable.</span><br /><span style="font-style: italic;font-family:courier new;" > * Label</span><br /><span style="font-style: italic;font-family:courier new;" > * Panel</span><br /><span style="font-style: italic;font-family:courier new;" > * <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_2">GroupBox</span></span><br /><span style="font-style: italic;font-family:courier new;" > * <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_3">PictureBox</span></span><br /><span style="font-style: italic;font-family:courier new;" > * <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_4">ProgressBar</span></span><br /><span style="font-style: italic;font-family:courier new;" > * Splitter</span><br /><span style="font-style: italic;font-family:courier new;" > * <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_5">LinkLabel</span> (when there is no link present in the control)</span><br /><br /><span style="font-family:arial;"><span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_6">C'mon</span>, why put the Select method in the Control class if they know that many inheriting classes will not implement it at all. This solution/idea reeks of bad design! If a Control does not support a certain functionality, then that class should not have a method pretending to support the functionality.</span><span style="font-family:arial;"> But this is not <a href="http://redsolo.blogspot.com/2006/08/changing-text-on-splitcontainer-what.html">the first time I found a similar problem</a> with the <span style="font-style: italic;">"design"</span> of Windows Forms, so I will stop whining here....</span><span style="font-family:arial;"></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-13254024050100078062006-11-30T10:55:00.000+01:002006-11-30T15:43:32.039+01:00Frustration grows when unit testing with VS2005<span style="font-family:arial;">I've always liked unit testing as it makes my job as a software developer much easier. But the unit testing features of <span style="font-style: italic;">Visual Studio 2005</span> makes me very frustrated and tired of writing unit tests.</span><br /><br /><span style="font-family:arial;">There are two big key issues when using unit testing in <span style="font-weight: bold;">VS2005</span>.</span><br /><ul style="font-family: arial;"><li>When I have executed a test and it fails; it will show up in a list with a red icon. When I double click on the failing row/test it will show a report stating what went wrong. <span style="font-style: italic;">Tell me something I don't know, and move the focus to the failed assertion.</span><br /></li><li>When I have fixed a bug in the project under test, I would like to re-run the test. In the <span style="font-style: italic;">"Test results"</span> window I can choose<span style="font-style: italic;"> "Rerun original test"</span>. When I click on it, it will re-run the test with the old code; and the test will fail again even if I fixed the bug. <span style="font-style: italic;">What happened, didn't I fix the code??</span><br /></li><li>What the h**l is <span style="font-style: italic;">"Assert.Fail failed."</span>?</li></ul><div style="text-align: center;font-family:arial;"><span style="font-size:130%;">Visual Studio 2005:</span><br /></div><div style="text-align: center;font-family:arial;"><a href="http://ramfelt.se/blog/redsolo/0611/unit_testing_failures_vs.PNG"><img src="http://ramfelt.se/blog/redsolo/0611/unit_testing_failures_vs_thumb.png" /></a><br /></div><br /><div face="arial" style="text-align: center;"><span style="font-size:130%;">Eclipse:</span><br /></div><div style="text-align: center; font-family: arial;"><a href="http://ramfelt.se/blog/redsolo/0611/unit_testing_failures_eclipse.PNG"><img src="http://ramfelt.se/blog/redsolo/0611/unit_testing_failures_eclipse_thumb.PNG" /></a><br /></div><span style="font-weight: bold;font-family:arial;font-size:130%;" ><br />Issue 1</span><br /><span style="font-family:arial;">Since the test report window has already displayed that the test fail, I'm not interested in a report stating that the test failed, I know already that the test failed and (hopefully) the reason for it. What I am interested in is which assertion failed and where it is.<br /><br /></span><span style="font-family:arial;">In VS2005 I have to do the following to get to the assertion:</span><br /><ol style="font-family: arial;"><li>Double click the failure in the "Test results" window.</li><li>Find the row number by reading the text in the stack trace section. Add row number to memory.<br /></li><li>Open the unit testing code file.</li><li>Go to the row found in step 2</li><li>Fix the assertion</li></ol><span style="font-family:arial;">In Eclipse it is so much easier:</span><br /><ol style="font-family: arial;"><li>Click on the failure in the "Junit" window.</li><li>Double click on the "AssertionFailed" in the "Failure trace"<br /></li><li>Fix the assertion</li></ol><span style="font-family:arial;">C'mon; 4 steps and many user interactions involving remembering trivial values to show the failed assertion. It is really frustrating to do it whenever something fails. If something is frustrating and takes time, the developer will stop doing it; thus stop unit testing the software. There is no context menu item to go to the failed assertion, only to go to the begining of the test method. With test cases that can be long, it is not so easy to find the failed assertion.</span><span style="font-family:arial;"> Below is the test report that is shown when the user double clicks on the failure. </span><br /><div style="text-align: center; font-family: arial;"><a href="http://ramfelt.se/blog/redsolo/0611/unit_testing_failures_2.PNG"><img src="http://ramfelt.se/blog/redsolo/0611/unit_testing_failures_2_thumb.png" /></a><br /></div><br /><span style="font-family:arial;"><span style="font-weight: bold;font-size:130%;" ><span>Issue 2</span></span><br />I have one project that contains the production code, and one test project next to it as I don't want to mix production code with test code. I've created a test project, added a reference to the production project, and verified that the test project depended on the main project. The test project can access the production classes, so far everything is fine.<br /><br />But the problem comes when one of the tests fails because of a bug in a production class. When I update the code in the production project, and want to debug the last failed test I click on the <span style="font-style: italic;">"Debug original test"</span>. Sure the debugger starts, but the problem is that VS2005 forgot to build the whole solution including the production project. Instead of rebuilding the production project it will only rerun the test. <span style="font-weight: bold;">The test will of course fail again, and I will be sitting there wondering if my fix didn't do anything. </span>This has happen to many times, and I've wasted numerous minutes before realising that I must manually build the solution.<br /><br />Perhaps I'm not using the features correctly, and MS has another view on old test results. Maybe test results should be saved every time a test is run. But for me test results has a very limited lifetime, as soon as I've fixed an error; I don't care about the results prior to the fix.</span><span style="font-family:arial;"><br /><br />This does not happen in Eclipse, the minute that I've updated the code I can re-run the test by clicking on <span style="font-style: italic;">"Re-run Last Test - Failures first"</span>. No rebuild needed, no time spent wondering why a fix doesn't work.<br /></span><br /><span style="font-family:arial;"><span style="font-size:130%;"><span><span style="font-weight: bold;">Issue 3</span> </span></span></span><span style=";font-family:arial;font-size:85%;" ><span style="font-style: italic;">(Minor)</span> </span><span style="font-family:arial;"><br />I just saw this when writing this blog. How can an <span style="font-style: italic;">Assert.Fail()</span> fail? The failure text states that the Assert.Fail() itself failed, to me that is not correct. The test failed itself, and should perhaps say <span style="font-style: italic;">"Failed due to an Assert.Fail() call". </span>Unfortunately Eclipse is not much better as it states <span style="font-style: italic;">"AssertionFailedError"</span> for a <span style="font-style: italic;">fail()</span> call, but still that is better than VS2005.<br /><br /><span style="font-weight: bold;font-size:130%;" >Opinion</span><br />The VS2005 unit testing features are not user friendly, they don't help the user as good as they could. Sometimes a tool with a bad feature implementation is worse than a tool without the feature. Perhaps MS can improve the usability in VS2005, and make it easier for us developer that wants to utilise unit testing. It seems that the above design misstakes must be developed by people who doesn't practice unit testing.<br /></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-10057781508137103592006-11-23T15:53:00.000+01:002006-11-23T16:42:00.101+01:00Why no Equals() and GetHashCode() in System.Collection?<span style="font-family:arial;">Today I had another brain freeze when I was trying to understand why two array lists would generate two different hash codes even if they contained the same data. But when I started my investigation in <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_0">MSDN</span>, I see that the <span style="font-style: italic;"><span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_1">ArrayList</span> </span>does not override the <span style="font-style: italic;"><span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_2">GetHashCode</span>()</span> nor the<span style="font-style: italic;"> Equals()</span> method. <span style="font-style: italic;"><span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_3">Ehhhhh</span>?</span></span><br /><br /><span style="font-family:arial;">So my question is how can I check if two lists are equal? NO, I <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_4">don't</span> want to go through all items. This should be handled by the framework classes and I <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_5">don't</span> want to do any unnecessary implementation.</span><br /><br /><span style="font-family:arial;">If I look in <span style="font-weight: bold;">Java, </span>the <span style="font-style: italic;"><span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_6">ArrayList</span> </span>implements <span style="font-style: italic;">equals(), <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_7">hashCode</span>()</span> as all good objects should. They have also a good <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_8">explanation</span> on how it is done <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html#hashCode%28%29">here</a>. </span><br /><br /><span style="font-family:arial;">If I look through the other classes in <span style="font-style: italic;">System.Collection</span> I see that no implements <span style="font-style: italic;"><span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_9">GetHashCode</span>()</span> or <span style="font-style: italic;">Equals()</span>. If none of them do, then it must be a design choice. But what design choice would that be? If anyone have any <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_10">explanation</span>, please make a comment to this blog. I really want to know.</span><br /><br /><span style="font-family:arial;">There is an interface in<span style="font-style: italic;"> System.Collections.Generic</span> that is named<span style="font-style: italic;"> <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_11">IEqualityComparer</span></span>, which has two methods, <span style="font-style: italic;">Equals()</span> and <span style="font-style: italic;"><span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_12">GetHashCode</span>()</span>. Why make an interface when every class implements those methods? And why doesn't the default list/collection classes implement this interface?<br /><br />I did a little test application to test this out, because I can not believe it. <a href="http://pastebin.com/831400">Full listing here.</a><br />Pseudo code:<br /><br /><span style="font-size:85%;"><span style="font-family:courier new;"></span><span style="font-family:courier new;">string a = "A";</span><br /><span style="font-family:courier new;"> string b = "B";</span><br /><span style="font-family:courier new;"> <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_16">ArrayList</span> list1 = new <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_17">ArrayList</span>();</span><br /><span style="font-family:courier new;"> list1.Add(a);</span><br /><span style="font-family:courier new;"> list1.Add(b);</span><br /><span style="font-family:courier new;"> <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_18">ArrayList</span> list2 = new <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_19">ArrayList</span>();</span><br /><span style="font-family:courier new;"> list2.Add(a);</span><br /><span style="font-family:courier new;"> list2.Add(b);</span><br /><br /><span style="font-family:courier new;"> Console.<span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_20">WriteLine</span>("list1.equals(list2) ? " + (list1.Equals(list2)));</span><br /><span style="font-family:courier new;"> Console.<span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_21">WriteLine</span>("list1.equals(list1.clone) ? " + (list1.Equals(list1.Clone())));</span><br /><span style="font-family:courier new;"> Console.<span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_22">WriteLine</span>("list1.hash == list2.hash ? " + (list1.<span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_23">GetHashCode</span>() == list2.<span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_24">GetHashCode</span>()));</span><br /><span style="font-family:courier new;"></span><span style="font-family:courier new;"><br /><span style="font-size:100%;"><span style="font-family:arial;">This program would show:</span><br /><span style="font-size:100%;"><span style="font-weight: bold;">list1.Equals(list2) ? False</span><br /><span style="font-weight: bold;">list1.Equals(list1.Clone()) ? False</span><br /><span style="font-weight: bold;">list1.hash == list2.hash ? False</span></span><br /><br /></span></span></span></span><span style="font-family:arial;">If I create two array lists that contains the same items, the <span style="font-style: italic;">Equals()</span> method will return <span style="font-weight: bold;">FALSE</span>. If I clone an array list and checks if they are equal the <span style="font-style: italic;">Equals()</span> method returns <span style="font-weight: bold;">FALSE</span>. How can a CLONE not be an exact copy of the object, or how can two exact copies not be equal to each other?</span><span style="font-family:arial;"><br /></span><br />The best part is that <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_27">Hashtable</span> <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_28">doesn't</span> implement <span style="font-style: italic;"><span onclick="BLOG_clickHandler(this)" class="blsp-spelling-error" id="SPELLING_ERROR_29">GetHashCode</span>()</span> either. And that class require all other objects to implement that method in order to be used, but they refuse to do it themselves. <span style="font-weight: bold; font-style: italic;">"Do what I tell you, not what I do."</span><br /><span style="font-family:arial;"></span><span style="font-family:arial;"><br />Is it because they know people will not implement those <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_25">methods</span> since developers are lazy? But why have they put them into the Object class if they can't be trusted? Or was it a copy-paste <span onclick="BLOG_clickHandler(this)" class="blsp-spelling-corrected" id="SPELLING_ERROR_26">mistake</span> from Java? </span><span style="font-family:arial;">To me this is so wrong.<br /></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-74739948181177494392006-11-20T15:48:00.000+01:002006-11-20T16:42:18.968+01:00Localisation with VS2005 will slow you down<span style="font-family:arial;">In my previous <a href="http://redsolo.blogspot.com/2006/11/localisation-gone-wrong-in-c.html">blog about a localisation that went sour</a>, I mentioned that the time for building a localised application takes longer and longer for every language that is added. I have now quantified my feeling and found out that adding a language adds 15-20 seconds for each language. Now that doesn't sound that bad right? <span style="font-weight: bold;">Wrong</span>, If you develop an application that takes one minute to build and adding languages almost triples that time, then it becomes tedious very quickly.</span><span style="font-family:arial;"><br /><br />This is what I found out<span style="font-style: italic;"> (</span><a style="font-style: italic;" href="http://ramfelt.se/blog/redsolo/0611/Table.PNG">table </a><span style="font-style: italic;">and </span><a style="font-style: italic;" href="http://ramfelt.se/blog/redsolo/0611/Graph.PNG">graph</a><span style="font-style: italic;">)</span>:</span><br /><ul><li><span style="font-family:arial;">Default language took 69 seconds to build</span></li><li><span style="font-family:arial;">With two languages it took 85 seconds to build (16 extra seconds)</span></li><li><span style="font-family:arial;">With four languages it took 118 seconds to build (49 extra seconds)</span></li><li><span style="font-family:arial;">With six languages it took 144 seconds to build (75 extra seconds)</span></li></ul><span style="font-family:arial;">If a normal developer compiles 10 times an hour to test something, he/she will waste 12 minutes, just sitting to wait for VS2005 to build. I meanthat is an outrageous extra time, and I wonder if we can send a invoice to Microsoft for those hours that we just wait for the build complete?</span> <span style="font-family:arial;">And I guess we have to make the work day longer as we get much less done.</span><br /><br /><span style="font-family:arial;">For this project, the solution was to remove all language resource files from the project file. This means that the only language that is supported in mid-development is "default" and nothing else. <span style="font-style: italic;">So fixing those too narrow labels for localised texts has to wait for another day.</span> The tool do add/remove all those languages to/from the project file is developed in house and can not be shared unfortunately. The tool is very simple to create, but in my view unnecessary.</span><br /><br /><span style="font-family:arial;">Here we have a grave problem with the localisation in Visual Studio 2005. If it is done as MS wants, the build time to a project can (and probably will) go up for every language added. What is the outcome of that? Either the developer will stop adding localisations, constrain the development by only showing the default or sit and do nothing while the project builds.</span><span style="font-family:arial;"> This is not a good solution. I would rather have a one-file seperate from the GUI, which reads on the fly when the application is started. That way the language files does not affect the build at all, and it will be a minor load time added for the user which probably will not be noticed.</span><span style="font-family:arial;"><br /><br /><span style="font-style: italic;">Measurement notes:</span></span> <ul><li><span style="font-family:arial;">This is an observation of an application that has been under development for 3-4 years.<br /></span></li><li><span style="font-family:arial;">They have tried to follow MS design guidelines.</span></li><li><span style="font-family:arial;">Clear case is used with dynamic views, which could have an impact on the result as it needs to access 200 new files for every added language.</span></li><li><span style="font-family:arial;">The application is not divided up into more than 2 GUI projects. Perhaps adding more sub projects could make the build quicker?</span></li><li><span style="font-family:arial;">I used a C# application to measure the time it took to execute a bat file containing<span style="font-style: italic;"><span style="font-weight: bold;"> </span></span><span style="font-weight: bold; font-style: italic;">"devenv app.sln /build debug"</span></span></li><li><span style="font-family:arial;">I measured each language addition at least 4 times<span style="font-weight: bold; font-style: italic;"><br /></span></span></li></ul>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-42583309580702848652006-11-13T14:26:00.000+01:002006-11-13T23:30:00.403+01:00Localisation gone bad in C#<span style="font-family:arial;">I'm doing maintenance on a huge C# application that was developed for a swedish customer. A while ago it was decided that the application should be sold outside Sweden, and therefore it had to be localised in english, romanian, chinese, etc. The application consists of roughly 200 controls/panels and forms. It was a huge task to translate everything, and from what I now can see MS Visual Studio 2005 did not help very much (as I'm maintaining it right now).</span><br /><br /><span style="font-family:arial;">Apparently one new thing in VS, is that you can localise each and every control/form in the designer. That is nice when you have a few forms and controls that do not use the same words all the time. The developer creates a form, changes the language property and inserts all the translated texts. It is very easy to change a word in swedish to english, and it is all GUI based. But what happens if you have 200 controls/forms that share many texts? I have not figured out how to do that in VS2005 and GUI elements. </span><br /><br /><span style="font-family:arial;">Developers are lazy (and they should be), so they will use the easiest way out. In this case it meant that nobody cared that the same words were used in many forms. Sometimes, people missed a label here and there. And for me maintaining it, it isn't nice.</span><br /><br /><span style="font-family:arial;">I demand these things out of a localisation framework</span><br /><ul style="font-family:arial;"><li>One file for each language. <span style="font-style: italic;">- VS2005 brings you one file for each language and GUI control. In the project it means 1,000 new XML files to handle. That is not good.</span></li><li>One method call to get the texts for a language. <span style="font-style: italic;">- </span><span style="font-style: italic;">Yes, .NET helps partly with this (I will blog another rant about this later)</span></li><li>Ability to change locale during runtime. <span style="font-style: italic;">- Yes, it is possible in .NET.</span></li></ul><span style="font-family:arial;">I need the following tools:</span><br /><ul style="font-family:arial;"><li>Tool to find duplicates so they can be erased, and defined in one place. (Think OO but with languages) - <span style="font-style: italic;">VS2005 does not help you at all.<br /></span></li><li>Tool to spell check localisation files. Apparently there is no such tool out there. - <span style="font-style: italic;">I have not seen anything in VS2005.</span></li><li>Tool to show missing translations for a language. <span style="font-style: italic;">- Nope, the company had to build their own software to extract missing translations and merging. </span></li></ul><span style="font-family:arial;">So what I got was to "translate" around 200 "missing" translation in an XML file, out of them there were 50 "OK", 5 "Cancel", 10 "Index", 15 "Close", etc. I can sure tell you that it could have been very tedious, but I built a very simple tool that would go through the file, so I didn't have to bother with copying/pasting. But once again, I have to develop tools to do stuff that the IDE should have helped me with. </span><br /><br /><span style="font-style: italic;font-family:arial;" >Side note:</span><br /><span style="font-family:arial;">They discovered a side effect of adding new languages to the project files, for every new language you had to add 200 files, this made the project bigger and bigger. Now it takes eons to compile, and one of the core developers came up with the idea to remove all localisation files from the project files. When that was done, the time to compile was drastically cut which was good. Unfortunately we we're in integration testing and could not test any of the localisation bug fixes (</span><span style="font-weight: bold;font-family:arial;" >D'oh</span><span style="font-family:arial;">).</span><br /><br /><span style="font-family:arial;">So what did they end up with when using Visual Studio and .NET?</span><br /><ul style="font-family: arial;"><li>Duplicated texts all over the resource files.</li><li>200 new files for each language</li><li>Compilation time sky rocketed <span style="font-weight: bold; font-style: italic;">(I will bring stats for this later this week)</span></li><li>Developed their own tools to handle the resource files (RESX) which require maintenance, etc.</li><li>Forms that were not properly translated, which wasn't found out until the system test phase (or even later).</li><li>And lets not forget the need to update the size of every button/label to cater for romanian texts. That is also tedious and really unnecessary work.<br /></li></ul><span style="font-style: italic;">What is the proper way to do localisation in .NET and Visual Studio? What did they do wrong? What is the easier way out?</span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-13535005287931597492006-11-06T17:18:00.000+01:002006-11-07T14:05:38.048+01:00TabControl, ListView and checking list items<span style=";font-family:arial;font-size:100%;" >Today I found an odd feature with the <span style="font-style: italic;">ListView </span>GUI control. The list view must be the king of Windows controls. I mean, what can't it do? It can display lists in 5 different ways, which is increasing as Windows evolves. It can even display a list with check boxes for each item, very similar to the <span style="font-style: italic;">CheckedListBox</span>. But the <span style="font-style: italic;">ListView </span>behaves very differently when it comes to checking and unchecking list items if it is placed in a <span style="font-style: italic;">TabControl</span>.<br /><br />The event <span style="font-style: italic;">ItemCheck </span>should be called when the user or code checks an item in the list. But the oddity I found was that the <span style="font-style: italic;">ItemCheck </span>event method would <span style="font-weight: bold;">NOT</span> be called when code/user checks a list item, but the event is first called when the user clicked on the tab that contained the control.<br /><br />This is what I did <span style="font-size:85%;"><span style="font-style: italic;">(</span></span></span><span style="font-style: italic;font-family:arial;font-size:85%;" ><span style="font-family:courier new;"><span style="font-family:courier new;"><span style="font-family:arial;">Full source code available at <a href="http://pastebin.com/818663">pastebin.com</a>)</span></span></span></span><span style=";font-family:arial;font-size:100%;" >:<br /></span> <ul style="font-family:arial;"><li><span style="font-size:100%;">Created a <span style="font-style: italic;">Form </span>with a <span style="font-style: italic;">ListBox, TabControl </span>and a <span style="font-style: italic;">ListView</span></span></li><li><span style="font-size:100%;">The <span style="font-style: italic;">TabControl </span>contains 3 tab pages, the initial tab with a button, the second tab with a second <span style="font-style: italic;">ListView </span>and the third tab page contained a <span style="font-style: italic;">CheckedListBox.</span></span></li><li><span style="font-size:100%;">Added event listeners for all three lists that would add text into the <span style="font-style: italic;">ListBox </span>to show what happens and when.</span></li><li><span style="font-size:100%;">When pressing the button, it will check the first item in all lists (the two <span style="font-style: italic;">ListViews </span>and the <span style="font-style: italic;">CheckedListBox).</span><br /></span></li></ul> <span style=";font-family:arial;font-size:100%;" >This is what I found:</span><a style="font-family: arial;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger2/747/452/1600/btnClick.png"></a> <ul style="font-family:arial;"><li><span style="font-size:100%;">When the button was clicked, it would call the <span style="font-style: italic;">ItemCheck </span>method on the</span><span style="font-size:100%;"> <span style="font-style: italic;">CheckedListBox </span>and the ListView outside the tab control. It would <span style="font-weight: bold;">NOT</span> call the <span style="font-style: italic;">ItemChe</span></span><span style="font-size:100%;"><span style="font-style: italic;">ck </span>method on the <span style="font-style: italic;">ListView </span>inside tab page 2.</span> <a href="http://ramfelt.se/blog/redsolo/btnClick.png">(Form screen shot)</a></li><li><span style="font-size:100%;">When I clicked on tab page 2, then it would call the <span style="font-style: italic;">ItemCheck </span>method on the <span style="font-style: italic;">ListView </span>inside that tab page. </span><a href="http://ramfelt.se/blog/redsolo/tabClick.PNG">(Form screen shot).</a> Somehow the <span style="font-style: italic;">ListView </span>remembered that I wanted some of the items checked.<br /></li></ul><span style="font-size:100%;">Now we have two differently behaviours depending if a </span><span style="font-style: italic;font-size:100%;" >ListView </span><span style="font-size:100%;">is inside a tab control or not.</span><br /><ol style="font-family:arial;"><li>If a <span style="font-style: italic;">ListView </span>is outside a tab control it will call the <span style="font-style: italic;">ItemCheck </span>method when the property is changed. But if the <span style="font-style: italic;">ListView </span>is inside a tab control (that isn't visible) it will not call the <span style="font-style: italic;">ItemCheck </span>method when the property is changed.<a href="http://ramfelt.se/blog/redsolo/btnClick.png"></a><br /></li><li>A <span style="font-style: italic;">CheckedListBox </span>inside a tab control (not visible) will call the <span style="font-style: italic;">ItemCheck </span>method when the property is changed; and the <span style="font-style: italic;">ListView </span>will not call the <span style="font-style: italic;">ItemCheck </span>method. <a href="http://ramfelt.se/blog/redsolo/tabClick.PNG"></a><br /></li></ol> <span style=";font-family:arial;font-size:100%;" ><span style="font-family:arial;"><span style="font-style: italic;"></span></span><span style="font-size:130%;"><span style="font-weight: bold;">Workaround:</span></span><br />In our case I solved it by setting a boolean to false in the <span style="font-style: italic;">TabControl_SelectedIndexChanged</span>() event, and then setting it to true in the <span style="font-style: italic;">TabControl_Selected</span>() event. This way I can check from the boolean if the <span style="font-style: italic;">ItemCheck</span>() comes from the user or is cached by the <span style="font-style: italic;">ListView</span>. If the boolean is <span style="font-weight: bold;">true, </span>then I know the user checked a list item.<br /><br /><br /><br /></span><span style=";font-family:arial;font-size:100%;" ><span style="font-style: italic;font-family:arial;" >C'mon, which is the correct behaviour?</span><br /><span style="font-family:arial;"><span style="font-style: italic;">Why is there a need for a different behaviour?</span><br /><span style="font-style: italic;">Why do I have to bother?<br /><br /></span></span></span><span style=";font-family:arial;font-size:100%;" ><span style="font-family:arial;">Perhaps I didn't know that it is common GUI-OO design to have one implementation if a control is in a <span style="font-style: italic;">TabControl </span>and one if it isn't.</span></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-1161725002254947422006-10-24T22:57:00.000+02:002006-11-06T11:09:29.626+01:00C# Trolls vs. Java Trolls. (wikipedia wars)<span style="font-family:arial;">A month ago when I added the different release names for <a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a> in wikipedia, I saw that there were quite a few troll edits in the page. <span style="font-style: italic;">(Troll edit = people adding/changing wikipedia pages for no good reason)</span> Then I went over to the <a href="http://en.wikipedia.org/wiki/Csharp">C#</a> page in wikipedia, and just looked over the history </span><span style="font-family:arial;">very quickly </span><span style="font-family:arial;">and it seemed that there were less troll edits on that page. That got me thinking of the <span style="font-weight: bold;">"war"</span> between Java and C#; a war that developers loves to fight <span style="font-style: italic;">"What programming language is the best?" </span></span><span style="font-family:arial;">Uncanny similar to the youth discussion on whos dad could kick the other dad butt.<br /><br />Anyhow, this evening I had 30 mins to spare, so I did a very unscientific investigation to see which faction that had entered the most troll comments into the other factions wikipedia page. So I went through all the latest 200 changes for each page. <span style="font-style: italic;font-size:85%;" >Thanks for Firefox excellent tab support, I could do it quite quickly with Ctrl+Tab and Ctrl+W</span>. What I found was this:</span><br /><br /><span style="font-family:arial;">The <a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a> wikipedia page had been troll edited 12 times. Some examples of the changes:</span><br /><ul style="font-family:arial;"><li><span style="font-style: italic;" class="diffchange">"Java Database </span><span style="font-style: italic;">Connectivity" </span>was changed into <span style="font-style: italic;">"</span><span style="font-style: italic;" class="diffchange">help me groe </span><span style="font-style: italic;">Connectivity"</span></li><li><span style="font-style: italic;">"</span><span class="diffchange"><span style="font-style: italic;">IAN Hitchcox is a BIG qeer"</span> - Whatever that means...</span></li><li><span class="diffchange">Changing the name of James Gosling into <span style="font-style: italic;">"Giant Lava"</span> or <span style="font-style: italic;">"</span></span><span style="font-style: italic;" class="diffchange">Michael Adolf Gow"</span><span class="diffchange">... Giant Java would be more appropiate, but that Adolf guy is unknown to me.</span></li><li><span class="diffchange"><span style="font-style: italic;">"The entire java language centers around a single concept, IF Loops.</span>" - Hmm, I think I have used a switch statement once in java.<br /></span></li><li> <span style="font-style: italic;"> "Influenced by = ....</span><span class="diffchange"><span style="font-style: italic;">C sharp C#"</span> - </span>Well, that is not really true is it?</li><li><span style="font-style: italic;">"Mr. Youngpradit - A acclamed computer science teacher teaching Java to high school students he also heads the extreme sports club and botball"</span> - A computer science teacher that do extreme sports, that is a little far fetched.<br /></li><li>Some made an incorrect note that Java's performance is really bad<br /></li><li>And someone replaced all content on the page with <span style="font-style: italic;">"</span><span style="font-style: italic;" class="diffchange">XXXXXXXXXXXXXXX</span><span style="font-style: italic;">"</span><br /></li></ul><span style="font-family:arial;"><br />The <a href="http://en.wikipedia.org/wiki/Csharp">C#</a> wikipedia page has been troll edited 4 times. Some examples:</span><br /><ul style="font-family:arial;"><li> <span style="font-style: italic;">"A good example of this is the "Chad Rocks" program."</span> - Seems like that Chad managed to write a good program with C#</li><li>Self advertising as '<span style="font-style: italic;">'</span><span style="font-style: italic;" class="diffchange">This article is being presented by Rakesh.S</span><span style="font-style: italic;">, </span><span style="font-style: italic;" class="diffchange">Bangalore</span><span style="font-style: italic;">''</span>, with email adress and all. Thanks, I probably won't contact this troll.</li><li><span style="font-style: italic;">"C# is intended to be a '''simple, modern, general-purpose''', object-oriented programming language </span><span style="font-style: italic;" class="diffchange">that does not work</span><span style="font-style: italic;">."</span> - I don't think that was copied from the MS requirement spec?<br /></li><li><span style="font-style: italic;">"</span><span class="diffchange"><span style="font-style: italic;">The language is very facist and Fleury can't program it for shit!"</span> - Apparently someone was tired of both Fleury and C#.</span></li></ul><span style="font-family:arial;"><br />So what does this mean? I have no clue, but it seems that the C# Trolls won this round as they did manage to get in twice the number of troll edits into the Java page.<br /><br /></span><div style="text-align: center;"><span style="font-family:arial;">Java Trolls - C# Trolls</span><br /><span style="font-family:arial;">0 - 1 </span><br /></div><br /><span style="font-size:78%;"><span style="font-style: italic;font-family:arial;" >Yes, I was bored and no Im not serious, but the investigation was...<br /></span></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-1161363380936389632006-10-20T18:08:00.000+02:002006-11-06T11:09:29.559+01:00Open source is not your enemy<span style="font-family:arial;">The last weeks, I've seen an emerge of Open Source (OS) critical blogs. Those blogs most of the times talk how OS either provides </span><a style="font-family: arial;" href="http://blog.paytonbyrd.com/?p=42">no business opportunity</a><span style="font-family:arial;">, low quality products, steals our jobs, </span><a style="font-family: arial;" href="http://weblogs.asp.net/jezell/archive/2006/10/05/Open-Source_3A00_-It-Costs-Too-Much.aspx">are expensive</a><span style="font-family:arial;">, </span><a style="font-family: arial;" href="http://blogs.technet.com/bethpattonmsblog/archive/2006/09/13/455943.aspx">is for communists only</a> or <a href="http://eclipse-ecosystem.blogspot.com/2006/10/three-things-ive-learned-working-in.html#c116129512416433636">the participators are thiefs</a>.<br /><br /><span style="font-family:arial;">I don't get it. Why is open source so terrifying? Why is it so hard to understand that some people wants to collaborate on mutual project? Isn't it more fun to do stuff together than doing them yourself?<br /><br /></span><span style="font-weight: bold;">Communism?</span><br />Most OS projects are developed together with other people, every one has a say. To me that sounds a lot more like Democracy, and definetly not communism. Has nothing changes since the McCarthy era?<br /><br /><span style="font-weight: bold;">Expensive?</span><br />Sure, OSS don't have a support hot line which you can call, and it takes time to get used to ask your peers for help through mailing lists, or finding the information youself. But then, companies that charge for their commercial product can have bad support as well. How does it feel when you paid for it and don't get any help at all?<br /><br /><span style="font-weight: bold;">Stealing because they are incompetent?</span><br />Well, that was one of the stupidiest comments I've read in a while. Is it a problem if someone else is using your code? Is it a problem that you are no longer the only expert of your code? There is a huge amount of projects that produce tools that I can't imagine how to code. If someone is an expert on something else, why not utilise them; instead of doing it yourself? OSS is the opposite of the "Not invented here" idea.<br /><br /> <span style="font-weight: bold;">No business opportunities?</span><br />I'm sorry, but isn't MySQL, RedHat, JBoss successful companies? Don't they make money?<br /><br /><span style="font-weight: bold;">Steals our jobs?</span><br /><span style="font-family:arial;"> Open Source Software (OSS) is not going to make all developers unemployed. You need to see it from the other side, OSS helps us produce better quality products. We no longer need to implement a LinkedList, a String class or a web server every time a new project is started. Building on top of OSS will get us to the goal quickier. Then if I make an adjustment to an OSS, I give something back to the community. I'm tired of re-inventing the wheel every day. But sure, if I'm a crappy developer, then I should be worried.</span><br /><span style="font-style: italic;font-family:arial;" ></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-1160648776229614942006-10-12T10:13:00.000+02:002006-11-06T11:09:29.491+01:00.NET lacks action; can't keep up with Swing<span style="font-family:arial;">Microsoft has really not understood the concept behind the GUI design pattern Model View Control (<a href="http://en.wikipedia.org/wiki/Model-view-controller">MVC</a>). As I understand .NET can not connect GUI controls to functionality (logic) objects <span style="font-style: italic;">(that would be linking View to Control)</span>. I've asked this question on common .NET sites, usenet groups and it seems that they missed out on this part totally. To me, it shows that the .NET Forms project was really rushed and misses major parts that Swing has had for 8 years.</span><br /><br /><span style="font-family:arial;">What I am talking about, is that Java Swing has <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/Action.html">Action </a>classes that can be linked to GUI controls, which means that the GUI control uses the Action object when it has been activated (clicked for <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JButton.html#JButton%28javax.swing.Action%29">buttons</a>, <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JMenuItem.html#JMenuItem%28javax.swing.Action%29">menu items</a>, <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JComboBox.html#setAction%28javax.swing.Action%29">combo boxes</a>, lists and even tree controls) . This Action class contains only the logic (Control) and nothing else; when activated from a GUI control it will perform it's functionality. The drawback with this approach that every major action needs their own class, which generate many more classes. But the benefit is that you can have several buttons/menu items, that uses ONE class to do a certain functionality. <span style="font-style: italic;">It helps during maintenance, where I am right now.</span> This is nice, when a certain Action is disabled <span style="font-style: italic;">(for instance Save is disabled when the user doesn't have an active document)</span>; because it will notify ALL controls that is connected to the Action object. So the developer does not have to care which dialogs/forms/menu that are visible and must be disabled, etc. It is just one simple <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/Action.html#setEnabled%28boolean%29">method call</a></span>, and that is the beauty of it.<br /><br /><span style="font-family:arial;">Another nice thing with it, is that the Action class contains most of the important properties for a control:</span><br /><span style="font-family:arial;">* A <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/Action.html#NAME">name</a> (for buttons) <span style="font-style: italic;">(can be localised)</span></span><br /><span style="font-family:arial;">* A <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/Action.html#SHORT_DESCRIPTION">short description</a> (read tool tip) </span><span style="font-style: italic;font-family:arial;" >(can be localised)</span><br /><span style="font-family:arial;">* A <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/Action.html#ACCELERATOR_KEY">key accelerator</a>, for short cut keys</span><br /><span style="font-family:arial;">* An <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/Action.html#SMALL_ICON">icon</a> (next to the text in buttons and menu items)</span><br /><span style="font-family:arial;"></span><span style="font-family:arial;">* An <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/Action.html#MNEMONIC_KEY">mnemonic key</a><br /><br /></span><span style="font-family:arial;">So when I need to create a button and menu item, all I do is:</span><br /><span style="font-family:courier new;">anAction = new FileSaveAction();<br />JButton button = new JButton(anAction);</span><br /><span style="font-family:courier new;">mainFramePanel.add(button);</span><br /><span style="font-family:courier new;">JMenuItem menu = new JMenuItem(anAction);</span><br /><span style="font-family:arial;"><span style="font-family:courier new;">mainFrame.getJMenuBar().getMenu(0).add(anAction);<br />anAction.setEnabled(false);<br />//.. user opens a new document<br />anAction.setEnabled(true);<br /></span><br />The above code will create a button in the main frame panel, and a menu item. They will have the same text, the same icon, the same tool tip AND both are disabled at the same time. When the user opens a new document it is just one method call to enable both controls. Magic, isn't it? Or is it just properly designed?<br /><br />At my current project, which is a huge .NET project, they have many menu items and buttons that each of them needs to be enabled/disabled when some functionality is disabled. That generates alot of excess code that isn't needed and is <span style="font-weight: bold;">hell</span> to maintain. Since the application is localised in 5 different languages, the developer needs to code enable/disable functionality for least 2 GUI controls. And this means that each control needs 5 different localisations which needs to be set. Talk about unnecessary and unwanted work.<br /></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.comtag:blogger.com,1999:blog-3703531.post-1160290663277958652006-10-08T08:37:00.000+02:002006-11-06T11:09:29.416+01:00MVP Paul Yao can't code (or is .NET too hard?)<span style="font-family:arial;">For more than a year ago, I visited the head quarter of my previous company's in Everett, Washington, USA to meet up with some colleagues and our new boss. One evening there was a WE.DIG (User group for MS, .NET) meeting and me and my friend wanted to participate. So we signed up on a website for that meeting, went to it and enjoyed the free pizza.</span> This user group is run by Mr Paul Yao, a well known MS book writer and MVP.<br /><br /><span style="font-family:arial;">Apparently the sign up included adding us to the mailing list from hell. For more than a year, I've tried to unsubscribe from the newsletter for WE-DIG. As I live in Sweden, I'm no longer interested in events in Seattle. So every month when I get a newsletter, I click on the <span style="font-style: italic;">"Unsubscribe"</span> link; get a nice <span style="font-style: italic;">"You were unsubscribed from the list"</span>, and every next month I get a new newsletter. This grows old on me quite quickly. I've multipled times unsubscribed from it, emailed Paul Yao and the board for WE-DIG to be removed from the list. But no such luck.</span><br /><br /><span style="font-family:arial;">So my conclusion to this is, either Paul Yao is an evil person that never implemented an unsubscibe functionality; or he can not code diddly squat. I mean how hard is it to implement a mailing list functionality, there must be tons of reference implementations out there? Or is it just to hard to implement a mailing list in .NET?</span> Is it .NET that throws an unhandled exception when someone tries to unsubscribe?<br /><br /><span style="font-size:85%;">For you how don't know who Paul Yao is, he has been writing books about MS tech for more than 20 years, so he should know what he is doing. <span style="font-style: italic;">Or perhaps he doesnt..... And this is my last attempt to be removed from the mailing list.<br /></span></span>redsolohttp://www.blogger.com/profile/16392618477260411222noreply@blogger.com