Tuesday, August 18, 2015

VB.Net Interface Implements Again

I thought maybe it was just me, but lots of sites out there with incorrect examples of the Implements Interface in VB.Net. And yet in the Microsoft documentation it goes all the way back to VS2003, so if it was correct at any stage, it was a very long time ago.

https://msdn.microsoft.com/en-us/library/f6x8ydw5%28v=vs.71%29.aspx

perhaps the authors are thinking back to VB6 and ignoring this article:
https://msdn.microsoft.com/en-us/library/4ab292ze%28v=vs.80%29.aspx

Monday, August 17, 2015

.Net Winform config gotcha

Been bitten by this a few times, and now been asked if I remembered it, so putting it up here

You might follow the excellent advice at
http://instinctcoder.com/how-to-read-app-config-file-in-vb-net/

and end up with something like this:


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b99a9c59999e099">
<section name="ReportClient.My.MySettings" type="System.Configuration.ClientSettingsSection,System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b99a9c59999e099" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<applicationSettings>
<ReportClient.My.MySettings>
<setting name="SqlServerName" serializeAs="String">
<value>test123</value>
</setting>
<setting name="MainDbName" serializeAs="String">
<value />
</setting>
<setting name="ReportDbName" serializeAs="String">
<value />
</setting>
</ReportClient.My.MySettings>
</applicationSettings>
</configuration>

           
    The trouble is that that the config files are so complicated, it is easy to lose track.

The best thing in this case is to add the following right after the end of  </configSections>
  <appSettings>
    <add key="SqlServerName" value="test123" />   
    <add key="MainDbName" value="" />     
    <add key=="ReportDbName"  value="" /> 
  </appSettings>


and when you are happy, remove the  <applicationSettings> section entirely

C# to VB.Net Gotcha 1: Interfaces

This doesn't happen if you write your interfaces and classes from scratch, but if you are translating from C#
either manually or using an online tool, you might end up with

 A_Service must implement Function XMLData () As IAService.XmlData(id as String)


Public Class A_Service : Implements IAService

Public Function XMLData (id as String) as String
'implementation here
End Function
'....
End Class

and you are thinking "I did, dammit"

Actually you need to explicitly add teh Implements keyword to each function as well. Unlike the C# versions where the implementation is implied by the fact that the class declaration says Implements. I think was how VB6 interfaces worked?

What you need is:

Public Function XMLData (id as String) as String Implments IAService.XMLData

There was a great posting on Stackoverflow for this:
http://stackoverflow.com/questions/666399/cant-see-must-implement-error

Monday, February 9, 2015

Visual Basic 6 upgrades Francesco Balena on DotNetRocks

The topic seems to be in the air again lately. It hasn't really gone away because the problem of what to to with Windows XP hasn't gone away. ... Covered in  dotnetrocks last Summer -- in a rambling manner, I summarise below the link

http://www.dotnetrocks.com/default.aspx?showNum=977


Approximate times of topics on VLC media player - an application which seems to have gone slightly backwards over the years as regards features/UI but that is a different post;

minutes: seconds
06:20   introducing Francesco Balena
06:50  Off Topic: Francesco Balena gets to speak
08:20   Windows XP end of life
09:00   Spike in migrations to .Net
10:50   Government and government specifed projects need to upgraded to supported operating systems
12:10   N-tier
12:25   1000 - 1500 DLL applications
13:00   5 to 7 Mloc
13:45   Migration has no immediate benefit
13:50   Advisable to split migration into phases
15:50   Refactoring etc will be benefits after
16:20   Staged migrations
16:40   Upgrading "inner most components" yields best benefits but most also potentially has most stability problems
19:00  Threading issues [dealt with using attributes]
19:40  Write from scratch best option but -- maybe 30 percent
21:50   VB4   12 years later   original devs gone from companies, knowledge lost
24:10  Francesco Balena (and his company VB Migration Partner)'s tools, libraries etc  very little code transformation, VB6 programmers can typically continue using the code without having to learn a lot of .Net immediately
30:50 Devexpress advert
33:20  Off Topic : Musical instruments
36:25  Do VB6 dev environments still exist
37:10  Problems with licences for old 3rd party Activex contols, old database tech etc
40:40  Partitioning app layers
42:15  Danish financial org Bank ATM Gui software in vb6 ?! Example of GUIs take a long time to replicate
43:30  ADO or not
45:00  WPF migration less successful due to changes - better from scratch
ASP.net etc also better from scratch
49:00  Before upgrading -- Design -- what is end goal?
51:10  Old architectures problems -- lack of  separation of concerns, efficient at the time use of specific VB6 features, will now be a possible problem
53:00 Use of undocumented features
54:00  Dates and strings

Friday, January 16, 2015

Learning Apple's Swift Language

EDIT 18 Feb 2015: this seems to be one of my most popular posts, and I'm guessing it is people looking for help instead of me rabbiting on. In which case, I highly recommend the Swift tutorials on Ray Wenderlich's website. I am getting a lot out of them
http://www.raywenderlich.com/

I've been learning or trying to learn Apple Swift on and off since November, using numerous tutorials. The language itself seems quite nice and fairly intuitive, but XCode 6 is a moving target, and has been updated to version 6.1 since I started my journey (I gave up on Objective C about a year ago, I couldnt get into XCode 5 at all). I was noticing stability issues in the IDE (crashing due to syntax errors -- what's up with that?) but these seem to have been resolved by the new release. Still, as Apple are always touted as a quality company, and I have happy memories of learning Turbo Pascal for Macintosh back in the Stone Age, I am underwhelmed. I have also been dabbling with Eclipse and Scala, and in comparison although I havent pushed either Eclipse or Scala as hard, I'm finding it a more pleasant and familiar experience as a long time Visual Studio user