Design decisions for validation

I am looking for the right place to validate the input in a textfield basically in Java. This is specific for a MVC based construct. The main question to be answered is: is the validation part of the model or the view. Let’s have a look at the view.

What are the advantages if the validation is in the view? What are the disadvantages?
One of the advantages is the relative easy and quick access to the UI component, e.g. a JTextfield. With the according listener it is possible to react on each character entered into the field. This would led to a fast solution. The big caveat would be to violate the principle of the MVC pattern. We would have business logic in the view component. When I think more about this behavior we would even be against the single responsibility principle. A class should have only one reason to exist.
One further caveat will be to enter the validation code for every component, I think here of forms, in this view as a inner class. This would led to a violation of the DRY principle. DRY stands for Don’t repeat yourself. One of the advantages of this is that the view don’t has to communicate with the according model over a server or something like an internal messaging system this would led to a simpler implementation of the system.

What would happen when the validation occurs in the model?
Advantages of this is a clear separation of the behavior. It would be possible to reuse all the validation code for various view parts. What is the price to get to this point? There would be an overhead to get to this point, e.g. we need some kind of a message system to use to communicate between the view and the model. This will be needed in every case because of the nature of this kind of pattern. If the system is huge we can run in some timing problem when the server connection isn’t fast. But in a local system it should be an appropriate way to communicate. In my opinion and with my knowledge I would consider the right place for the validation somewhere in a model component.

Book log

I was converting some pdf files to epub with Calibre when I discovered an old entry of Michael Fogus. Back in 2007 he wrote on his blog about books he have read. It was more a kind of a dairy what he had read in this year. This led me to the following question: Is it worth to write a book journal? And the second question: What kind of format could this be? And last what information is it worth to collect?

Let me answer the second question first. In my opinion this could be a simple page in a journal which states in a chronological manner what I have read. Why a journal and not a fancy program? I believe sometimes you can only win if you have the ability to write something in a easy way with colors, mindmaps, different drawings. This work is much easier with pen and paper than with electronic stuff.

The third question what should noted. For me the answer is:

  • the author
  • how do I like this book
  • a kind of classification
  • the duration for reading

The reason for this introduction? I made a sticky note to myself ‘Note the books read’. At this time I was very busy and days became weeks and weeks became months and I started to go through my old notes again and found this sticky note. I needed almost a week to get out what I intended to do. In the meantime I started my book journal. My experience so far? Not really much. But this is only the beginning. I have some long time reading books. One of them is ‘How to read a book’ from Mortimer J. Adler and Charles Van Doren. Why is this a long time reading book? If I will take full advantages of this book I will read as mentioned in the book. Many reading techniques will be uncovered, e.g. pigeon holing, X-raying a book, coming to terms with the author, and many more. The whole fourth part of this book is about syntopical reading. This means how are the various subjects interconnected. This is the point where I hope my journal will help me. Interconnect my reading and my knowledge.

Notetaking

The idea of the structured note taking with org-mode was depend on the following link The most impressive point was the structure which he uses as base for the notes. After short research I discovered that I have installed a very similar structure about 1 and 1/2 years ago. The bad thing is I have missed to use it completely. This leads me to a small improvement step: Use my structure and export all the needed information with c-c c-e h Simple expressed: this leads to an export as a html file. The next logical step for me was the creation of a Master.org page. On this page all my pages where linked together. What is missing now is a link or menu on every page. So that I can switch to other pages as I need them. Fun isn’t it?

Some days later I had do rename my Master.org. The reason are very simple. Most start pages which are viewed through a web browser are called index.htm. So this is more a common way to name this proper.

Frames and EMACS

I’m a EMACS user since several years. And still there are features to (re)discover. Today I looked for a easy method to switch between frames. The obvious way is to use C-x 5 o. This is basically the same as C-x o to switch between windows.

In this stackoverflow questions is a package called framemove.el mentioned. If you install this you got as default key-bindings shift and arrow or meta and arrow to move between frames. I don’t think that this are very good bindings because shift and arrow is a way to mark some text and meta and arrow is to move a whole word at one time. I thing many windows user are trained to use this shortcuts on a daily base. I’m aware, that the same functionality in EMACS is bound to meta-f meta-b for movements between words and c-f and c-b to move for one character. But some muscle memory won’t be erased in a easy way

Hello World

My very first blog post 🙂 I’m not sure what I will say in this blog. Not yet. I think it will get a documentation on my journey as a pragmatic software developer. With some hints about how I will use Emacs as my editor of choice, about books I have read and will read, about agile themes. And so on. For the moment I don’t know exactly where my journey will lend me. But as said Bilbo Baggins in Lord of the Rings:

The road goes ever on and on
Down from the road where it began.

Fixing org-mobile-push

After update to the new version of org-mode (7.8.06) the function org-mobile-push didn’t work as expected. After a more or less lengthy search I found the solution on the following link

It seems that one necessary correction isn’t present on the 7.8 branch. After applying the changes mentioned it worked as expected.

On 02/01/2012 01:58 AM, Greg Troxel wrote:
>
> The following fix is in org master, but not in 7.8.  I am able to use
> org-mobile-push.
>
>
> commit 71089b7e3b00736f854d6e95a52229853262e12a
> Author: Bastien Guerry<bzg <at> altern.org>
> Date:   Wed Jan 4 16:37:59 2012 +0100
>
>      org-mobile.el (org-mobile-push): Use `org-agenda-tag-filter'.
>
>      * org-mobile.el (org-mobile-push): Use `org-agenda-tag-filter'
>      instead of the obsolete `org-agenda-filter'.
>
>      Thanks to Charles Sebold for reporting this.
>
> diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el
> index b049f4e..bcc1c90 100644
> --- a/lisp/org-mobile.el
> +++ b/lisp/org-mobile.el
> @@ -303,7 +303,7 @@ create all custom agenda views, for upload to the mobile phone."
>     (interactive)
>     (let ((a-buffer (get-buffer org-agenda-buffer-name)))
>       (let ((org-agenda-buffer-name "*SUMO*")
> -     (org-agenda-filter org-agenda-filter)
> +     (org-agenda-tag-filter org-agenda-tag-filter)
>       (org-agenda-redo-command org-agenda-redo-command))
>         (save-excursion
>     (save-window-excursion

According to the comments this should be done in the main branch. For later versions this shouldn’t be a problem.

Setup org-2-blog for my installation

Since I’m a little bit lazy and I really prefer Emacs as text editor I was looking for an easy solution to publish my blog entries out of Emacs. My entry to search for a solution was the blog of Sacha Chua. She uses EMACS as well and had done some improvements in the directions of simplify the workflow with org-mode. In an old blog entry I found the solution to my needs.

The next step was the installation of org2blog and xml-rpc since this two tools are needed to get the automatism to work.

After that I only have to configure my ~./emacs like this:

(require 'org2blog-autoloads)
(setq org2blog/wp-blog-alist
   '(("wordpress"
      :url "http://btd67.com/xmlrpc.php"
      :username "btd67"
      :tags-as-categories t)))