SteelePrice.Net

Thinking outside the Box - Thought provoking insights on the Bleeding Edge

VB Requires Certain Keywords to be surrounded with Square Brackets

clock January 9, 2010 06:56 by author Steele

I was working on a conversion of a Visitor Pattern and this was not giving me much information to go on to resolve the problem:

See:  http://msdn.microsoft.com/en-us/library/bb534318.aspx

.NET Framework Class Library

Expression.New Method(ConstructorInfo, IEnumerable(Expression), MemberInfo[])

Creates a NewExpression that represents calling the specified constructor with the specified arguments. The members that access the constructor initialized fields are specified as an array.

The usage sample for VB:

returnValue = Expression.New(constructor, arguments, members)

 

This will not Compile, you will get the following error:
    Constructor call is valid only as the first statement in an instance constructor.

This is an erroneous error since that is not actually what we are trying to do.  We are trying to call a method that just happens to be the same name as a Constructor in VB.

To work around this, surround the New keyword with brackets:

returnValue = Expression.[New](constructor, arguments, members)

 

You will not be prompted to do this, nor will intellisense change it for you, it can be rather frustrating when you are not sure what the problem is. 
You will find this also happens when trying to use System.Enum at various times, this one however is not consistent it depends on what namespaces you have Imported.
This same problem occurs in different variations for other Methods or Properties with names that are special keywords, surrounding them with brackets is the solution.



COOL Stuff - MonoTouch from Novell

clock September 14, 2009 15:48 by author Steele

Guess what I’m going to be diving into in the coming months :-)

What is MonoTouch?

MonoTouch is the Mono edition for Apple's iPhone and Apple's iPod Touch devices.  MonoTouch allows developers to create C# and .NET based applications that run on the iPhone and can take advantage of the iPhone APIs as well as reusing both code and libraries that have been built for .NET as well as existing skills.

MonoTouch from Novell



Of Mice and Men

clock August 26, 2009 18:24 by author Steele

I think it's critical for us all to start rethinking how we build interfaces.

One thing about Ford/Microsoft Sync is that it is entirely designed to expect the user to be doing something other than thinking about how to make it do what you want (like driving)

With the coming onslaught of Win7, mobile devices, better voice and pen recognition as well as multitouch we need to stop thinking about mice and keyboards as the sole primary inputs.

Personally I am delighted we are finally able to use these reliably. Microsoft’s voice development team used to be known as the “wreck a nice beach” group… Today, the Speech SDK is very usable.  My primary input for Twitter is transferring to voice from my iPhone.  I never really thought the iPhone was a critical device until I actually bought one… I use it 100x more than my iPod Touch.  Gee, there’s no mouse on that thing, the interface suddenly needs to be different.  Right-Click? what’s that?

We have a lot to learn about input and information overload.  The web is really starting to suck badly for many people such as my mother.

She was trying to upload some pictures to share with the family and couldn't figure out how to coordinate between Explorer, Picasa, EasyShare and Gallery that all the different people were using, nor should she have to.  All this stuff is FAR too overwhelming for the non-Geek. Try explaining why an Album in Picasa isn't the same as a Folder in Explorer and one program puts things in Public Pictures and another in My Pictures.  Which click, right or left… single, double or triple click… this is madness.

We might also suggest Search but all the pictures are intelligently named things like img10472.jpg, etc. So what does she search for?  Teaching her to rename everything when importing is not so fun either.  Can she get Geo-Location on the camera? Maybe, but also limited use in searching. I have thousands of picture and have no idea who is in most of them.  Why can’t my Photo Browser recognize when I say “That’s Jake and Kelly on a Horseback Ride in Cave Creek”? Then promptly update the Metadata of photo its displaying?  It already has the date, so now a search might be worth something.

So what do we as designers and developers do? Alienate all non technically degreed users?  I have a friend from high-school that subscribes to my Facebook page, which echoes my Twitter feed. I laugh out loud nearly every time he replies that he has no idea what the heck I am saying… ever, which is frequent.  Computers are supposed to be tools, not instruments of torture or mass destruction.

I think it is up to us geeks to make these things more intelligent so not only is it easier for the user to shuffle stuff around from 3 or 4 cameras, notebooks, phones, music players, game devices, cars, TVs, etc. but at the same time make it so a developer of this stuff doesn’t lose their mind trying to accommodate the ever increasing demands of users who have no idea how to use any of this software nor any time to learn the intricacies of the interfaces.

One thing is for sure. The days of the dedicated PC are over. Sharing is important. No one cares how organized my files are or what they are named but I still need to find things. We need to be able to move important items from one place to another without hassle, often someplace other people have access to them who don’t care about your organizational skills.

I don't always type emails from a desktop computer any more. Sometimes it is my phone, sometimes it's my notebook. Can I easily sync my email?  Not really, Contacts... Harder... Calendar, next to impossible. In a semi-connected, mobile world mixed with different OSes, Consumer Electronics and PCs we have a lot to think about before we sit down and start hacking a program together for even the simplest tasks these days.

This was originally a post written on my iPhone in reply to thoughts about developing for things like Microsoft Sync in a language not supported because apparently Microsoft and Ford don’t think anyone is capable of writing apps for it.  I thought the idea deserved to be expanded just a little and blogged for more visibility because it is a driving force in what my company, Digital Dreamshop does.  We try to make interfaces for everyone, not just people who are used to using computers or can tweak settings here and there to make the software “work for them”.

More and more we are finding that people using our software know less and less about how a computer works and strive to accommodate that.  They are using our software to accomplish a task, if it’s overwhelming, “your software sucks”.  If you get in the users way, they hate your app.  I recommend reading http://www.whysoftwaresucks.com/ as well as David Platt’s book if you are not a developer.  Another good read is http://www.sensible.com/ even though the site truly sucks in appearance :-)  I recommend these for the general ideas they represent, not necessarily their solutions.

We will never live in a one philosophy world, especially when it comes to software, OSes and Interfaces, get over it and figure out how to make it easier to get things in and out of your application and how to treat the User as the one controlling the reason you have a job.

If your boss is telling you that their way is the only way and the users don’t know, quit and get a job with someone who gives a damn about User Experience. Old mentalities of forcing methodologies on users and putting them in a box is going to die fast. 

Our Applications need to talk to the outside world, both in terms of the Interface and the Data.  One thing is for sure, the number of devices, programs, and the data they contain will only grow with time.  How will your Applications interact in that world?  Do you even have a plan?



Jeff Wilcox on Custom Control Development: Simple code guidelines

clock August 26, 2009 15:28 by author Steele

Jeff makes several Great points here about Regions,  Comments, Threading, Refactoring and Naming conventions.

We don’t always practice them all here, but strive to do better.  Most of our Code Generation templates do output code that is very descriptive and readable even if we don’t expect people to read the code, the Philosophy is along the lines of “but what if we need to during debugging or something…”  Having clear and concise coding guidelines makes that task much easier.  Describing what something is supposed to accomplish in the comments has been an essential practice for a long time, code no longer describes itself when you are not writing monolithic apps, even then it was a sure challenge just to find things.

Great custom control development is a skill that takes more than time and experience to perfect. It’s also not a widely documented practice. When it comes to Silverlight controls, there are similarities and differences from WPF custom control development, too – so that chapter on controls in your favorite WPF book often is not directly applicable.

I do admit that there’s a lot of flexibility in control development, so I’ll be basing a lot of my tips on both official and unofficial practices on the Silverlight Toolkit team. And I understand if you don’t agree with everything I have to say. But I do hope this information will be useful!

Jeff Wilcox – Custom Control Development: Simple code guidelines



Glenn Block on MVVM

clock August 14, 2009 16:21 by author Steele
My Technobabble

Lately there is a lot of momentum and interesting conversation around Model-View-View-Model. There’s several good resources out there that discuss the basics of the pattern, who the actors are that are involved and what role the play. I’ll let those speak for themselves, including John Gossman’s great post here, Martin Fowler’s post on the more general PresentationModel pattern and more recently Josh Smith’s MSDN article, Rob Eisenberg’s new series, and Ward Bell’s posts which touch on some of the deeper complexities involved.

In many of these discussions (not including the posts I referred to) it seems like one aspect of ViewModel get’s lost, which is “Why use it in the first place?” This leads to a lot of debate around details of implementation including one item in particular which is whether or not code in the code-behind is an anti-pattern. Building off of the stage Phil set in his great LOD post, I’ll say ViewModel is not a code-counting exercise.

These are all GREAT points. 

Something else Glenn covers is Commands:

The last thing I want to touch on relates to invoking commands, and usage of command parameters through element binding, vs using bound properties on the ViewModel. The user selects an item in the Order list, and double clicks. Do we a) Use element binding and have clicking on the “Open Order” button invoke the OpenOrder command passing in the currently selected order as a parameter, or b) Set the orders list selected item to bind to a SelectedOrder ViewModel property and then have a parameterless OpenOrder command which uses the SelectedOrder order property on the VM itself.

I agree with his assessment that this stuff should use method B.

My reasoning is sort of the same.  Element Binding is nice, but it does make the Designer responsible for something that should be in a Unit Test and this I feel is a no-no.

Element binding is useful for scaling with a slider, but NOT for changing display based on Persisted Data; that relationship belongs in the ViewModel.

Views can have code as long as they exclusively touch Display Only elements, an example would be Style Changes, if you need to invoke some code to load a resource, then that should be in the ViewModel, but to invoke a change based on binding, like a trigger, that may be perfectly fine in the View.

While we are still in the beginnings of applying these patterns to Silverlight, I should point out that if we are forced to overcome a “bug” in rendering, keep that in the View, because the ViewModel just gets muddied up if you don’t; especially if you intend to share your ViewModel with WPF.  Most likely the same “bug” would not exist in both UIs.  Then when a refresh is done and the “bug” goes away in Silverlight, you only have to deal with a change in the Silverlight View.

Maintainability is the key here and the reason these patterns exist.  Keep your code where it belongs for maintainability and you a following the pattern correctly.



Phoenix Silverlight User Group Meeting- August 2009

clock August 9, 2009 05:37 by author Steele

The August 2009 meeting of the Phoenix Silverlight User Group featured a fabulous demonstration of Prism with Silverlight.

Adam J Wolf presented a great sample of a project he created.

The Silverlight Prism Prezi was also very impressive and Comprehensive (click the link to view it.)

Adam dove into lots of code and walked us through how Prism makes a compelling case for Flexible, Loosely-coupled Silverlight development.

He showed us how a Modular Design can speed development and offer great flexibility for the future of your App.

One particular part of the Architecture I really liked was how he made a Secure Shell, then loaded all the components from independent XAPs.

This allowed his App to start fast and dynamically get the components it needed on first run, then cache those for future use.

Hats off to Adam for delivering a tremendously useful presentation.

Tim Heuer stayed afterward and showed us the new HP TouchSmart tx2z multitouch enabled Tablet.

This got many people thinking about how Touch can be really useful and change the way some UI elements are engineered.

Thank you again to Adam and Tim for making this another great meeting.



Excellent guide for building your BootFromVHD Images

clock August 6, 2009 16:29 by author Steele

With the introduction of Windows 7 we have a new method we can use for booting. There is also a backport for Vista if you are so inclined to still run that as your main OS

The Windows(R) Image to Virtual Hard Disk (WIM2VHD) command-line tool allows you to create sysprepped VHD images from any Windows 7 installation source. VHDs created by WIM2VHD will boot directly to the Out Of Box Experience, ready for your first-use customizations. You can also automate the OOBE by supplying your own unattend.xml file, making the possibilities limitless.
Fresh squeezed, organically grown, free-range VHDs – just like Mom used to make – that work with Virtual PC, Virtual Server, Microsoft Hyper-V, and Windows 7’s new Native VHD-Boot functionality!

Win7, 2008 R2, Boot from VHD and more! - Christopher Kusek, Technology Evangelist

I am using this same technique for my main desktop and Laptop.  By creating the VHD images I just copied it to the new machine ran my BCDEDIT script and booted.

No re-install from DVD, find an ISO Loader, etc.

Welcome to the new Virtual World.

In addition, I now employ Differencing Disks on my MAIN OS.  You know what this means?

I can install Betas to my heart’s content and run them at pretty much full speed with no worry of trashing my OS. I am getting about a 3% performance hit from the VHD on an SSD and I have FULL Hardware support.

I have never liked the 10% or more performance hit I was getting from Virtual Machines as well as the pain of double Natting and hardware limitations they have.

BootFromVHD is really awesome for a development machine or for someone who tends to try out a lot of software.  If something goes horribly wrong, simply drop the Differencing Disk.

You do have to take merging down the differencing disk into consideration, as well as creating a new one before installing big Betas but they are stackable.  I have 4 or 5 differencing disks sometimes. for example, I have VS2010 and VS2008 in separate spaces and a third that has them side by side. Then I have a differencing disk for trying out new programs.  My Main OS Install is not touched unless I merge the differencing disk down.

There are some drawbacks, you can’t BootFromVHD with anything but Windows, and only with Vista, Server 2008 and Win7, but that is fine for me, I don’t need to boot to Linux or XP on my dev boxes.  You also can’t do some things like Windows Experience Index, but I don’t need to do that most of the time and I have other machines for that sort of thing.

I would suspect that at some point this will become a pretty common scenario once Windows developers figure out just how nice it is to develop in this environment.

One thing that always bugged me was installing device drivers in a VM, it’s much easier with BootFromVHD and if the driver BSODs, bye-bye differencing disk, no restore/rollback necessary.

Here is a guide for doing it with ONLY the Win7 Install CD if you don't need/want a sysprepped image

http://blogs.msdn.com/cesardelatorre/archive/2009/01/11/windows-7-natively-booting-from-a-vhd-virtual-pc-image-file.aspx



Silverlight3 RTW, Blend3, SketchFlow, DeepZoom Available for Download

clock July 10, 2009 03:22 by author Steele

This is awesome and exciting!

Some of the places to look might be hard to find until later today, the sites are all being updated.

Christian Schormann (Blend PM) has kindly provided a set of working links to everything available now.

Silverlight3 RTW, Blend3, SketchFlow, DeepZoom Available for Download

He also has terrific posts and demos about the Concepts and Overviews

Watch Visual Kitchen here: http://vepexp.microsoft.com/seethelight

And go visit See the Light for a nice vision of what the new versions of Silverlight and Blend can do to help your development shine.



dotNetDave - dotNetTips.Utility 3.5 Released

clock July 3, 2009 09:41 by author Steele

Dave McCarter has released a great package of Tips and Helpers.

After lots new coding, refactoring and upgrading to .NET 3.5, dotNetTips.Utility 3.5 is finally released! This assembly is much of the common code I have been writing for the past 8+ years all wrapped up in a nice package and easy to use.

read more: dotNetTips.Utility 3.5 Released

What’s great about this is that you will get some serious tools and the VB.Net source to see how they work.  Dave is a proponent of Standards and you can see in this library how he implements some of the techniques he talks about.

From AvailablePhysicalMemory to UsStateCollection the helpers get you from nowhere to somewhere fast.

Highly Recommended!

Codeplex Project: http://dotnettips.codeplex.com/



Tweeps List: Visual Basic Influencers

clock July 1, 2009 02:00 by author Steele

Antonio has put together a great list of VB Influencers to follow on Twitter

Antonio Chagoury - Tweeps List: Microsoft Visual Basic MVP’s

While his title says MVPs, there are some other influencers listed



News

Had some aggravation getting my old posts converted to BlogML and then more from the BlogEngine.Net Importer, thank goodness it was open source so I could find the trouble spots and make some changes to get it to import correctly.  Getting it OUT of the old system was not so bad thanks to XML Literals. The good news... Archive Posts are now restored and I can start blogging again Cool

Posts by Date

<<  February 2010  >>
MoTuWeThFrSaSu
25262728293031
1234567
891011121314
15161718192021
22232425262728
1234567

View posts in large calendar

Disclaimer

Copyright ©2003-2009
H. Steele Price, IV

All opinions are my own, not necessarily those of my employer, your mother, or any government agency.

Sign in