MVC,MVC,MVC… but how to resist to the bad temptations?

Posted in Quark framework, UI design on August 28th, 2010 by sinica – Be the first to comment

One question that sooner or later  the architects of a MVC framework should ask is how the system will be dealing with creation of error messages and pop-ups.  In Quark,we are trying to be consistent with our philosophy of strict separation and one single sense communication between model,view and controller.  Given that, a simple solution like calling PopUpManager.Show from view,model or controller it is not possible or  a good thing.  Other framework have the luxe of using Facades and Mediators to put code like PopUpManager.Show and do there the dirty work but we want to keep things simple and editable from UI.

Our solution is a bit abstract but it is using the MVC as it should do: there should be always a special place in  model where a controller can add a message or an object instance and that cause automatically the view to show a popup! Basically, we just create a convention and we expect quark’s view components to follow. That special place can be for example a special metadata member for the current data object.

Conclusion: in quark, pop-ups get displayed when they are requested by model or controller by stetting values in metadata and they are never directly displayed using direct calls.

What benefits do we see here?

  • the code needed to create an application is shorter,cleaner and easier to write and maintain
  • the code  for quark based applications have very few dependencies on platform’s APIs,the code is focused on  user’s problems and just follows a few standard conventions to achieve its goals. That will make easy in future to write quark like platforms in Java Script,Silverlight  or any other  technology and having the final application still working perfectly.
  • this is a practical approach for having MDA’s advantages without UML or other abstract and esoteric technologies. We try to minimize even the design patterns we use inside of the framework but should not be a concern for the final user of the framework.

Meta-Data in quark

Posted in Flex, Programming Philosophy, Quark framework, UI design on August 28th, 2010 by sinica – Be the first to comment

As a MVC framework, quark have a nice solution to the control of views using data from  model.

Firstly, we have a convention that every component we display in a quark based application has a model object instance that keeps the status and current configuration of that component. We call those object instances: shadows and we call the shadow classes,those quark classes that describe shadow objects.  That magic of quark is that it automatically creates UI for editing quark classes and in this way we have cheap UI to configure everything in current and future quark components.

The View is responsible for reflecting changes in model and for simplicity and loose coupling we don’t allow direct access of controller to the view . But if there is no direct connection how we control the UI?

Te answer stays in something we call metadata . A meta-data is like a member of an object,except that it is not a member that get persistence or UI. Meta-data can be attached to any quark object or to object members.  We identified a set of standard meta-data but any view component can need a different set of meta-data:

  • ViewState metadata type ( not a very intuitive name,we are still looking for one) is probably the most important type of metadata.  This metadata give a hint to  quark about what shadow clone to use for UI configuration when a class instance  should be  displayed.  It simpler than it looks, basically every class instance in  model should have a ViewState metadata that is a name of a configuration used   to display/edit that object.
  • ReadOnly metadata – an object with this meta-data set is obviously a read only objects
  • Invisible metadata (for fields or objects)
  • Label  metadata – what label get displayed when an object is displayed in a list,etc
  • Icon metadata

We will show how it works  in some demos,soon.

References to class members in PHP

Posted in examples, php code on August 27th, 2010 by sinica – Be the first to comment Tags: ,

We have decided to switch the server-side of Quark Framework 2.0  to the php language. The main reason is that PHP is everywhere,many programmers (and even non programmers) can deal with  it and we can be more agile with PHP than with java. Also the hosting costs for SaaS are lower with PHP.  I did programming for more then 14 years in strongly typed  languages like C,C++,Java,C#,Action Script and I hate that I don’t have types for parameters in php  and I don’t like how strange is PHP occasionally (php references are unlike others in any decent language I’ve ever used, the insane and ugly $this-> is annoying etc ). I’m not a big fan of Php but for what we need it is a rational choice (Don’t forget the unit tests or you are doooomed :) )

Anyway,PHP is serving us well and I’ve decided to share here a small php class that will act like a sort of reference to function members. A closure could solve sometimes the same problem (sort of) but it will not make the code clearer. And it will not work for calling members from another class/instance.

class FunctionRef
{
 	protected $mythis;
 	protected $myFunction;

	public function __construct($mythis,$myFunction)
	 {
	 	$this->mythis = $mythis;
	 	$this->myFunction = $myFunction;
	 }

	 public function call()
	 {
	 	$args = func_get_args();
	 	call_user_func_array(array(&$this->mythis, $this->myFunction), $args);
	 }
}

If you know a better way on doing this in PHP, I will be glad to know.

Internet blackmailing for creating a useful program!?

Posted in Business thoughts, Opinions on August 27th, 2010 by sinica – Be the first to comment Tags: ,

I’ve recently received an email  with this content:

hi
i am BLaCkViRuS
Your program Security is Very Low  < ..link to a rapidshare download page>
If you want we can work together and I have anti-cracking programs that you can do
Have a Nice Day !

He was talking about a program we sell at www.obfusc.com. It was not about security but about how strong the licensing is. That link was to a .exe file that was patching obfusc.exe and removed the licensing checks. Nice and friendly email,isn’t it?

In our backlog we have this sprint a story  about introducing  licensing for of our new product (SensErp based on Quark Framework)  and it is a good moment to express my opinion on licensing and cracking:

  1. I don’t think that anybody in this world can create the perfect anti-cracking and 100% protection system for a code that will run on a computer where he doesn’t have full control (not having hardware under control)
  2. Having people creating cracks for your software it means that your software is good and you have market for it and there are people that love what are you  are doing. I have received many e-mails from customers pleased by using Obfusc Php and that makes me proud and happy (and I make money also, not the salary of a senior programmer or a software manager but enough to consider Obfusc like a decent investment). Obfusc is a good piece of software but the market where it competes is too small for making me a millionaire :)
  3. I don’t think that the licensing system for a software should be very strong. It is better for me if somebody really desperate(out of money,etc)  find a way to solve a problem using my software and not using other software or not solving their problem at all.
  4. I don’t think that people using such cracks do such a big business damage to a software producer. Somebody is very desperate if will run dubious .exe cracks on his computers at a risk of contacting viruses or other malicious piece of software on his computer. It is like having unprotected sex with a prostitute… some people will do it but they are not very smart  if they take such risks.
  5. Some people are greedy,yes,but it is not my problem to solve this issue. Even God looks to have a difficult problem with greedy people :) We will survive and flourish even if some people are unfairly using our software.
  6. People that are creating cracks for software and especially for software created by small companies (like Axiologic) are smart and highly skilled but are not decent persons: they don’t have any morale or ethical justifications for such actions. They will probably pay for it as other people will notice  how they behave.  They will probably loose opportunities for cooperation and they will not even notice that.

What was my answear to  BLaCkViRuS ? Just that: Your offer to help is not acceptable.

Format the text inside a Spark RichEditableText control

Posted in Best practices, Flex on August 26th, 2010 by bogdan – Be the first to comment Tags: , , , , , , , , , , ,

Lately I’ve been working on a code editor, based on Flex 4.1, that should be similar to a modern
editor with the so needed syntax highlighting feature. In order to highlight reserved words, strings
and comments, the text is transformed into tokens, which contain useful information for coloring
such as its position in text, length and the type, used to decide which color should be used to
highlight the token.

Everything went well until formatting RichEditableText to highlight the tokens, which was tricky.
My first implementation was something like the code below :

	for (var i:int = 0; i < tokens.length; i++)
	{
		var tlf:TextLayoutFormat = new TextLayoutFormat();
		tlf.color = tokens[i].color;
		richEditableText.setFormatOfRange(tlf,
			tokens[i].beginIndex, tokens[i].endIndex);
	}

This implementation was way too slow: if I pasted a text with around 125 of words to be colored, it would take up to 19 seconds. That was unbelievable, so I started searching about the performance of setFormatOfRange method. By reading some forums and the source code for RichEditableText class, I noticed that this method triggers update on all the elements of textFlow, which happened for each of those 125 words and dropped so much the speed of formatting and displaying the text.

So to solve this issue, all the format operations should be wrapped into a single one to be executed, and when this is done, trigger the update only once.

Fortunately, the Text Layout Framework provides an API for doing just this through flashx.textLayout.operations package. So I wrapped each format operation into an ApplyFormatOperation, which was added to a CompositeOperation object and executed the latter one.
Below is a sample implementation for my improved solution :

	var compositeFormatOperation:CompositeOperation =
		new CompositeOperation();
	for (var i:int = 0; i < tokens.length; i++)
	{
		var operationState:SelectionState =
			new SelectionState(richEditableText.textFlow,
				tokens[i].beginIndex, tokens[i].endIndex);
		var leafFormat:TextLayoutFormat = new TextLayoutFormat();
		leafFormat.color = tokens[i].color;
		var formatOperation:ApplyFormatOperation =
			new ApplyFormatOperation(operationState,leafFormat,null);
		compositeFormatOperation.addOperation(formatOperation);
	}
	var success:Boolean = compositeFormatOperation.doOperation();
	if (success)
	{
		richEditableText.textFlow.flowComposer.updateAllControllers();
	}

Notice that after the composite operation is executed, I update the textFlow only once.
This improved solution dropped the time from 19 seconds to 0.3 seconds, an 63x improvement that makes
my code editor usable again.

I didn’t use an EditManager because it dispatches TextOperationEvent.CHANGE, which I listen for my RichEditableText. So if text changes, I set color on some tokens by calling applyFormat on EditManager, which send a new TextOperationEvent.CHANGE and I end up in a infinite loop.

There might be better ways of doing this, so I’m open to new suggestions and I hope this post would serve as a starting point for others having similar task with the new text controls inside Flex Spark framework.

For more information on Text Layout Framework you may have a look at this PDF file

One day,the source code for enterprise software could have very little value?

Posted in Business thoughts, Opinions on August 22nd, 2010 by sinica – Be the first to comment

While thinking this weekend on what we are doing with our startup (Axiologic SaaS) I have just realized a  surprising fact:   having better tools and technologies will mean that the value of code will drop as the code will be cheaper to produce. What it the meaning for businesses? But for professional programmers?

Obviously, source code, like anything else, is worth exactly what one person is willing to pay for it but the first signs of a new reality are already  here:  a lot of  code  for enterprise software is available for free ( open source). It is true that lot of current open source code is quite hard to digest,costly to understand and maintain,etc etc. and that is drastically reduce the value of such code ( but it is not my main point for this post :) )

For  big software providers,already is true that the value is not in their source code but in their brand,selling capacity, business models and huge amounts of capital that is rolling apparently forever.  Also,I’m not talking in this post about the value of platform’s source code (like Windows, Flash Player,iOS,etc) or about the source code of the tools,  I’m talking about software dedicated to companies (CRMs,ERPs,etc).

When we started our startup we looked carefully towards open source solutions that we could offer to our customers at a reasonable price. We found some open source software with value but it is not all roses. There are some document management solutions there are good,some  open source CRMs  relatively decent (but too complex and hard to sell and deploy,train),  some open source ERPs that could work  but the cost and risks of adapting such solutions is very high  for an self-booting startup.  We already had some experience trying to build RAD frameworks and we have decided to invest our money and effort for create  better technologies that should  dramatically decrease the overall costs of creating and maintaining enterprise source code.   Huge and very risky step, but hey, so is life itself:).

In  enterprise application we can found at least 4 types of code:

  • database schema modeling code (code in a DDL)
  • business logic code (in rule engines,workflows or OOP code)
  • user interface code
  • platform/framework code (generic code that doesn’t address directly the end users needs)

My believe is that lows of physics will demand that  in the end all applications that require indefinite level of customization in order to get real and consistent business value  will be based on a very strong and customizable platform and a set of open source code (or anyway low value source code)  that will act like configuration for the platform.

The industry is already going in this direction by putting efforts toward MDA or DDD  (I’ve already mentioned in a previous post). Big ERPs and CRMs names from Microsoft or SAP  have such kind of architecture that put some customization in business rules or workflows but these solutions are not even trying to walk on the highest possible peaks. And it makes probably sense for big companies and their customers but puts walls for small and medium companies that should get the best software for their needs at a reasonable cost. Many managers or owners of small and medium companies already have skills to create Excel spreadsheets to create some proto-application for their needs. We are working for a platform to replace those poor quality applications with fully working, professionally looking and fully customizable business applications at a fraction from current software developmental costs (hopefully almost the same costs like creation of a few spreadsheets).

In the end, a nice picture with one of the highest peaks in Oriental Carpathian mountains (a peak I have just visited this weekend)

Peak Toaca,Ceahlau

Peak Toaca,Ceahlau

Flex unit testing without a Serial Number for Flash Builder 4 PREMIUM

Posted in Flex, Q&A on August 17th, 2010 by bogdan – 1 Comment Tags: , , , , ,

Flash Builder 4 comes in 2 flavors: Standard Edition and Premium. With Standard Edition you can’t run unit tests inside Eclipse. If you’re reading this post then I guess you’re looking for an easy and free way of unit testing your flex application. There is a easy way of doing this. All you have to do is create a project, add some swc libraries and set up unit testing.

For a Flex 4.1 environment, you’ll need to add flexunit-core-flex-4.1.0 and flexunit-uilistener-4.1.0 libraries to your project, write test classes and suite class to include the tests, and in the end you should write a little code to Default Application file.

Here is a sample unit testing project you can look over.

The whole post was meant to be short and provide a simple, but reliable way of unit testing in Flex.
For more details and more advanced features you can check out the official website.

DictionaryCollection – a mix between Dictionary and ArrayCollection

Posted in Flex, Quark framework on August 16th, 2010 by bogdan – Be the first to comment Tags: , , ,

One day I came across a task which involved using some sort of collection that was bindable
and could store and retrieve data like a dictionary does. And soon I got a new task : to build
such a data type.

Practically I needed a mix between Dictionary and ArrayCollection, so my first idea was to
extend Proxy, in order to access and retrieve data using square brackets, and after that to
create similar methods to ArrayCollection. But after looking over the source code of ArrayCollection,
I’ve noticed it inherits Proxy, due to ListCollectionView inheritance, which saved me from the classic
‘reinventing the wheel’ and led me to improving the wheel instead.

My plan was to modify the methods of ArrayCollection so it adds/removes links to the added/removed
objects and this way they could be retrieved later.It was pretty straightforward to override the methods
and add/remove references to items,which were stored in a Dictionary. It was also easy because I didn’t have to override each method as some of them are reused. For example, addItem  just calls addItemAt.

Besides this basic functionality, I thought it would be useful to add one more feature : adding and
removing references to items based on given properties. Let’s say you add objects with
quantity, price and label properties, using the plain addItem method and you still want to retrieve
them using square brackets. You can do this, but first you have to decide which properties should be
the keys that references to the object. Below is an example for more clarity.

// here I declare an empty DictionaryCollection and set the label property as a key field
var a:DictionaryCollection = new DictionaryCollection(null,"label");
a.addItem({label: "Bread", price: "2", quantity: "1"});
a.addItem({label: "Butter", price: "3", quantity: "2"});
a.addItem({label: "Tea bags", price: "1", quantity: "4"});
a["Jam"] = {label: "Jam", price: "4", quantity: "1"};
// now I can retrieve each object based on its label
trace(a.getItemByKey("Butter").price);   // 3
trace(a["Tea bags"].quantity);             // 4
trace(a["Jam"].label); 			     //	Jam

I hope this code snippet explains pretty well how a DictionaryCollection can be used and you can download it following the link below. I also included the test class for unit testing.

DictionaryCollection

As a conclusion, I’m happy that reading the source code of Flex saved me hours of work and helped me to build a custom data type that should blend seamlessly with the framework.

Models,Models?,Models!

Posted in Best practices, Programming Philosophy, Quark framework on August 15th, 2010 by sinica – Be the first to comment

The  model is the central part of any MVC application.  But what exactly the models are? Simplistically,one can see the model as  database schemas plus some data structures that reflect data from databases at runtime.

I have tried this “simple” approach in the past frameworks (even in Quark 1.0) and we used classes that mimics the usual OOP classes that languages as Java or Action Script provides by default.  In Quark 2.0 we have created a new XML based, OOP language that we call Quark Schema that is providing support for nice and useful models:

  • declaratively describe the persistence and the life of the objects
  • declaratively describe the constraints, validation and relations between model’s objects
  • describe class behavior
  • is fully editable using GUI tools that we are currently building

We found that we can discern 6 categories of objects (they are not orthogonal categories ):

  • transient objects – objects that exists only at runtime in one instance of the application and should not be saved in a persistent storage
  • globally persistent objects: objects with global identity (even for different users )
  • locally persistent objects : objects that have no global identity but have a local identity inside of a global or transient object
  • relational objects – objects that mimic the structure of relational tables
  • document objects – graph of objects that contain other objects
  • shadow objects -objects that doesn’t contain user data but inner information of the system.  Example of shadow objects : configurations and the structure of the view. Shadows get automatically generated and one  is doing customization by using visual tools organically embedded in the application but it doesn’t care much about shadow’s structure.

    Observations:
  • Global objects that contains other local objects (or are persistence roots for graph of objects as we call it ) should be seen as complex documents structured as graphs that can be used as configurations or data structures. Quark Framework allows you to describe models in the form of normal “relational” objects or in form of  ”document” objects.
  • Document objects can be seen as relational objects with fields that are root for trees containing local objects  serialized as XML strings.
  • Shadow documents are usually document objects.
  • Transient objects can be global or local
  • Members of classes can be declared  transient and will not be present in the database schema but their values get serialized depending of their declaration as  local,global( or created as transient objects or no)
  • We have discovered that local objects have an interesting property: when they are assigned to a member of a class member from a different persistence root (different persistence global root object) they should be automatically cloned.   Quark Schema is automatically doing just that and we discovered that is nice and useful in real cases.

Apparently all these rules and observations are a bit complex, fortunately the business user will use a simple UI to create such classes (models) and should not worry much about persistence aspects.  It will just communicate his intentions and the system will do “the magic”. Local objects are usually shadow objects and will be a concern for component creators and rarely for the business users (customers or consultants).

This article is long enough so I will not present  any syntax but I want to mention only that for Quark 2.0 we have got all these aspects working and well tested with unit testing.  Drop me an email for any questions.

At the end, take a look at this picture that is saying: “the model should be fat but it should be constructed with skinny,elegant and nicely shaped classes”:

Creating  above picture piece by piece is  a laborious process. For me, it took 1 minute to create using Google search for images and a screenshot. Similarly, our goal is to create a tool that  will allow  creation of a working business application in minutes and we believe that we are not far from it! A new direction I’m contemplating now is to have  Quark Framework  as a tool for creation of mashup applications [1] with data from multiple business applications. It is a logical use of Quark and fortunately it results from our design,without much supplementary programming work.

References:

[1] http://en.wikipedia.org/wiki/Mashup_(web_application_hybrid)

Quark Framework 1.0 release

Posted in Flex, Java, Quark framework on August 12th, 2010 by cmanolescu – Be the first to comment

We are happy to make a public release of Quark Framework 1.0.

For the last couple of  months we have been working on Quark 2.0 and we’ve decided to have Quark Framework 1.0 released under LGPL license.

Quark RAD Framework comprises two key components – a core library written in Java  (which provides the basic server side persistence and authentication  services that are required by most applications) and a set of flex classes so developers can easily use to rapidly engineer UI of the applications.

As we are working for 2.0, we discontinued support for 1.0 (except fixing things required for applications we build with 1.0) On the other hand, if you are a good Java and Flex hacker you could find good piece of code to reuse in your applications.

Documentation for 1.0 is scarce as we focus on explaining and documenting 2.0.

Download Source |  Binary