Johan Broddfelt
/* Comments on code */

Better tools, better code

Why DataFlex

This is the first post on the topic about DataFlex where I'm primarily going to add the videos from my Discovering DataFlex videos on youtube. So if you can not wait for my next post, then go ahead and watch some more videos there. I'll try to not only rewrite what I'm talking about in the video, but also add some additional comments to the video so that it's easier to use as a reference.

To start this topic of I show you this talk I made, where I compare different development platforms I have used in order to argue why I like the DataFlex way of doing things. Even though I'm not as fluent in DataFlex as I am in php it's easy for me to create a complete application within a couple of hours. And I also have plans on making a video where I create an entire mobile application in 30 minutes. But that is for another post.

The argument I'm making in this video is that DataFlex is easier to maintain and faster to develop in than any of the other platforms could ever be. Because of the way DataFlex is designed. That said, the other programing languages are not in any way bad. And if you, as me, are fluent in one of them it might be a bit hard to switch to DataFlex. But I'm here to help ;) DataFlex is not the preferred platform for building games nor applications that require extreme speed. But it really does a good job when it comes to building business applications.

Benifits explained

The thing that DataFlex does that no other language does, except perhaps JavaScript, is that it has declared objects in code. This was really confusing for me in the beginning, because I kept confusing classes with objects because the where created in a similar way in the code. The only thing is that the procedures inside a class was only accessible if the class was instantiated. But the procedures declared inside of objects... Yes, inside of objects. Were available at run time by interacting with the object.

This is how the code would look in a regular application.

// view
My Form <input name="my_form" value="">
<input type="submit" name="my_btn" value="My button">

// controller
frm = new Form("my_form");
btn = new Button("my_btn");
btn->onClick() {
  frm->update();
}

// model
class Form {
  var value = "";
  function init($name) {
     // Some code to find the element and bind an event handler
     onChange();
  }
  function onChange() {
  }
  function update($string) {
    $this->value = $string;
  }
}
class Button {
  var label = "Button";
  function init($name) {
     // Some code to find the element and bind an event handler
     onClick();
  }
  function onClick() {
  }
}

These three segments, the view, the controller and the model is also often stored in three or more separate files and if you do a change in one of them, it often means that you also need to modify the other two.
Here is how the same code would be written in DataFlex

// view
This is generated by the DataFlex engine. So we do not write any code here.

// controller
Object frm is a Form
  Set label to "My Form"
  Set value to ""
End_Object

Object btn is a Button
  Set label to "Button"
  
  Procedure onClick
    Set value of frm to "Test"
  End_Procedure
End_Object

// model
Form and Button two in a list of predefined view objects, so even if we could write more complex behaviours here,
we do not need it for this simple sample.

This is a lot cleaner and easier to maintain. All is in one file and even the layout is declared inside of the objects. So you can set things like disabled, height, width, x-pos, y-pos, value, and a lot more depending on which object and if we are writing for windows, web or mobile.

Another smart feature of the DataFlex way of doing things is the DataDictionaries. That keep track of all table relations for you and ensure that you are not breaking any rules of your database. And 90% of this is done for you, automatically by these DataDictionaries.
This way of managing data is the thing that inspired me to build my framework the way I have done. But it is not nearly as complex as the DataFlex way of doing things.
Then we have all the prefabricated controlls, such as forms, dateforms, buttons, lists, grids and the list goes on, that will generate the code nessacery to display these controlls in windows, web or as touch controls in web for mobile, so that you only have to deal with pure DataFlex code in your code base.

I hope that this first post about DataFlex has sparked an interrest in you to take a look at it. And you can actually Download DataFlex for free for personal use and follow me as I show you how to build rich business applications in DataFlex.

- dataflex, introduction, software

Follow using RSS

Installing DataFlex >>

Comment

Name
Mail (Not public)
Send mail uppdates on new comments
0 comment