Posts

Showing posts from 2012

The lambdas, the anonymous and the events

Combining lambdas, anonymous methods and events feels natural in C#, and we use them almost as a reflex, they help us to create closures and avoid creating state variables outside the scope of our methods or passing extra state data through event calls. But one thing that come with events is the fact that writing good applications implies making good use of the resources, meaning we have to dispose those we no longer need. When using events with lambdas and anonymous methods, is possible to forget about that, thus writing code that is not efficient and prone to crashes. Will start this 2-part series talking about the subscribe/unsubscribe behavior. Subscribe/Unsubscribe lambdas and anonymous methods Let's begin with a basic scenario using events in a single-thread context for now; just to keep it simple. The code fragment below contains the HelloEventArgs implementation as well as the publisher class MyClassWithEvents . public class HelloEventArgs:EventArgs { ...

Windows Phone vs iOS Development (with C#): Round One

Image
DISCLAIMER: This is not about iPhone vs WP7 devices; its about development tools. If you think you can enter into a device fight here, or you like to listen to Justin Bieber, you should leave the page now. I like programming, and that's it. Well...no. I LOVE programming. No matter the platform, OS, framework or  language; I find that programming is a rewarding experience. Of course as with anything in life, you want that experience to be as smooth as possible. And that's why I am so picky with development tools... They are supposed to make my work easier. And this entry is about that, comparing the development tools used to create apps for iOS (iPhone) and Windows Phone. Recently I had the opportunity to develop the same mobile app for two platforms: Windows Phone and iOS. While I have developed for these platforms before, I rarely have coded the same app (and a complex one) for the two of them. And this is a good chance to perform a comparison, beca...

New app and updates

Image
Crazy cars, the new game Recently added a new game to my list of apps for Microsoft Windows Phone, a game, and is called "Crazy cars" can be downloaded  here . The game have been download thousands of times and very short time! Check out the new UI created in Silverlight. Hidden Pics The app for hiding photos on you phone also get a new UI, more styled design and several bug fixes. Check out the new look. New updates are coming for this app, including encrypted photo sharing, fake passwords, bogus tiles and more.

The Loan Calculator App

Image
Few days ago I added a new App to my inventory on Windows Phone Marketplace. The Loan Calculator app was just something I needed when I was in a hunt for a car (still am). The thing is I wanted to keep it simple. Just input the numbers and see the total, how much, for how long, you know.. just the FINAL number. Which is what car dealers will never give upfront, because they always play that 101 psychology thing on you. So I built this app using the common formula that you can see around in many websites. The idea is pretty simple, just input the data and get the total final price and the monthly installments. As an extra you can also see how the amortization for the loan plays along time. Check it out, assume we want to calculate the final price for a car that cost 25k, we will put a  10% down payment, 2.5k, with an APR of 3.0%, and with a loan term of 3 years. Just enter the data and hit "Calculate" Then we just get the summary result with the final cost, se...

When somebody changes my code...

Well, initially I might get upset, but only if they break something. But here I am not talking a team member changing your code... No... that's OK This blog entry is about that 'non-deterministic' behavior that sometimes happens to 'us' while developing software and all of the sudden something does not work as it 'should' be. Who does not hate that kind of bugs right? This example is a real case scenario using Telerik components in a web application. Consider the following piece of ASPX code, I have placed a button and a label, the button 's click event in code-behind event will change the value of the label. Pretty simple right? Just a button with a javascript confirmation dialog before performing the page's post back. Now lets 'ajaxify' this... Using the new ajaxified code now have pretty much same effect, except we are not performing a full page post back, but only updating elements inside the UpdatePanel control. But what if I...

Two notes on Mixed security warnings

Image
When deploying and testing websites that use secure connections (SSL)  we might get warnings about non secure content on the page. This is usually an easy thing to fix. Just find a tool like "Fiddler" and find out what traffic is going over a regular HTTP (non secure) channel. Sometimes even a simple FIND over the code will let you find those "unsecured" elements. But that's not enough if you refer some javascript or refer a link over SSL that then does some non-SSL redirection.  Each browser has a similar way to show you how secure you are on a website. Google Chrome shows website security indicators (icons) that will appear next to your site URL in the toolbar. The first one (1) is just a regular site with no SSL, and we want number (2) the green one, you should avoid the other ones. Now two notes on that. Google Ads Don't use Google Adsense on your website if you use SSL and you care about your site not showing any warning, the ads will b...

Using WPConnect instead of Zune for Windows Phone development

Image
Sometimes you get so used to do something everyday that you don't appreciate how much time it saves you. So in this entry I want to go back to the basics and comment on something I had been asked many times. I remember the times where we used Active Sync to connect Windows Mobile devices, is was not that hard but it could get tricky some times, depending if the device was connected via USB or Wi-Fi, emulators via  DMA and more. And to be honest, it was not that long ago. Fortunately the new Microsoft Windows Phone 7 series does this in a pretty easy way. Zune Besides being used to download apps, musics, podcasts or to sync content between the computer and the device. The Zune software is what we can easily use to "hook up" your device with your Visual Studio and deploy apps to your phone. If you are a registered developer at Microsoft Marketplace just connect your unlocked/activated phone. Run Zune if not setup to auto-start. Then on the Visual Stud...

Nice panning and zooming in Windows Phone 7

A bit of time ago I published an app called Hidden Pics on the Microsoft Marketplace, on that entry I covered some basics on the Isolated Storage and the PhotoChooserTask for Windows Phone 7. On this entry I want to cover the zooming and panning. As part of that app, the user has the option to open a photo full size on the device screen and then pinch to zoom the photo.  They can also pan by dragging on the screen with the fingers. Now this is supposed to be very basic, but there is a catch, which is making the zoom stable. By stable I mean that if you use two fingers to zoom in the photo, once you finish the two fingers should have the same pixels behind them, which indicates that you zoomed proportionally and panned correctly. After googling around a bit I put together the code to do both zooming and panning properly. So here is the XAML for the control, I am using an Image control inside a Canvas with a CompositeTransform : The photo will start fully fitted on the Ima...

Hidden Pics: My first App on Windows Phone marketplace

Image
Just days ago I finished and published my first app to Microsoft Windows Phone Marketplace. As part of the "#30tolaunch" program, I must admit that waiting for  the app to be certified was a little scaring, but the app was approved without any trouble and is already up, you can grab it here . Now the idea of the app is simple, it uses the Isolated Storage to hide pictures you want to keep out of curious people looking at your phone. And it involves two common elements that might be useful for you in future apps. 1) Isolated Storage 2) Photo Chooser Task Isolated Storage. The Isolated Storage is a virtualized file system so your app can't really access the device storage like it used to be. If you are a Windows Mobile developer, you might remember those times where you could write/read files all across the filesystem of a windows device. Thankfully that's not like that anymore. And you get a isolated space just for you application. Reading bytes from a file ...