When working on a project which requires a user interface, it is usually best not to jump ahead and start programming the UI part before making some sketches first. It makes sense, since UI development shouldn't be different than library/API development. The client is different, but the principals remain.
For a long time I've been a Balsamiq Mockups person. I know, it's not open source, but they'd used to give licenses to those who blogged about it. Also, few years ago, Balsamiq was far superior to other solutions and it contained much needed features.
This is not true anymore. For the past few months I've been using Evolus Pencil and I can tell you it's great. First - it's open-source. Second - it has ports to all platforms and can also run as a plugin for Firefox. Moreover, it is customize-able, extensible and very flexible.
So if you've decided to give Pencil a try, here's a tip that would make your wireframes look a bit more serious and professional: right click the "Sketchy GUI" collection in the collections tab, and select "Collection Settings...". Navigate to the "Text" tab in the resulting dialog, and change font family from "Comic Sans" to a font that you might actually use for the final product.
Want another tip for general wireframes design? Don't ever use "loren ipsum" as a text filler. Wireframes should be later translated into real UI and graphics design, so you don't want to find out that that text area you've been designing doesn't fit the needs of your application. Always wireframe with real data.
Those were my two cents for wireframes using open-source software. Hope it helped.
Friday, February 17, 2012
Saturday, January 7, 2012
Using App.Config in IronPython
I love python very much, and as you probably already noticed, I love C# as well. I already have many libraries and utilities developed in those languages, and for me, the ability to reuse code between those languages, is a must.
So I came to know IronPython, which is a complete Python implementation for the .NET platform, using the DLR. For most of the time, the integration between the two is a breeze. All you have to do is "clr.AddReference" your .NET assemblies, and you're good to go.
Unfortunately, with more complex projects, there are some caveats. Most notably is the missing ability to load app.config (or web.config, or any other .config) files from IronPython. Without diving too much into details, the reason is the way AppDomain works in .NET. It is looking for [assembly name].config file when one is requested using the ConfigurationManager. Since IronPython code is invoked with ipy.exe, the configuration file must be called ipy.exe.config. I suppose the same goes with IronRuby as well. This is a serious limitation.
Thanks to Tom E. Stephans for providing this awesome proxy for the ConfigurationManager. Basically, his code injects some logic to the inner workings of the ConfigurationManager, that allows us to specify which config file to be loaded. This config file will be seamlessly loaded by the ConfigurationManager when needed.
Unfortunately, Tom's code doesn't exactly compile. Probably due to some copy-paste issues he had when publishing it. So I did some minor modifications, and removed the part of the code responsible for loading custom configuration sections and uploaded it to Bitbucket, so everyone can use it. The code is available here, along with a sample usage python script.
Few things to keep in mind regarding my code:
So I came to know IronPython, which is a complete Python implementation for the .NET platform, using the DLR. For most of the time, the integration between the two is a breeze. All you have to do is "clr.AddReference" your .NET assemblies, and you're good to go.
Unfortunately, with more complex projects, there are some caveats. Most notably is the missing ability to load app.config (or web.config, or any other .config) files from IronPython. Without diving too much into details, the reason is the way AppDomain works in .NET. It is looking for [assembly name].config file when one is requested using the ConfigurationManager. Since IronPython code is invoked with ipy.exe, the configuration file must be called ipy.exe.config. I suppose the same goes with IronRuby as well. This is a serious limitation.
Thanks to Tom E. Stephans for providing this awesome proxy for the ConfigurationManager. Basically, his code injects some logic to the inner workings of the ConfigurationManager, that allows us to specify which config file to be loaded. This config file will be seamlessly loaded by the ConfigurationManager when needed.
Unfortunately, Tom's code doesn't exactly compile. Probably due to some copy-paste issues he had when publishing it. So I did some minor modifications, and removed the part of the code responsible for loading custom configuration sections and uploaded it to Bitbucket, so everyone can use it. The code is available here, along with a sample usage python script.
Few things to keep in mind regarding my code:
- It was compiled using Mono 2.10 like this: mcs ConfigurationProxy.cs -t:library -r:System.Configuration
- It was tested both under Mono and under MS .NET framework 4.0.
- There's a sample config file called blogsample.config which contains a demo connection string. This configuration file is loaded in test.py and the connection string is printed.
- Just like the ".ConnectionStrings" collection is accessed, one can access the ".AppSettings" collection.
- Since the injection is done to the ConfigurationManager, implicit usage attempts will also work. For instance, the SubSonic ORM which requires a connection string, will work seamlessly.
Once again, kudos to Tom for his great work. I hope you will find my corrections and sample useful.
Friday, October 28, 2011
TRouBLe is Useful
Web programmers have probably seen this a lot:
The reason many programmers "need" 4 lines of code for such a simple thing, is that it's impossible to set the margin (margin is just an example, since this is also true for padding/border/...) to 20px, and then override just the top margin. But isn't there a better way?
Well, there is a shortcut for the above:
Shorter, heh?
The parameters for attributes such as margin, are specified in this order: Top Right Bottom Left, or TRouBLe for short. CSS parsers are smart enough to apply the last specified parameters, to those that were omitted. So in the above example, I've omitted bottom and left, so the 20px value would be applied to those as well.
The general rule is:
* if only one value is specified - it is used for all (top, right, bottom and left)
* if two values were specified - the first will be used for top and bottom, and the second for left and right
* if thee values were specified - the first will be used for the top value, the second for the left and right values, and the last for the bottom value
If I wanted to set the margin-left to 10px, I'd have to write this "long" statement:
Many times, the shortened syntax can be used, and save us some typing while increasing the expressiveness of CSS attributes.
EDIT: It seems I messed up a bit the order in which things are shortened. Thanks for Tomer for correcting me. I've updated the post accordingly.
margin-top: 10px;
margin-right: 20px;
margin-bottom: 10px;
margin-left:20px;
The reason many programmers "need" 4 lines of code for such a simple thing, is that it's impossible to set the margin (margin is just an example, since this is also true for padding/border/...) to 20px, and then override just the top margin. But isn't there a better way?
Well, there is a shortcut for the above:
margin: 10px 20px;
Shorter, heh?
The parameters for attributes such as margin, are specified in this order: Top Right Bottom Left, or TRouBLe for short. CSS parsers are smart enough to apply the last specified parameters, to those that were omitted. So in the above example, I've omitted bottom and left, so the 20px value would be applied to those as well.
The general rule is:
* if only one value is specified - it is used for all (top, right, bottom and left)
* if two values were specified - the first will be used for top and bottom, and the second for left and right
* if thee values were specified - the first will be used for the top value, the second for the left and right values, and the last for the bottom value
If I wanted to set the margin-left to 10px, I'd have to write this "long" statement:
margin: 10px 20px 10px 10px;Which is still shorter than the first example above.
Many times, the shortened syntax can be used, and save us some typing while increasing the expressiveness of CSS attributes.
EDIT: It seems I messed up a bit the order in which things are shortened. Thanks for Tomer for correcting me. I've updated the post accordingly.
Wednesday, October 26, 2011
Installed Apps Doesn't Show in Market
Today I noticed an annoying bug in the Android Market application: it showed only 3 applications under the "my apps" section in the market, even though I have over a couple of dozen installed.
Rebooting the device or removing the SD card didn't help.
Being rather new to Android, I was tempted to remove the market application, and reinstall it. But Android is much like Linux, and much less like Windows, so reinstalling an application would probably retain the old settings.
And then it hit me - the settings. Why not reset those?
Simply go to: settings -> applications -> manage applications -> market -> clear data
That's it. The next time the market app launches, it will rescan the installed applications, and everything will be fine again.
That's pretty robust, even though it's in a geeky way, since I don't expect most people to do that.
Rebooting the device or removing the SD card didn't help.
Being rather new to Android, I was tempted to remove the market application, and reinstall it. But Android is much like Linux, and much less like Windows, so reinstalling an application would probably retain the old settings.
And then it hit me - the settings. Why not reset those?
Simply go to: settings -> applications -> manage applications -> market -> clear data
That's it. The next time the market app launches, it will rescan the installed applications, and everything will be fine again.
That's pretty robust, even though it's in a geeky way, since I don't expect most people to do that.
Friday, October 21, 2011
Best Windows Development Environment
I know, this one is going to sound a bit crazy, but hear me out. IMHO, the best Windows development environment is Linux.
First, let me start with a less surprising statement: the best way to run a Windows installation is on a VM. This should make perfect sense to anyone who runs Windows on a daily basis, and knows that as time goes by, it simply gets slower.
No registry or other cleaning utilities can return it to run as fast as it was the day you installed it.
Moreover, when one wants to test a new piece of software, the VM's snapshot feature really shines.
So, every once in a while, one can revert to the a stored snapshot, and get an almost fresh Windows installation, almost instantly.
When it comes to development environments, where one rarely install tools, and the code is managed in source-control, reverting to a snapshot is even easier.
My second point is: use the host environment that you feel most comfortable with. In my case, it's Linux. Specifically Ubuntu. If you prefer running a Mac or a different Windows as the VM guest, it's OK as well. But I can assure you that after giving Linux a trial period as the host OS, you'll find it the most pleasant one.
Moreover, if cross platform compatibility is an issue for you, having Linux *and* Windows running simultaneously, is a great advantage and a real time saver.
First, let me start with a less surprising statement: the best way to run a Windows installation is on a VM. This should make perfect sense to anyone who runs Windows on a daily basis, and knows that as time goes by, it simply gets slower.
No registry or other cleaning utilities can return it to run as fast as it was the day you installed it.
Moreover, when one wants to test a new piece of software, the VM's snapshot feature really shines.
So, every once in a while, one can revert to the a stored snapshot, and get an almost fresh Windows installation, almost instantly.
When it comes to development environments, where one rarely install tools, and the code is managed in source-control, reverting to a snapshot is even easier.
My second point is: use the host environment that you feel most comfortable with. In my case, it's Linux. Specifically Ubuntu. If you prefer running a Mac or a different Windows as the VM guest, it's OK as well. But I can assure you that after giving Linux a trial period as the host OS, you'll find it the most pleasant one.
Moreover, if cross platform compatibility is an issue for you, having Linux *and* Windows running simultaneously, is a great advantage and a real time saver.
Sunday, September 25, 2011
C# Extension Methods
One of my favorite features in C# is Extension Methods. Let me explain why.
Did it ever happen to you that you needed to add a method to a class you cannot edit, and inheritance couldn't help as well?
This can happen in various opportunities, especially when working with libraries and SDKs that uses a certain class for its internal operations, and exposes this class to the user as well.
In such cases, in languages that doesn't support extension methods, the only way to add functionality to that class, is to write a "helper" class or method, and use it.
C# Provides a better way.
Let's say you have a blogging system, and you have a blog summary page, that displays only the first 100 characters of each post, as a teaser. There could be many ways to get the shortened text, but image you could have your own String class, that provides a method that displays the entire post if it's less than 100 characters long, and displays only the first 100 characters and "..." if it is longer.
Have a look at the following extension method:
Simple. This code needs very little explanation. All it does is create a new extension method for the String class that implements the logic described above. Here's a sample usage for this new method:
The output of this would be "12345...", as you'd expect.
The possibilities of extending built-in classes provided by C# and the various libraries, such as ASP.NET MVC, are endless. Just make sure you don't abuse it.
The full source code of the sample given above is available on my bitbucket samples repository. It compiles on Mono as well as on MS C# compiler.
Did it ever happen to you that you needed to add a method to a class you cannot edit, and inheritance couldn't help as well?
This can happen in various opportunities, especially when working with libraries and SDKs that uses a certain class for its internal operations, and exposes this class to the user as well.
In such cases, in languages that doesn't support extension methods, the only way to add functionality to that class, is to write a "helper" class or method, and use it.
C# Provides a better way.
Let's say you have a blogging system, and you have a blog summary page, that displays only the first 100 characters of each post, as a teaser. There could be many ways to get the shortened text, but image you could have your own String class, that provides a method that displays the entire post if it's less than 100 characters long, and displays only the first 100 characters and "..." if it is longer.
Have a look at the following extension method:
public static class StringExtension { public static String ShortenText(this String str, int length) { if (str.Length > length) { return str.Substring(0, length) + "..."; } return str; } }
Simple. This code needs very little explanation. All it does is create a new extension method for the String class that implements the logic described above. Here's a sample usage for this new method:
Console.WriteLine("12345678".ShortenText(5));
The output of this would be "12345...", as you'd expect.
The possibilities of extending built-in classes provided by C# and the various libraries, such as ASP.NET MVC, are endless. Just make sure you don't abuse it.
The full source code of the sample given above is available on my bitbucket samples repository. It compiles on Mono as well as on MS C# compiler.
Friday, September 23, 2011
Ubuntu 11.04 and Unity
For a long time I've been a 10.10 user. Probably too long. To tell you the truth, I couldn't care less. Everything was so customized to my own needs, and everything worked perfectly.
Moreover, since most of my development nowadays is done on a Windows box, I didn't feel the urge to try something new on Linux.
Finally, there were so many bad reviews about Unity, and "thanks" to those I had second thoughts about replacing the desktop environment.
Last week I took the "risk", and you know what? I love it!
I had 11.04 installed both on my workstation and my laptop, and I can easily say it's one of the best Ubuntu versions I used.
On my laptop, I rarely connect a mouse, and I hate touchpads. This means I use the keyboard almost exclusively. Unity seems to be adapted to this, so it provides great keyboard shortcuts. Now I need the mouse even less.
On the workstation, even though I have a big screen with a "big resolution", I always try to find the best utilization for the screen space real-estate. If you ever seen a those 30" mac wide monitors that have the mac dock dragged to the left edge, you know what I'm talking about.
Unity also knows what I'm talking about.
Also, performance is great, as ever. Far better than using Windows. Ubuntu never misses this one.
I wish I didn't wait so long to try Ubuntu 11.04 and Unity. On the other hand, since this version is quite mature, there's a chance I saved myself some of the glitches and bugs it had 5 months ago.
Moreover, since most of my development nowadays is done on a Windows box, I didn't feel the urge to try something new on Linux.
Finally, there were so many bad reviews about Unity, and "thanks" to those I had second thoughts about replacing the desktop environment.
Last week I took the "risk", and you know what? I love it!
I had 11.04 installed both on my workstation and my laptop, and I can easily say it's one of the best Ubuntu versions I used.
On my laptop, I rarely connect a mouse, and I hate touchpads. This means I use the keyboard almost exclusively. Unity seems to be adapted to this, so it provides great keyboard shortcuts. Now I need the mouse even less.
On the workstation, even though I have a big screen with a "big resolution", I always try to find the best utilization for the screen space real-estate. If you ever seen a those 30" mac wide monitors that have the mac dock dragged to the left edge, you know what I'm talking about.
Unity also knows what I'm talking about.
Also, performance is great, as ever. Far better than using Windows. Ubuntu never misses this one.
I wish I didn't wait so long to try Ubuntu 11.04 and Unity. On the other hand, since this version is quite mature, there's a chance I saved myself some of the glitches and bugs it had 5 months ago.
Subscribe to:
Posts (Atom)