Archive for the ‘general programming’ Category

Browsing Web with human interface: Mozilla Ubiquity

preamble

Mozilla Labs as always makes us happy with new innovative ideas.
Maybe you remember post of Vasiliy Kiryanov about Mozilla Prism: with that platform we can use web-applications like regular desktop applications [http://blogs.helion-prime.com/vasiliykiryanov/2008/06/03/new-web-experience-with-mozilla-prism.html]
And now new fresh idea from Mozilla Labs: Ubiquity as a way “connecting the Web with language”.

Ubiquity way

For a long time people have idea to create a way to store and query data of any application easy.
It can give enormous flexibly like everything is already here and in appropriate format. We know this idea as W3C Semantic Web[http://ru.wikipedia.org/wiki/Semantic_Web], as we are still far from it, software developers on Internet are using mashups [http://en.wikipedia.org/wiki/Mashup_(web_application_hybrid)] to get similar effect today.

But what can we do from user side when we want to connect many different applications together, and use them in a same way. Ubiquity propose a way to describe common tasks in the Web using language-based instructions, and then you can create you own mashups with help of existing open Web APIs.

To have a better understanding how it work you can watch following video:

Now if you like the idea you can try it: [https://people.mozilla.com/~avarma/ubiquity-0.1.1.xpi]
or continue reading about it from Ubiquity tutorial: [https://wiki.mozilla.org/Labs/Ubiquity/Ubiquity_0.1_User_Tutorial]

related links:
Ubiquity Commands: [https://labs.toolness.com/ubiquity-herd]
Get Help & give your suggestion: [http://getsatisfaction.com/mozilla/products/mozilla_ubiquity]
Report a Bug: [http://labs.toolness.com/trac/report]

Easy user-interface(UI) prototyping

preamble

We need special software to make prototypes of user-interface everyday, and it doesn’t mater if we do new system or redesign of old one. Also we don’t have dedicated person for every task due to we use Agile approach [http://en.wikipedia.org/wiki/Agile_software_development] to development.

Certainly someone say that: they don’t need to prototype, they can use just pencil and paper, or even they have designer for such tasks. Don’t believe them, it’s task of developers as well as writing tests.

If you still think differently about test: check Test-Driven Development (TDD) [http://en.wikipedia.org/wiki/Test-driven_development],
if about prototyping read famous book of Alan Kuper “The Inmates Are Running the Asylum”. [http://www.amazon.com/Inmates-Are-Running-Asylum/dp/0672316498]

rapid prototyping

If you still reading.. then we just need to select some software to do it fast, pretty, and surely with Open-Source software. [http://en.wikipedia.org/wiki/Open_source]

On Interaction Design Association (IxDA) [http://www.ixda.org/] discussion forum we can find that  people use almost any tool to do prototyping: ACD Canvas, Microsoft Word, Microsoft Excel, Snapz Pro X, Eight Media, GUI Design Studio, LucidSpec,
Multimedia Fusion, SmartDraw, Inspiration, MockupScreens, Microsoft Power Point, Oversite, …

First of all forget about software for grapic manipulations like: adobe photoshop or corell draw, then  about software that don’t have any connection to prototyping at all. With such software you will lose your time, and will think that it is work for designers.

There are different special software to prototype software user-interfaces, and most of them are commercial.

As famous commercial I can note:
Axure [http://www.axure.com/],
Adobe inDesign [http://www.adobe.com/products/indesign/],
MS Visio [http://office.microsoft.com/en-us/visio/FX100487861033.aspx]

Sure we have open-source ones, I have checked several and unfortunately most of them are ugly.
But still we have wonderful rising star. It has basic amount of functionality at this time. But has all possibilities to became wonderful open-source project.
Here it is: Pencil project. [http://www.evolus.vn/Pencil/]

Top features:
* Built-in stencils for diagramming and prototyping
* Multi-page document with background page
* On-screen text editing with rich-text supports
* Installing user-defined stencils
* Standard drawing operations: aligning, z-ordering, scaling, rotating…
* Adding external objects
* Cross-platforms

I hope you will find yourself in UI prototyping, as well as architecture prototyping with Unified Modeling Language(UML) [http://en.wikipedia.org/wiki/Unified_Modeling_Language]

related links:
# http://Interaction-Design.org — an open-content encyclopedia about usability
# http://jthom.best.vwh.net/usability —Online guide to usability methods
# http://Usabilitybok.org
# http://usabilityfirst.com — Online guide to usability methods resource

W3C Semantic Web: future or another standard?

“The nice thing about standards is that there are so many to choose from.”
Andrew Tannenbaum

preamble

Web 2.0 became a buzz word nowadays and many people has different understanding of it.
It seems we can just use World Wide Web consortium(W3C) [http://www.w3c.org] and find final definition,
but there is no any standard definition. We have many different definitions from different companies or people.

Let’s make short sum-up:
Web2.0 is a architecture of interconnectivity and social interactions on the Web.
With such architecture we can create web-sites where users can produce content of his network using distributed content of other networks or independent developers.

Common mis-association here is that AJAX[http://en.wikipedia.org/wiki/AJAX] is a main feature of Web2.0, it is became so popular because many Web2.0 sites heavily use Ajax. In real we can create Web2.0 web-site with described features of Web2.0 without Ajax.

Web2.0 websites typically use some of the following features:
* CSS: separation of presentation and content
* REST or JSON-based APIs: system inegration and separation
* Rich Internet application techniques: Ajax, Flex, Flash
* Syndication, and aggregation: RSS or Atom feeds
* Weblog-publishing tools, and social networking tools: chat, forum, wiki, ..

Now as you have rough understanding of Web2.0 main question is what is:
Semantic Web (Web3.0)?

Another useful standard

Unlike Web2.0 Semantic Web is a W3C standard[http://www.w3.org/2001/sw/] and so we can find final definition of it.

“The Semantic Web provides a common framework that allows data to be shared and reused across application, enterprise, and community boundaries. It is based on the Resource Description Framework (RDF).”
According to Semantic Web home page

Talking common language:
Semantic Web is a way to store all data in such way to provide easy way for any application to use it.
It provide special formats for storing and querying of data.

“The big picture: imagine having one query language, one client, and one data access protocol which let you arbitrarily slice the data of Flickr, delicious, Google, and your favorite Web 2.0 sites, FOAF files, RSS 1.0 feeds — plus anything that can be mapped into RDF. This is data integration the Web 2.0 and the Semantic Web way.”
Good general description from “Talking Points for Semantic Web vs. Web2.0″ [http://www.w3.org/2006/05/SW_Web2.html]

Nevertheless potential useful points of Semantic Web and even some use-cases [http://www.w3.org/2001/sw/sweo/public/UseCases/]
we still very far from any production use of it.

In real life we can still use XML[http://en.wikipedia.org/wiki/XML], RDBMS [http://en.wikipedia.org/wiki/RDBMS], and SOA [http://en.wikipedia.org/wiki/Service-oriented_architecture] to get similar behavior today.

Own social network for anything

preamble

Nowadays social networks on Internet take a lot of popularity. Your neighbor is probably already has social network about home shopping or nuclear reactors.
It is no wonder that more possibilities appear to create fast and easily your social network like:
Ning [http://www.ning.com/], KickApps[http://www.kickapps.com/], CrowdVine[http://www.crowdvine.com/], GoingOn[http://www.goingon.com/], ONEsite [http://www.onesite.com/], etc..

Our company had a chance to estimate some of them.
As most advanced and popular (> 230.000 networks) platform I can name: Ning.

Ning platform

After rapid registration process you get social full-featured network: instant messaging, blogs, music, video, photos, and so on..

One feature is a possibility is to change a number of parameters from administrator panel. That gives opportunity without any special software development education create and maintain social network.

Another feature is a possibility for software developers to create additional widgets, change behavior of system, and query and modify data thru RESTful API [http://en.wikipedia.org/wiki/Restful]. At this moment for widgets development only php is supported but Ning developers promise support for all popular languages.
Look on this “hello world” application to understand how you can drive it: [http://developer.ning.com/tutorials/Hello_World]

Extensions development for Ning platform looks like development for CMS systems [http://en.wikipedia.org/wiki/Content_management_system] and based on MVC paradigm [http://en.wikipedia.org/wiki/Model-view-controller].

As unusual approach I can note using of Ning content store[http://developer.ning.com/wiki/The_Ning_Content_Store:_A_Primer]. It is non relative database that looks like ORM systems[http://en.wikipedia.org/wiki/Object-relational_mapping]. I think that using of it is a disputable idea but for novice developers it is easy to understand it.

At the end I want to note main advantages and disadvantages of Ning plarform:

Advantages:

1.Simple an rapid creation of social networks;
2.Free basic access to the system(full abilities but you can’t turn off ads);
3.Big possibilities for modernization and relatively simple API for developers;
4.Quite good documentation;

Disadvantages:

1.Closed platform: we can’t deploy it at any place, we can’t look to source code when we have lack of documentation, we can’t redesign it, it prevent from simultaneous work of developers
2.Commercial platform: if you want to use your own domain name, or remove ads from Ning you should pay;
3.Database approach to store and handle data in DB.;

Conclusion:

This system is a wonderful start for new social networks, or old social networks without big amount of specific functionality.

ONE IMPORTANT note:
we faced disgustful relations of Ning to customers:
making some internal procedures they revoke access to source code from all user, and we lost many time waiting for an access when we have responsibilities against our customers to develop project by some fixed date. Closed platform is an evil !!

On-the-fly compilation in Java6

One of interesting novelty of Java6 is a possibility to access compiler via special API.
Let’s look on this feature a bit closer.

In order to have an access to compilation subsystem we should use classes located at javax.tools package [http://java.sun.com/javase/6/docs/api/javax/tools/package-summary.html].
In the future in this package possibly appear classes to work with different external utilities,
but at this moment we have only access to the compiler.

As simple example let’s look on request to compile:

	JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();

	Iterable<SimpleJavaFileObject> srcList =  Arrays.asList(new SimpleJavaFileObject[]{
		new SimpleJavaFileObject(URI.create("string:///myclass.java"), Kind.SOURCE) {

			@Override
			public CharSequence getCharContent(boolean ignoreEncodingErrors) {
				return "class myclass {}";
			}
		}
	});
       JavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
       compiler.getTask(null, fileManager, null, null, null, srcList).call();

Let’s try to understand how it’s work:

The compiler access input data not directly but via objects inherited form JavaFileObject.
Therefore depending on needs of developer information for compilation can be received from any place:
network, file, memory; for that we need to implement successor of JavaFileObject.
It is better to do it by inheriting class-gag SimpleJavaFileObject

In our example implementation of SimpleJavaFileObject returns source of class as constant string.

It is slightly harder with output data. There is another abstraction layer called JavaFileManager that is
object factory per se.

Standard file manager that we receive in our example let us work with files on the disk. If you need to place output data
on the network on in the memory you need to override JavaFileManager. It is better to do it inheriting
ForwardingJavaFileManager, this class retarget request to provided during creation file manager.
At the same time you can handle only those request that you need.

Last string of example creates compilation command and execute it at once. As a result of execution we have file
in the execution directory of example with name myclass.class that contains bytecode of appropriate class.

It is noteworthy that classloaders of system know nothing about existence of given class and so call
Class.forName(“myclass”) throws ClassNotFoundException.
Let’s complete our example to get class bytecode as byte array. For that we need to implement our own file manager:

public class JavaMemFileManager extends ForwardingJavaFileManager {

	class ClassMemFileObject extends SimpleJavaFileObject {
		ByteArrayOutputStream os = new ByteArrayOutputStream();

		ClassMemFileObject(String className) {
			super(URI.create("mem:///" + className + Kind.CLASS.extension), Kind.CLASS);
		}
		byte[] getBytes() {
			return os.toByteArray();
		}

		@Override
		public OutputStream openOutputStream() throws IOException {
			return os;
		}
	}

	private HashMap<String, ClassMemFileObject> classes =
			new HashMap<String, ClassMemFileObject>();

	public JavaMemFileManager() {
		super(ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null));
	}

	@Override
	public JavaFileObject getJavaFileForOutput(Location location,
			String className, Kind kind, FileObject sibling) throws IOException {
		if (StandardLocation.CLASS_OUTPUT == location && JavaFileObject.Kind.CLASS == kind) {
			ClassMemFileObject clazz = new ClassMemFileObject(className);
			classes.put(className, clazz);
			return clazz;
		} else {
			return super.getJavaFileForOutput(location, className, kind, sibling);
		}
	}

	public byte[] getClassBytes(String className) {
		if (classes.containsKey(className)) {
			return classes.get(className).getBytes();
		}
		return null;
	}
}

As you see our file manager override method getJavaFileForOutput that complier calls to receive output file object.
Here we check destination, for new classes it should be StandardLocation.CLASS_OUTPUT and type.
If it correspond to newly compiled class then we create new file object: we save it and pass it to the compiler.
Then we can receive access to the bytecode with method getClassBytes(className) passing the name of the class.

Let us change previous example to use new functionality:

	....
	JavaFileManager fileManager = new JavaMemFileManager();
	compiler.getTask(null, fileManager, null, null, null, srcList).call();

	byte[] myClassBytes = ((JavaMemFileManager)fileManager).getClassBytes(“myclass”);
	....

And yet one feature of example execution in our case will be absence of file on the disk.

Finally I made a library that makes easier access to Java6 Compiler API.
See details on: [ http://opensource.helion-prime.com/jruntime/ ]

Simplify of web-development with Firefox plug-ins

preamble

There is set of plug-ins that really simplify development process and glance will help you select something for your daily work.

golden list

name: firebug
functions: edit, debug, and monitor CSS, HTML, and JavaScript live
hints: page loading analysis, live working with CSS styles, JavaScript debugger
add-on page: [https://addons.mozilla.org/en-US/firefox/addon/1843]

name: user agent switcher
functions: switch the user agent of the browser
hints: cool but IE, and Firefox still interpret code differently and anyway for interpretation tests you need ‘ies4linux’ [http://www.tatanka.com.br/ies4linux/page/Main_Page]
add-on page: [https://addons.mozilla.org/en-US/firefox/addon/59]

name: firesizer
functions: resize of firefox the window to specific dimensions
hints: it helps to test site in required resolutions
add-on page: [https://addons.mozilla.org/en-US/firefox/addon/5792]

name: SQLite manager
functions: manage SQLite databases
hints: I think you know why it is better to use SQLite DB on workplaces
add-on page: [https://addons.mozilla.org/en-US/firefox/addon/5817]

name: add N edit cookies
functions: allows you add and edit session and saved cookies in live
add-on page: [https://addons.mozilla.org/en-US/firefox/addon/573]

Gem of the day: haml - abstraction markup language

preamble

If you use RoR [http://en.wikipedia.org/wiki/Ruby_on_Rails] then you already know that
ERuby [http://en.wikipedia.org/wiki/ERuby] is pretty enough and you don’t ever think you need something else.

Haml {markup haiku}

Haml is an alternative way to code your “views”. It can be much easier, look on these examples:

XHTML:
<strong class=”code” id=”message”>Hello, World!</strong>

Haml:
%strong{:class => “code”, :id => “message”} Hello, World!

XHTML:
<div id=’content’>
<div class=’left column’>
<h2>Welcome to our site!>/h2>
<p>
<%= print_information %>
</p>
</div>
<div class=”right column”>
<%= render :partial => “sidebar” %>
</div>
</div>

Haml:
#content
.left.column
%h2 Welcome to our site!
%p= print_information
.right.column= render :partial => “sidebar”

like it .. so give you a try with Haml..

haml site: [http://haml.hamptoncatlin.com/]
haml docs: [http://haml.hamptoncatlin.com/docs/]

Setup of Ruby on Rails environment under Debian GNU/Linux

preamble

here you will find just quick-and-dirty hints how to use Ruby on Rails on Debian GNU/Linux platform

ruby and RoR installation

# apt-get install ruby

install ruby gems [http://en.wikipedia.org/wiki/RubyGems]
# apt-get install rubygems

then don’t use ‘rails’ Debian package because it doesn’t work with gem and so gem will not know about it.
you should use gems for that:
# gem install rails –include-dependencies

if you located behind a firewall, export following value before gem using:
HTTP_PROXY=http://[username]:[password]@[proxyserver]:[port]

if you use some IDE like NetBeans [http://en.wikipedia.org/wiki/NetBeans]with Ruby on Rails extension than after installing of ruby and rubygems packages
you can use NetBeans to install ruby extensions

installation of gems that require building of native extensions

some gems are simple set of ruby scripts and then can be just installed
some gems contain source code c/c++ and so before installing of such gems you should have:

**development environment
# apt-get install build-essential

**ruby development header files
# apt-get install ruby-dev

**header files of library that you want to build

for example: you want to have ruby driver for postgresql DB
# apt-get install postgresql-server-dev-8.3
# gem install postgres

enjoy it ..

Fast ways for creation of web-based solutions

preamble

Nowadays business require full-featured cost-effective solutions with short time to market.
I see only 3 approaches to achieve it:

**development platform which allows rapid visual component-based web-applications development
Unfortunately only .Net platform has it at this moment but we try to avoid proprietary [http://en.wikipedia.org/wiki/Proprietary] solutions.

**using of real productive framework Ruby on Rails (RoR) [http://en.wikipedia.org/wiki/Ruby_on_Rails]

**lightweight platform which provide already developed full-featured system that can be easily customized with modules
- CMS (Content Management System) [http://en.wikipedia.org/wiki/Content_management_system]

I want to make a note here: not every CMS can be used as such base platform.
Appropriate platform should contain well-designed API and documentation for extension development as well as
good set of already developed extensions.

Ruby on Rails

RoR gives you an extremely quick way to develop flexible Web applications.
It contains set of useful classes and methods for carrying out the actions most used in Web-based applications, and
provide base structure of project that everyone should follow.

Rails based on 2 principles: Convention over Configuration (CoC) [http://en.wikipedia.org/wiki/Convention_over_Configuration]
and Don’t repeat yourself (DRY) [http://en.wikipedia.org/wiki/Don%27t_repeat_yourself];
uses the Model-View-Controller (MVC) [http://en.wikipedia.org/wiki/Model-view-controller] architecture,
and ActiveRecord [http://en.wikipedia.org/wiki/Active_record_pattern] which maps relational tables to Ruby objects.
I just like it..

Selected CMSs

There are set of different CMSs, and even commercial ones but we should not use them because we have enough cool open source software.

I have reviewed numerous Open-source CMSs for our company to find some noteworthy systems.
Look to this list to understand that we have to select from:
[http://en.wikipedia.org/wiki/Category:Open_source_content_management_systems]

I will not provide you with any comparison due to you can easily find them on the Internet.
There are several platform as base for CMSs: Java, Ruby, Python, PHP

Personally I like Java for strict object-oriented programming methodology, type safety [http://en.wikipedia.org/wiki/Strongly-typed_programming_language],
automatic garbage collection, good design of API, and amount of libraries that almost all are open-source.
But: Java based CMSs are heavy, ugly, and still lack functionality.

Most of wonderful (lightweight, pretty, and full-featured) CMSs are written in PHP, and 2 most cool are:

Joomla! [http://en.wikipedia.org/wiki/Joomla%21]
features list: [http://www.joomla.org/content/view/4483/118/]
documentation: [http://docs.joomla.org/]
api: [http://api.joomla.org/]
list of extensions: [http://extensions.joomla.org/]

Typo3 [http://en.wikipedia.org/wiki/TYPO3]
features list: [http://typo3.com/Feature_list.1243.0.html]
documentation: [http://typo3.org/documentation/]
api: [http://typo3.org/fileadmin/typo3api-4.0.0/]
list of extensions: [http://typo3.org/extensions/]

and at the end of the article I will provide to you one of our last solution based on Joomla!:

project name: car auctions site
rough description: site that provide functionality to purchase cars from auctions, forum to discus details, multi language support,
vote functionality, customized searches.

platform: Joomla! 1.5
template: free template from [http://joomlashack.com]
Joomla extensions:
forum: simplest forum 1.1.4 [http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,3131/Itemid,35/]
Polls: built-in Joomla! 1.5 vote component
localization support: JoomFish 2.0 [http://www.joomfish.net]

men-hours: 110
site URL: http://www.svidcars.com