BlackBerry Java Development: As compared to Android = Horrible Experience

The BlackBerry device , when it came out was amazing. There was nothing like it! At one time it was at the pinnacle of its glory, as an amazing little communication tool, when iPhones and Android’s weren’t there yet. But in the recent years , due to various reasons I feel like listing out here, BlackBerry is going home.

I’m an android developer. My love for android and java started at an early age, and now I’m pretty established over the Android market. After that I decided to try BlackBerry development. And boy was it tough! Anyone who has gone through this transition will know what I’m talking about.

All the Android developer tools are well documented, easy to use, built with great care and allow people who are fundamentally weak in programming to do things they never thought possible. But when it came to BlackBerry, I was very disappointed.

Lets go pointwise

1. Development tools

You need to sign up with Blackberry and download their development environment which is around 400 MB. Now though it seems heavy, everything is packaged into one neat little bundle ready to run. Android has a very tedious process of installing the development environment which isn’t very easy at all and some configuration needs to be done in order to get the SDK working.

Although both run eclipse, BlackBerry somehow seems to be slower. Writing programs in the BB environment isn’t so user friendly – not many suggestions or tweaks RIM has implemented. Nothing fancy at all.

Now when you start writing code, You’ll realise for debugging and testing, Android has the upper hand. LogCat, Emulator control, Profiler , Allocation Tracker and so many tools in Android make debugging a breeze. BlackBerry is the worst when it comes to debugging. Firstly the emulators are horrible. Simply horrible. Firstly they take a hell of a lot of time to start up. The emulation isn’t efficient at all and immediately hogs about 500MB of your memory. Oh and this is without the debugger. If you choose to attach the debugger from the start you can probably take a bath and it still won’t be ready yet. The debugger output isn’t at all categorized like android. Its just random shit blurting out at you. It takes you time just to find out where you wrote a simple System.out.Println(“Hello World”) , and be sure to include newline characters because it wont do that either.

Now assuming your program has a bug in it and you hit run, most of the emulators just show you this nasty Java error screen and halt. Thats it. They halt. Then you can’t even quit the bloody thing. You have to kill the processes on Windows Task Manager , well not only kill but to FORCE it to close. Then you edit your code and restart. The same thing all over again. And no my laptop isnt slow – its an Acer Aspire with 3 gigs of RAM and a core i3 processor runnning windows 7 x64.

Also, theres a funny thing. You would expect things that work on an emulator to work on a device of same specs. Sometimes, the program runs fine on the device but not on the emulator! The emulator keeps throwing weird errors at you. You have to keep “cleaning” the emulators. I really do not understand why RIM can’t put a little effort into their development tools. Its almost like BlackBerry doesn’t want you developing apps!

Sometimes the environment just will not show you exactly where the error occured. It just shows you the top level stack trace like the line MyScreen = new Screen() failed. Gee, I need to know WHERE the error occurred in order to fix it don’t I? So I google this error on the BlackBerry blogs. It looks like there’s a poor guy by the name of Mark Sohm answering everyones questions. The best part is, not even trained advanced developers have a clue about what is going on because of RIM’s slack implementation of Java.

2. Official Documentation and Support

The BlackBerry website seems to have detailed documentation about implementation with code, but sometimes that code simply does not run. Yes their own code has bugs in it and does not run. Also, they don’t explain proper methodologies on their website, they will never tell you efficient ways of doing it. Apart from that there is very little documentation out there. Android has tutorials on almost every website , not one but like ten different websites with ten different methods!

Also, for Android developers, theres a website called Stack Overflow. It is an amazing community of people who solve any problems related to Android and I refer to their questions more often then I do with the official website. Blackberry doesn’t have such a community. Everything is corporate. You need help, you pay for it. Nobody is interested in offering you good advice or code for free. They don’t even have proper videos on how to start programming.

3. Components

The RIM Blackberry API has very very limited components with limited functionality. You can’t skin them just by giving them a stateful background like android. You have to download heaps of code just for a simple stylable button. Wastes a lot of the developers time. There is no drag and drop UI. The UI isn’t separate like in android xml layouts. Everything is crammed into one ugly piece of code.

4. Signing and Publishing

Well registration is free for a BlackBerry developer account. But its a very long process, they ask you to fax them your identification proof before they accept your registration. Then the ISV portal where you submit your apps doesn’t work half the time. The graphs dont show saying there was an unexpected error, right now I’m getting a server overloaded error, and they ask you to upgrade to the latest browsers. The app submission process isn’t friendly at all. Its very ugly and complicated. Theres no good mechanism for uploading files, the app approval process takes a huge amount of time like 15 days or even three weeks or so. If you have an error the process repeats. Same like apple. Now the Android market gives you good analytics. BlackBerry analytics = one ugly CSV file.

RIM has murdered blackberry development by not supporting it and making it more user friendly. Looks like they don’t want people to develop BB apps.  I hope someone from RIM reads this. Shame on you. All of you.


The sad truth about Assignments

Many of you know I oppose UoP a lot. I have my reasons for opposing them. And today my effrontery has reached its pinnacle. Now that I have probably become the epitome of shamelessness, I might as well start.

For those of you who do not know UoP – Its the university in Pune, India which probably is analogous with most , but not all universities in India. Wikipedia says It is one of India’s “premier” universities. It was founded in 1949.

” Assignments are Criminal “

Most Indian colleges tend to give something called “assignments” to the students. These assignments are usually questions from a local author book or questions from previous papers. Now by definition “assignments” were always meant to be insightful small tasks to be performed by the individual at his own pace. Assignment pages in US universities for undergrads probably span maybe 3 or 4 pages long consisting of original objective questions put forward by the professor. It is assumed that the student will do this task if he wants to and nothing is forced with few or no deadlines.

UoP apparently has a policy in place where a minimum number of assignments must be assigned to each student to grant his/her term. Most teachers take this a step further and make the two page assignment into a ten page one taking the average time per assignment from say thirty minutes on your own to a few hours at least. They also impose certain “deadlines” along with other extortion tactics like not “marking your attendance”.

Also, a deeper study of why teachers do this is led me to the reason that they believe that if you “write” something , whatever you write will magically be embedded deep within your brain and you will never forget it, something like a Harry Potter blood quill.

A much deeper flaw is that on an average only 10/60 students sincerely complete the assignment task while the others replicate it in fear or sheer laziness. These assignments when completed are never checked deeply because even the teachers know they are copied.

On an environmental note, you also waste a phenomenal amount of paper. Each journal has around 14 assignments on average with around 4 to 5 pages of write ups with it. So one journal comsumes 14*5 = 70 pages. There are around three journals per semester. So 70*3 = 210 pages for a semester not counting the extra internal assignments. Each branch has around 120 students per year of college. So 120*4 = 480 students in a college. Last time I checked there were around 700 colleges in Maharashtra state itself. So 480  * 700 (students) * 210 pages per semester thats around 7,05,60,000 or around 7 crore pages per semester. Multiplied by eight semesters so 7*8 = 56 crores. With my calculation that amounts to around 20 lakh trees being cut down in one state of one country.

We kill 20 lakh trees per engineer writing assignments that never help anyone.

The question we have to ask is are these assignments really necessary? They lead us absolutely nowhere,  benefit no one and help in global warming.


Controlling your PC via the internet: A XML Approach

I’ve recently come across thousands of paid apps that allow you to control your pc via the internet through a mobile phone / tablet pc. I couldn’t help pondering over how to code this or implement this in real life. A very simple, stupid approach which I will introduce here through this tutorial should teach you how to easily create a simple framework for access.

This should give you a fair idea how it is going to be implemented

Overview

Again, just so you know – This isn’t the ideal way to implement it but as I said – this is the quick and dirty base you can set up within a few hours.

For this tutorial you will need the following:

  1. A Shared/Dedicated Hosting Web Space with PHP and FTP access
  2. Visual Studio 2010 (C#)
  3. A good php and xml code editor like Dreamweaver
  4. A testing server (Optional)
  5. A mobile device with internet access (For testing!)

I will briefly explain how it works:-

  • A C# executable will be running on your PC (Which you will code of course) which establishes a connection to the server and “listens” (keeps downloading the file every X seconds)
  • The information is downloaded, parsed and actions are taken according to the values found after parsing.
  • This executable shall issue the commands to the .NET API to control your PC ( I will show you a simple mouse demo )
  • A PHP front end interface will allow the user to issue commands to the PC. An HTTP GET request will be dispatched to the server with a variable(number) that tells PHP to write that number out into an XML file and keep it on the server
  • The file is again pulled by the computer and commands are executed.

Lets Start!

1. Coding the C# Application

Fire Up Visual Studio 2010. Open a new C# Project (Windows Forms Application). Make your UI Similar to this.

Four Button Controls , Two Labels, Two Textboxes,A timer, A Status Strip

The Buttons are just for testing your code for moving your mouse. Before I explain what everything is for, start implementing the simple code for moving your cursor. Take a look at this

Cursor.Position = new Point(Cursor.Position.X + d1, Cursor.Position.Y + d2);

This is the crux of the program. This will move your cursor to the X,Y Position already present + the displacement in pixels (d1=displacement in x direction and d2=displacement in y) Replace d1 and d2 with integer values and watch the fun!

private void btnDown_Click(object sender, EventArgs e)
{
 Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + 10);
}

Once you double click on any of the buttons – just like Visual Basic, code is generated. In that paste the given line with modifications. Keep in mind the coordinate axes meant for computer screens and give values accordingly. I have showed the code for the down button.

Our next job is to create the sample xml file we will use for parsing and upload it to the server.

Now some of you might ask, why XML? The answer is simple. XML is a generic, simple markup language which allows any language to communicate with any other language. The parsing functions for XML might differ but the result is unique. If you are not familiar with XML you can read a bit on http://www.w3schools.com/xml/default.asp

Our XML file structure will be something like this

<?xml version="1.0" encoding="ISO-8859-1" ?>
<root>
 <Command>
 <id>263</id>
 <instruction>1</instruction>
 </Command>

<root>

Our ‘root’ nodes shall hold a Command object which has the following properties:

id: A number to keep track of which command was executed previously

instruction: A number which we assign a special meaning to – it tells which instruction is to be executed. For example instruction =1 could mean Mouse Up, Instruction=2 could mean Mouse Down, and so on.

We can also have Multiple Commands if we plan to extend it. For example Open Media Player. Play the file. Exit ; Well you get it!

Now you could code the xml file in any text editor you like, just make sure it is well formed. Once you have done that, save it temporarily on your drive. Open up your FTP Manager Program / Login into your shared hosting control panel File Manager

Transfer the xml file to some directory for testing. I have named mine “remote”.

Keep the absolute location in mind (http://myhosting.com/remote.xml) or whatever , because our program is going to need this.

Now we have to write a function that parses the XML file in C# So we know what to do.

Specify the using directive on the System.Xml namespace so that you are not required to qualify XmlTextReader declarations later in your code. You must use the using directive before any other declarations.

Create an instance of an XmlTextReader object, and populate it with the XML file. Typically, the XmlTextReader class is used if you need to access the XML as raw data without the overhead of a DOM; thus, the XmlTextReader class provides a faster mechanism for reading XML. The XmlTextReader class has different constructors to specify the location of the XML data.

Read through the XML. (Note that this step demonstrates an outer “while” loop, and the next two steps demonstrate how to use that loop to read the XML.) After you create the XmlTextReader object, use the Read method to read the XML data. The Read method continues to move through the XML file sequentially until it reaches the end of the file, at which point the Read method returns a value of “False.”

The code above should help you with the parsing of XML files. I have used Booleans to check at what point we are in the xml file.

while (reader.Read())
{
    // Do some work here on the data.
	Console.WriteLine(reader.Name);
}
Console.ReadLine();

The last three steps were from http://support.microsoft.com/kb/307548 Please refer for more information.

 

I have also handled exceptions for when there is no internet connectivity.

Now where does this function go? Simple! The timer should execute this function every “X” seconds to get the right Data.

private void timer1_Tick(object sender, EventArgs e)ReadMyXML();That should take care of getting and parsing the data.  Your demo is ready and should run with the static xml file.

}

 

Now the question arises, can we generate this file dynamically? Can we get a user to enter a link in his browser passing a parameter he wants so that the xml file is generated?  for example http://harsh.alkutkar.com/remote/?c=1 will generate an xml file that contains a “Mouse Up” command!

The answer is , yes, We can use a dynamic web language such as PHP or python to generate this. PHP shall parse the URL entered in the browser and find the parameter (here it is ‘c’) and its value (1).

Here is the php code for writing out an XML file in the way we want. Make sure permissions for writing files are enabled on your server or it gives an error when you try to write a file.

PHP Code for Index.php

PHP Code for Index.php

Thats it! Try your new link http://mysite.com/remote/index.php?c=3 or something and enjoy the fun. You could do the following modifications to make it fully featured

1. Provide user security with user name and passwords

2. Make an Android App that will have a nice UI and issue those commands

3.Add Code for more functionality – Playing Music, Powerpoint (Google them!)

Let me know on my email harshalkutkar@gmail.com if you do come up with something!

Till then Cheerio!


RIA Development: Great Typography

Remember, Engineers are not designers!

Typography

Typography in terms of web design is basically, text, composed to create a readable, coherent, and consistent look which works for the reader.

This arrangement of text involves –

  1. Typefaces
  2. Line height
  3. Font Weight
  4. Text Colour
  5. Letter Spacing
  6. Character Spacing
  7. Measure

An arrangement of these which suits the clients requirement and also appeals to the user ,makes it visually appealing and attractive

You might probably think, ‘Hey! I can just pick a random font and a random color and it should be alright right?’

If you want your app to look like a 3rd grade school project you could go with the above idea, or else it’s time to change your user interface and, your attitude towards UI.

I’ll be illustrating some examples with CSS because it’s the easiest to understand and works with any website and also Flex. You can find most of these options on the Photoshop ‘Character’ panel or whatever you are using.

Typefaces usage guidelines:-

  • When designing logos and headings try to stick to simple serif fonts rather than funky bitmap, calligraphic fonts, unless your client demands so specifically
  • As a general rule of contrast – Light text on Dark backgrounds and Dark text on light backgrounds, so that a user can read the text comfortably without strain on the eye.
  • Try to cater to the larger audience. Use system installed fonts like Arial, Helvitica etc which are universally available on every machine and are cross platform. List alternatives by using the Font-Family statement instead of sticking to a single font, in case of CSS.
  • Remember not to use fonts which you have downloaded directly on to the webpage without embedding them in some form.
  • Consistency: – Try to stick with one style of font for all your pages, don’t use for example Comic Sans for the heading, then Arial for the menu and Courier for the content. You may vary font weights and sizes where needed.

 

Getting the best out of simple fonts with CSS

People feel their creativity is limited when you tell them to use in-built system fonts. I’ll explain how this is not true with some examples

Example of Styled Fonts

Example of Styled Fonts

Here the first paragraph is the default rendering in Internet Explorer with no style

The second paragraph has some minimal styling applied to it as follows:-

Styling Applied to Paragraph 2

Styling Applied to Paragraph 2

 

As you can see these three properties dramatically alter the default rendering. A few variations of this could be adjusting just the four properties: –  letter-spacing,line height,font-weight,text-transform

Example of how built in fonts can be styled using CSS

Example of how built in fonts can be styled using CSS

Text Colour

  1. Make sure your text is readable and also matches with the template or color theme of the program. While doing this make sure you know the background color of your text, what I mean to say is for example don’t put light grey text on a cream background webpage which is very hard to make out. 
  2. Test out the colors on either paint or photoshop to see that they complement the overall theme of the page.
  3. Do not use colors on the fly randomly without first thinking of a color theme
  4. Do not use contrasting colors or vivid colors on the web page that hurt the eye.
  5. Use font weights to assign priorities to the text under consideration. For example, if there is an alert or a warning next to normal text content make sure both of them do not have the same weight (bold). Give the warning a higher weight than the text

Letter Spacing/Word Spacing/Line Spacing

            Make sure the letter spacing and word spacing are proportionate. Do not try to fit maximum content in the minimum amount space. Don’t give the user an impression that you are throwing something at him and be like “Here is everything. Now figure it out”.

 

Deciding a color theme

There is no single answer to the question “What is the best colour theme to use?”. The truth is there are millions of them. How do you come up with something that suits your requirement?

In many websites the colour theme is adjusted according to the content. For example if the images in your slides/pages have a lot of purple in them, the theme will be oriented in a “purple varaints” fashion

The other way is to go by the colours of a logo. Usually you have logos ready before you start a page or a program. If your logo is light, you want a dark backround and vice versa. Also the website colours must complement the logo or the product for the webpage.

If you still aren’t getting it, try Kuler from Adobe (http://kuler.adobe.com) where you can play around colour themes people have already made and use them directly on Photoshop or Dreamweaver.

Adobe Kuler

Adobe Kuler

Content Padding

            The padding clears an area around the content (inside the border) of an element.

Make sure you use proper padding and margins everywhere so similar containers or text don’t get too close to each other like it’s a trashcan where everything is thrown in!

The image below should give you a clearer picture about how paddings and margins work.

 

Some Examples of great typography

That finished the typo part. Hope this will help you at some point of your life when you design good scalable applications or RIA’s.


Create your own trance,rock,pop songs! Professionally on your computer! Without a single Instrument!

Ever listened to Armin Van Buuren , Dj Tiesto trance songs and wondered if you could try ? Ever wanted to create your own songs but never had the cash? Here’s just the thing for you!

Logo

FL Studio 9 by Image-line!

This is the most amazing piece of software I have come across by far. This software will allow you to create, edit, mix your own drum samples, make your own loops for techno/trance songs. You can use built in drum-loops or make your own. It has support for a lot of musical instruments. If you ever fall short you can always download your own sound samples or plugins from their website.

The basic layout is somewhat like this -

Main FL Studio Window

On the extreme left you can see the Browser window which allows you to see all the files and sound samples available as also plugin presets.

In the middle you can see the Pattern Sequencer. The sound sample can be triggered on or off by clicking the switch-like buttons.

Pattern Sequencer

You start off with a basic Kick,Clap,Snare,Hihat. After that you add your own channels according to your requirements.

You get a piano-roll interface to find the exact notes. There are Bassline synthesizers built in. You just have to play around a little to get the beats right. If you try the one above you might get an idea.

The TS404(or any other) will sound a bit boring alone on its own. So try and send it to an ‘FX’ channel, and apply different effects.

Effects/Send Window

The easiest to start with for a techno preset are the Fruity Delay Bank which gives a nice delay effect. Recorded vocals can use the Vocodex plugin.

If you have a MIDI compatible keyboard at home you can enter your notes directly into fruity loops. Dont have one? no worries! Just type with your normal keyboard and hit record.

Also you can use the Hardcore Plugin to experience real AC/DC guitar like-effects. Just like the real ones.

Hardcore Plugin

What are you waiting for? Navigate to http://www.flstudio.com/ and download your free trial!

Dont believe me? Try listening to this http://www.youtube.com/watch?v=E0yuzb1ysnU&feature=related created on Fruity Loops.


1000 views: Thank you

1000+ Views!

I just checked my stats right now and my blog has 1085 views. Thank you everyone!

Harsh


Snow Leopard 10.6.2 on HP 530 Fully loaded

Snow Leo

Snow leopard on HP530

After hours of tinkering and downloading kexts , distros, finally I managed to get Snow Leopard Working on my HP530.

Here are the specs of my HP 530

SPECS

Core 2 Duo 1.6 Ghz T5 series

Intel GMA 950 Graphics

2GB DDR Laptop RAM

Intel PRO/8245 Ethernet and Wireless

Realtek HD Audio (On 7)

Chameleon 2RC4 bootloader with Mac OS X 10.6 / Win 7 / Snow Leo Dual boot

Installed Kexts/Drivers: [ Available in file attached below ]

1.Graphics – Intel GMA 950 (0x27AE) series kexts. Please note I had to add the device-properties UUID to the apple com.boot.apple.plist so that it detects it.[Full Resolution with acceleration]

2.Audio – VoodooHDA (fixes the mic and headphone ports and makes them work )

3.PS/2 Controller – Synaptics Apple PS2 controller

4.Ethernet – Intel 8255x controller.

5. Wireless – Intel PRO Wireless [Does not support encryption] http://code.google.com/p/iwidarwin/

6.Power – VoodooBattery / VoodooMiniPower (Google it) Enables Speedstep required for greater battery life and less overheating

Download Netbook Pack here

Download Trackpad kext here

Download Ethernet Card kext here

Download Extensions folder here

Netbook Pack contains IntelGMA950 x27AE specially for HP530 and voodoo battery meter/hda kexts along with com.apple.boot.plist which you need to place in your extra folder to run snow leo.

My method

After reading hundreds of different tutorials I decided to do it my own way. I downloaded SNOW OSX 3.5 , burned it to a DVD and tried to run it. It gave a kernel panic with something about page fault error type 14 and forced me to restart.

This is a problem with HP Laptops. I cannot set it to IDE through the bios I can just enable or disable the native SATA mode which in my opinion does not make a difference. Also I did not know about the DSDT or what it is used for.

Also I wanted to triple boot it on MBR partitions. This was a major problem.

1. Installed Kalyway’s Distro  10.5.2 to DISK 1. Updated it to 10.5.6 following the update guides given. Used Chameleon 2 RC4 and EFI 9. (RC4 and EFI 9 or 10 is MUST)

2. Then Downloaded Snow Leo Distro SNOWOSX. Burned it to a DVD.

3.Booted into Leopard. Browsed to the System/ Install/ Folder to a file called OSInstall.mpkg

4.Formatted DISK 2 on which snow leo was to be installed. Installed Snow leopard with the file above. DO NOT RESTART AT THIS POINT.

5.Installed Chameleon 2 RC4 and EFI v10 on the other drive too.  Replaced the mach_kernel with the voodoo one and the boot file which I got from somewhere

6.Find the DSDT GUI Patcher on the drive. Run it. Select the drive you are going to install Snow on. Do not select any other drive. Hit the Make DSDT button or whatever. You should see a dsdt file on the drive root now.

7.Make a new folder called “Extra”. Copy com.apple.boot.plist from the netbook pack, and also copy the dsdt file here too. Next make a folder called Extensions. Copy the extensions you want it to load on startup. Best way is to copy the extensions folder from your working Leopard. Pay attention to IntelPIIXATA. Read threads about the IOFamily kext causing problems with SATA.

8.I deleted the IntelPIIXATA file. Downloaded fakesmc from netkas. Deleted the DSMOS inside the installed snow leopard drive in  S/L/E

9.Restart. Select the snow leo drive. Type -v cpus=1 arch=i386 rd=diskAsB where A and B are the identifiers for your drive. You need cpus=1 or it just wont start.

8.If you get a waiting for root device message there are a lot of ways to solve this. Its a problem with the SATA drive. Play around with the IOATAfamily kext. I deleted it and I got no kernel panic. That file caused a page fault for me and snow leo wouldnt boot. Add the UUID string for the disk if you need to in the com.apple.boot.plist file in the Extra Folder

9.Snow leo should start with 1024×768 and no graphics/ethernet/sound working

10. Use kext helper. Install the kexts one by one. Restart

There you go a working Snow leo install with almost no kernel panic!


Follow

Get every new post delivered to your Inbox.