Saturday, April 14, 2018

Self Mission

OK, so this blog has been stale for so long that i do not wish to disclose "how long" i am talking about.

So, I was watching the Julie and Julia movie and thought so self, this is a real good plan, expect for taking a sick leave from office and posting about it online part, lets give it a try.

Hence, I have challenged myself to post a blog post at least once a week till end of this year.
As they say in Mission Impossible movie, "Good morning, Mr. Hunt. Your mission, should you choose to accept it, involves posting a blog post once a week till Christmas. This message will self-destruct in five seconds"

Friday, March 2, 2018

Why and When to use Padding vs. Margin


To me the biggest difference between padding and margin is that vertical margins auto-collapse, and padding doesn't. Consider two elements one above the other each with padding of 1em. This padding is considered to be part of the element, and is always preserved. So you will end up with the content of the first element, followed by the padding of the first element, followed by the padding of the second, followed by the content of the second element. Thus content of the two elements will end up being 2em apart.

Now replace that padding with 1em margin. Margins are considered to be outside of the element, and margins of adjacent items will overlap. So in this example you will end up with the content of the first element followed by 1em of combined margin followed by the content of the second element. So the content of the two elements is only 1em apart.

This can be really useful when you know that you want say 1em of spacing around an element, regardless of what element it is next to.




The other big difference is that padding is included in the click region and background color/image, but not the margin. Hence padding can be used to add more space around the anchor text of a text link in order to be better clickable on handheld devices; this cannot be done with margin since it adds space outside of the box where the contents (the anchor text) lie.

Since margin is on the outside of block elements while padding is on the inside, I tend to follow these usage guidelines:

  • Use margin to separate the block from things outside it
  • Use padding to move the contents away from the edges of the block.
TL;DR: By default I use margin everywhere, except when I have a border or background and want to increase the space inside that visible box.
 


Margin Padding
1  considered to be outside of the element considered to be part/inside of the element
2  vertical margins auto-collapse They do not collapse, never!!
3  Its outside the element, so wont work like this included in the click region and background color/image




2014 - Year of Custom ROM's

Hello!!
I see there are no posts for a full year. That's bad, it shows I  haven’t learnt anything new. But thats not completely true. I have been abusing my 18month old Sony Xperia-U with a variety of custom roms.

It all started with the unlocking problems; that button got so broken that i was barely able to use my mobile. Cutting the chase, i have used below OS so far.


Sunday, November 10, 2013

Bob, What's this CLOB and BLOB?

The main differences between BLOB and CLOB are:
  • BLOB stores values as LOB (Large OBject) in bitstreams.
  • CLOB stores values as LOB (Large OBject) in character steams.
CLOBs are for text like XML, JSON, etc. You should not assume what encoding the database will store it as (at least in an application) as it will be converted to whatever encoding the database was configured to use.

BLOBs are for binary data. You can be reasonably assured that they will be stored how you send them and that you will get them back with exactly the same data as they were sent as.


CLOB is encoding and collation sensitive, BLOB is not.

When you write into a CLOB using, say, CL8WIN1251, you write a 0xC0 (which is Cyrillic letter А).
When you read data back using AL16UTF16, you get back 0x0410, which is a UTF16 representation of this letter.

If you were reading from a BLOB, you would get same 0xC0 back.

Wednesday, July 3, 2013

Tail Call Optimization

A tail call is a subroutine call that happens inside another procedure as its final action; it may produce a return value which is then immediately returned by the calling procedure. The call site is then said to be in tail position, i.e. at the end of the calling procedure.

Tail because it has to happen as the very last operation in a function, or as the function's tail operation. Call because that last operation is calling a function. Making tail calls can sometimes (though not by any means always) require support from your platform's calling conventions, linker, and run-time library. It also needs a non-trivial amount of effort in the compilers that support it.

There's also a more restricted version, called tail recursion, which only happens if a function, as its last operation, returns the result of calling itself. Tail recursion is easier to deal with because rather than having to jump to the beginning of some random function somewhere, you just do a goto back to the beginning of yourself, which is a darned simple thing to do.

A recursive function is tail recursive if the final result of the recursive call is the final result of the function itself.  If the result of the recursive call must be further processed (say, by adding 1 to it, or consing another element onto the beginning of it), it is not tail recursive. Tail calls need not be recursive.

Tail calls are significant because they can be implemented without adding a new stack frame to the call stack. Most of the frame of the current procedure is not needed any more, and it can be replaced by the frame of the tail call, modified as appropriate (similar to overlay for processes, but for function calls). The program can then jump to the called subroutine. Producing such code instead of a standard call sequence is called tail call elimination, or tail call optimization. Tail call elimination allows procedure calls in tail position to be implemented as efficiently as goto statements, thus allowing efficient structured programming.

When a function is called, the computer must "remember" the place it was called from, the return address, so that it can return to that location with the result once the call is complete. Typically, this information is saved on the call stack, a simple list of return locations in order of the times that the call locations they describe were reached. For tail calls, there is no need to remember the place we are calling from – instead, we can perform tail call elimination by leaving the stack alone (except possibly for function arguments and local variables), and the newly called function will return its result directly to the original caller. The tail call doesn't have to appear lexically after all other statements in the source code; it is only important that the calling function return immediately after the tail call, returning the tail call's result if any, since the calling function will never get a chance to do anything after the call if the optimization is performed.

For non-recursive function calls, this is usually an optimization that saves little time and space, since there are not that many different functions available to call. When dealing with recursive or mutually recursive functions where recursion happens through tail calls, however, the stack space and the number of returns saved can grow to be very significant, since a function can call itself, directly or indirectly, creating new call stacks each iteration. It often asymptotically reduces stack space requirements from linear, or O(n), to constant, or O(1).

Besides space and execution efficiency, tail call elimination is important in the functional programming idiom known as continuation passing style (CPS), which would otherwise quickly run out of stack space.

Friday, October 26, 2012

Demangling the namemangling

Found an awesome command today. Thanks to the "symbol not found" error. As usual i was debugging using "nm" command. It tells me if a symbol is present or not, but it doesn't tell me what that symbol stands for.

tada...thats where "c++filt" comes to rescue.

The C++ and Java languages provides function overloading, which means that you can write many functions with the same name (providing each takes parameters of different types). All C++ and Java function names are encoded into a low-level assembly label (this process is known as mangling). The c++filt program does the inverse mapping: it decodes (demangles) low-level names into user-level names so that the linker can keep these overloaded functions from clashing.

Every alphanumeric word (consisting of letters, digits, underscores, dollars, or periods) seen in the input is a potential label. If the label decodes into a C++ name, the C++ name replaces the low-level name in the output.

$ c++filt -n -s gnu-v3 _ZN8BcastMsg10mBroadcastE6AppMsgz
BcastMsg::mBroadcast(AppMsg, ...)
 

Ain't she beautiful?

Tuesday, September 11, 2012

Software Maintenance

In the matter of reforming things, as distinct from deforming them, there is one plain and simple principle; a principle which will probably be called a paradox. There exists in such a case a certain institution or law; let us say, for the sake of simplicity, a fence or gate erected across a road. The more modern type of reformer goes gaily up to it and says, “I don’t see the use of this; let us clear it away.” To which the more intelligent type of reformer will do well to answer: “If you don’t see the use of it, I certainly won’t let you clear it away. Go away and think. Then, when you can come back and tell me that you do see the use of it, I may allow you to destroy it.”

This paradox rests on the most elementary common sense. The gate or fence did not grow there. … Some person had some reason for thinking it would be a good thing for somebody. And until we know what the reason was, we really cannot judge whether the reason was reasonable. It is extremely probable that we have overlooked some whole aspect of the question, if something set up by human beings like ourselves seems to be entirely meaningless and mysterious. There are reformers who get over this difficulty by assuming that all their fathers were fools; but if that be so, we can only say that folly appears to be a hereditary disease. … If he knows how it arose, and what purposes it was supposed to serve, he may really be able to say that they were bad purposes, that they have since become bad purposes, or that they are purposes which are no longer served.

Monday, July 16, 2012

The difference between hard and soft links

Unix files consist of two parts: the data part and the filename part.
The data part is associated with something called an 'inode'. The inode carries the map of where the data is, the file permissions, etc. for the data.
                               .---------------> ! data ! ! data ! etc
                              /                  +------+ !------+
        ! permbits, etc ! data addresses !
        +------------inode---------------+

The filename part carries a name and an associated inode number.
                         .--------------> ! permbits, etc ! addresses !
                        /                 +---------inode-------------+
        ! filename ! inode # !
        +--------------------+
More than one filename can reference the same inode number; these files are said to be 'hard linked' together.
        ! filename ! inode # !
        +--------------------+
                        \
                         >--------------> ! permbits, etc ! addresses !
                        /                 +---------inode-------------+
        ! othername ! inode # !
        +---------------------+
On the other hand, there's a special file type whose data part carries a path to another file. Since it is a special file, the OS recognizes the data as a path, and redirects opens, reads, and writes so that, instead of accessing the data within the special file, they access the data in the file named by the data in the special file. This special file is called a 'soft link' or a 'symbolic link' (aka a 'symlink').
        ! filename ! inode # !
        +--------------------+
                        \
                         .-------> ! permbits, etc ! addresses !
                                   +---------inode-------------+
                                                      /
                                                     /
                                                    /
    .----------------------------------------------'
   ( 
    '-->  !"/path/to/some/other/file"! 
          +---------data-------------+
                  /                      }
    .~ ~ ~ ~ ~ ~ ~                       }-- (redirected at open() time)
   (                                     }
    '~~> ! filename ! inode # !
         +--------------------+
                         \
                          '------------> ! permbits, etc ! addresses !
                                         +---------inode-------------+
                                                            /
                                                           /
     .----------------------------------------------------'
    (
     '->  ! data !  ! data ! etc.
          +------+  +------+ 

Now, the filename part of the file is stored in a special file of its own along with the filename parts of other files; this special file is called a directory. The directory, as a file, is just an array of filename parts of other files.
When a directory is built, it is initially populated with the filename parts of two special files: the '.' and '..' files. The filename part for the '.' file is populated with the inode# of the directory file in which the entry has been made; '.' is a hardlink to the file that implements the current directory.
The filename part for the '..' file is populated with the inode# of the directory file that contains the filename part of the current directory file. '..' is a hardlink to the file that implements the immediate parent of the current directory.
The 'ln' command knows how to build hardlinks and softlinks; the 'mkdir' command knows how to build directories (the OS takes care of the above hardlinks).
There are restrictions on what can be hardlinked (both links must reside on the same filesystem, the source file must exist, etc.) that are not applicable to softlinks (source and target can be on seperate file systems, source does not have to exist, etc.). OTOH, softlinks have other restrictions not shared by hardlinks (additional I/O necessary to complete file access, additional storage taken up by softlink file's data, etc.)
In other words, there's tradeoffs with each.


Now, let's demonstrate some of this...

ln in action

Let's start off with an empty directory, and create a file in it
~/directory $ ls -lia 
total 3
  73477 drwxr-xr-x   2 lpitcher users        1024 Mar 11 20:16 .
  91804 drwxr-xr-x  29 lpitcher users        2048 Mar 11 20:16 ..

~/directory $ echo "This is a file" >basic.file

~/directory $ ls -lia 
total 4
  73477 drwxr-xr-x   2 lpitcher users        1024 Mar 11 20:17 .
  91804 drwxr-xr-x  29 lpitcher users        2048 Mar 11 20:16 ..
  73478 -rw-r--r--   1 lpitcher users          15 Mar 11 20:17 basic.file

~/directory $ cat basic.file
This is a file 
Now, let's make a hardlink to the file
~/directory $ ln basic.file hardlink.file

~/directory $ ls -lia 
total 5
  73477 drwxr-xr-x   2 lpitcher users        1024 Mar 11 20:20 .
  91804 drwxr-xr-x  29 lpitcher users        2048 Mar 11 20:18 ..
  73478 -rw-r--r--   2 lpitcher users          15 Mar 11 20:17 basic.file
  73478 -rw-r--r--   2 lpitcher users          15 Mar 11 20:17 hardlink.file

~/directory $ cat hardlink.file
This is a file
We see that:
  1. hardlink.file shares the same inode (73478) as basic.file
  2. hardlink.file shares the same data as basic.file
If we change the permissions on basic.file:
~/directory $ chmod a+w basic.file

~/directory $ ls -lia 
total 5
  73477 drwxr-xr-x   2 lpitcher users        1024 Mar 11 20:20 .
  91804 drwxr-xr-x  29 lpitcher users        2048 Mar 11 20:18 ..
  73478 -rw-rw-rw-   2 lpitcher users          15 Mar 11 20:17 basic.file
  73478 -rw-rw-rw-   2 lpitcher users          15 Mar 11 20:17 hardlink.file

 then the same permissions change on hardlink.file.
The two files (basic.file and hardlink.file) share the same inode and data, but have different file names.
Let's now make a softlink to the original file:
~/directory $ ln -s basic.file softlink.file

~/directory $ ls -lia 
total 5
  73477 drwxr-xr-x   2 lpitcher users        1024 Mar 11 20:24 .
  91804 drwxr-xr-x  29 lpitcher users        2048 Mar 11 20:18 ..
  73478 -rw-rw-rw-   2 lpitcher users          15 Mar 11 20:17 basic.file
  73478 -rw-rw-rw-   2 lpitcher users          15 Mar 11 20:17 hardlink.file
  73479 lrwxrwxrwx   1 lpitcher users          10 Mar 11 20:24 softlink.file -> basic.file

~/directory $ cat softlink.file
This is a file 
Here, we see that although softlink.file accesses the same data as basic.file and hardlink.file, it does not share the same inode (73479 vs 73478), nor does it exhibit the same file permissions. It does show a new permission bit: the 'l' (softlink) bit.
If we delete basic.file:
~/directory $ rm basic.file

~/directory $ ls -lia 
total 4
  73477 drwxr-xr-x   2 lpitcher users        1024 Mar 11 20:27 .
  91804 drwxr-xr-x  29 lpitcher users        2048 Mar 11 20:18 ..
  73478 -rw-rw-rw-   1 lpitcher users          15 Mar 11 20:17 hardlink.file
  73479 lrwxrwxrwx   1 lpitcher users          10 Mar 11 20:24 softlink.file -> basic.file
then we lose the ability to access the linked data through the softlink:
~/directory $ cat softlink.file
cat: softlink.file: No such file or directory
However, we still have access to the original data through the hardlink:
~/directory $ cat hardlink.file
This is a file
You will notice that when we deleted the original file, the hardlink didn't vanish. Similarly, if we had deleted the softlink, the original file wouldn't have vanished. 

There are two major limitations of hardlinks. In these cases, you must use a softlink:
  1. A link across filesystems
  2. Because a hardlink is a direct reference to the underlying filesystem, you can’t hardlink across filesystems.
  3. Linking to a directory
  4. You can’t use a hardlink to link to a directory.
In the cases listed above, you must use a softlink because a hardlink simply won’t work. There are also cases where softlinks are preferable to hardlinks, even though either will work. For example, you’d probably want to pick a softlink when you want to create a shortcut especially when the destination of that shortcut might change in the future. For example, if you have a launcher to a beta version of an application, you may wish to use a softlink so you can easily change the target of the link between versions.
In most of the remaining cases (creating a link to a file on the same filesystem), hardlinks can be preferable for the following major reasons:
  1. Performance
  2. There is a slight performance boost to be gained from using hardlinks. This is because since a hardlink references a spot on disk, rather than referencing another another file (which then references the actual spot on disk you want), there is one less disk seek involved in hardlinking.
  3. Storage space
  4. Hardlinks don’t take up any additional space, since they are simply a reference to an already existing space of disk. Creating a softlink is creating a new file, and will consume a small amount (usually 4KB) of space on your filesystem.
    Additionally, hardlinks are preferable because a softlink is vulnerable to losing the ‘master’ instance of a file (the file to which all the softlinks point). If the original file is deleted, then all softlinks to it become invalid. With a hardlink, you can delete any of the instances, including the original, and as long as at least one instance exists the file will remain on the system.

Wednesday, July 11, 2012

bash-prompts

PS1 – Default interaction prompt
PS2 – Continuation interactive prompt
PS3 – Prompt used by “select” inside shell script
PS4 – Used by “set -x” to prefix tracing output 
 
\a     an ASCII bell character (07)
\d     the date in "Weekday Month Date" format (e.g., "Tue May 26")
\D{format}
       the format is passed to strftime(3) and the result is inserted into
       the prompt string; an empty format results in a locale-specific time
       representation. The braces are required
\e     an ASCII escape character (033)
\h     the hostname up to the first `.'
\H     the hostname
\j     the number of jobs currently managed by the shell
\l     the basename of the shell's terminal device name
\n     newline
\r     carriage return
\s     the name of the shell, the basename of $0 (the portion following
       the final slash)
\t     the current time in 24-hour HH:MM:SS format
\T     the current time in 12-hour HH:MM:SS format
\@     the current time in 12-hour am/pm format
\A     the current time in 24-hour HH:MM format
\u     the username of the current user
\v     the version of bash (e.g., 2.00)
\V     the release of bash, version + patch level (e.g., 2.00.0)
\w     the current working directory, with $HOME abbreviated with a tilde
       (uses the value of the PROMPT_DIRTRIM variable)
\W     the basename of the current working directory, with $HOME
       abbreviated with a tilde
\!     the history number of this command
\#     the command number of this command
\$     if the effective UID is 0, a #, otherwise a $
\nnn   the character corresponding to the octal number nnn
\\     a backslash
\[     begin a sequence of non-printing characters, which could be used to
       embed a terminal control sequence into the prompt
\]     end a sequence of non-printing characters 
 
PS1='\[\e[31m\]\u\[\e[0m\]'

Broken down, the opening sequence works as follows:
  • \[ -- Open a series of non-printing characters, in this case, an escape sequence.
  • \e -- An ASCII escape character, used to confer special meaning to the characters that follow it, normally to control the terminal rather than to enter any characters.
  • [31m -- Defines a display attribute, corresponding to foreground red, for the text to follow; opened with a [ character and terminated with an m.
  • \] — Close the series of non-printing characters.
The terminating sequence is very similar, except it uses the 0 display attribute to reset the text that follows back to the terminal defaults.
The valid display attributes for 16-color terminals are:
  • Style
    • 0 — Reset all attributes
    • 1 — Bright
    • 2 — Dim
    • 4 — Underscore
    • 5 — Blink
    • 7 — Reverse
    • 8 — Hidden
  • Foreground
    • 30 — Black
    • 31 — Red
    • 32 — Green
    • 33 — Yellow
    • 34 — Blue
    • 35 — Magenta
    • 36 — Cyan
    • 37 — White
  • Background
    • 40 — Black
    • 41 — Red
    • 42 — Green
    • 43 — Yellow
    • 44 — Blue
    • 45 — Magenta
    • 46 — Cyan
    • 47 — White

Saturday, April 7, 2012

The Java: An Overview

Introduction

The Java programming language and environment is designed to solve a number of problems in modern programming practice. Java started as a part of a larger project to develop advanced software for consumer electronics. These devices are small, reliable, portable, distributed, real-time embedded systems. When we started the project we intended to use C++, but encountered a number of problems. Initially these were just compiler technology problems, but as time passed more problems emerged that were best solved by changing the language.

Java

Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture neutral, portable, high-performance, multithreaded, dynamic language.
One way to characterize a system is with a set of buzzwords. We use a standard set of them in describing Java. Here's an explanation of what we mean by those buzzwords and the problems we were trying to solve.
Archimedes Inc. is a fictitious software company that produces software to teach about basic physics. This software is designed to interact with the user, providing not only text and illustrations in the manner of a traditional textbook, but also a set of software lab benches on which experiments can be set up and their behavior simulated. The most basic experiment allows students to put together levers and pulleys and see how they act. The italicized narrative of the trials and tribulations of the Archimedes' designers is used here to provide examples of Java language concepts.

Simple

We wanted to build a system that could be programmed easily without a lot of esoteric training and which leveraged today's standard practice. Most programmers working these days use C, and most programmers doing object-oriented programming use C++. So even though we found that C++ was unsuitable, we designed Java as closely to C++ as possible in order to make the system more comprehensible.
Java omits many rarely used, poorly understood, confusing features of C++ that in our experience bring more grief than benefit. These omitted features primarily consist of operator overloading (although the Java language does have method overloading), multiple inheritance, and extensive automatic coercions.
We added automatic garbage collection, thereby simplifying the task of Java programming but making the system somewhat more complicated. A common source of complexity in many C and C++ applications is storage management: the allocation and freeing of memory. By virtue of having automatic garbage collection (periodic freeing of memory not being referenced) the Java language not only makes the programming task easier, it also dramatically cuts down on bugs.
The folks at Archimedes wanted to spend their time thinking about levers and pulleys, but instead spent a lot of time on mundane programming tasks. Their central expertise was teaching, not programming. One of the most complicated of these programming tasks was figuring out where memory was being wasted across their 20K lines of code.
Another aspect of being simple is being small. One of the goals of Java is to enable the construction of software that can run stand-alone in small machines. The Java interpreter and standard libraries have a small footprint. A small size is important for use in embedded systems and so Java can be easily downloaded over the net.

Object-Oriented

This is, unfortunately, one of the most overused buzzwords in the industry. But object-oriented design is very powerful because it facilitates the clean definition of interfaces and makes it possible to provide reusable "software ICs."
Simply stated, object-oriented design is a technique that focuses design on the data (=objects) and on the interfaces to it. To make an analogy with carpentry, an "object-oriented" carpenter would be mostly concerned with the chair he was building, and secondarily with the tools used to make it; a "non-object-oriented" carpenter would think primarily of his tools. Object-oriented design is also the mechanism for defining how modules "plug and play."
The object-oriented facilities of Java are essentially those of C++, with extensions from Objective C for more dynamic method resolution.
The folks at Archimedes had lots of things in their simulation, among them ropes and elastic bands. In their initial C version of the product, they ended up with a pretty big system because they had to write separate software for describing ropes versus elastic bands. When they rewrote their application in an object-oriented style, they found they could define one basic object that represented the common aspects of ropes and elastic bands, and then ropes and elastic bands were defined as variations (subclasses) of the basic type. When it came time to add chains, it was a snap because they could build on what had been written before, rather than writing a whole new object simulation.

Network-Savvy

Java has an extensive library of routines for coping easily with TCP/IP protocols like HTTP and FTP. This makes creating network connections much easier than in C or C++. Java applications can open and access objects across the net via URLs with the same ease that programmers are used to when accessing a local file system.
The folks at Archimedes initially built their stuff for CD ROM. But they had some ideas for interactive learning games that they wanted to try out for their next product. For example, they wanted to allow students on different computers to cooperate in building a machine to be simulated. But all the networking systems they'd seen were complicated and required esoteric software specialists. So they gave up.

Robust

Java is intended for writing programs that must be reliable in a variety of ways. Java puts a lot of emphasis on early checking for possible problems, later dynamic (runtime) checking, and eliminating situations that are error prone.
One of the advantages of a strongly typed language (like C++) is that it allows extensive compile-time checking so bugs can be found early. Unfortunately, C++ inherits a number of loopholes in compile-time checking from C, which is relatively lax (particularly method/procedure declarations). In Java, we require declarations and do not support C-style implicit declarations.
The linker understands the type system and repeats many of the type checks done by the compiler to guard against version mismatch problems.
The single biggest difference between Java and C/C++ is that Java has a pointer model that eliminates the possibility of overwriting memory and corrupting data. Instead of pointer arithmetic, Java has true arrays. This allows subscript checking to be performed. In addition, it is not possible to turn an arbitrary integer into a pointer by casting.
The folks at Archimedes had their application basically working in C pretty quickly. But their schedule kept slipping because of all the small bugs that kept slipping through. They had lots of trouble with memory corruption, versions out-of-sync and interface mismatches. What they gained because C let them pull strange tricks in their code, they paid for in quality assurance time. They also had to reissue their software after the first release because of all the bugs that slipped through.
While Java doesn't make the QA problem go away, it does make it significantly easier.
Very dynamic languages like Lisp, TCL and Smalltalk are often used for prototyping. One of the reasons for their success at this is that they are very robust: you don't have to worry about freeing or corrupting memory. Java programmers can be relatively fearless about dealing with memory because they don't have to worry about it getting corrupted. Because there are no pointers in Java, programs can't accidentally overwrite the end of a memory buffer. Java programs also cannot gain unauthorized access to memory, which could happen in C or C++.
One reason that dynamic languages are good for prototyping is that they don't require you to pin down decisions too early. Java uses another approach to solve this dilemma; Java forces you to make choices explicitly because it has static typing, which the compiler enforces. Along with these choices comes a lot of assistance: you can write method invocations and if you get something wrong, you are informed about it at compile time. You don't have to worry about method invocation error.

Secure

Java is intended for use in networked/distributed environments. Toward that end, a lot of emphasis has been placed on security. Java enables the construction of virus-free, tamper-free systems. The authentication techniques are based on public-key encryption.
There is a strong interplay between "robust" and "secure." For example, the changes to the semantics of pointers make it impossible for applications to forge access to data structures or to access private data in objects that they do not have access to. This closes the door on most activities of viruses.
Someone wrote an interesting "patch" to the PC version of the Archimedes system. They posted this patch to one of the major bulletin boards. Since it was easily available and added some interesting features to the system, lots of people downloaded it. It hadn't been checked out by the folks at Archimedes, but it seemed to work. Until the next April 1st, when thousands of folks discovered rude pictures popping up in their children's lessons. Needless to say, even though they were in no way responsible for the incident, the folks at Archimedes still had a lot of damage to control.

Architecture Neutral

Java was designed to support applications on networks. In general, networks are composed of a variety of systems with a variety of CPU and operating system architectures. To enable a Java application to execute anywhere on the network, the compiler generates an architecture-neutral object file format--the compiled code is executable on many processors, given the presence of the Java runtime system.
This is useful not only for networks but also for single system software distribution. In the present personal computer market, application writers have to produce versions of their application that are compatible with the IBM PC and with the Apple Macintosh. With the PC market (through Windows/NT) diversifying into many CPU architectures, and Apple moving off the 680x0 toward the PowerPC, production of software that runs on all platforms becomes nearly impossible. With Java, the same version of the application runs on all platforms.
The Java compiler does this by generating bytecode instructions which have nothing to do with a particular computer architecture. Rather, they are designed to be both easy to interpret on any machine and easily translated into native machine code on the fly.
Archimedes is a small company. They started out producing their software for the PC since that was the largest market. After a while, they were a large enough company that they could afford to do a port to the Macintosh, but it was a pretty big effort and didn't really pay off. They couldn't afford to port to the PowerPC Macintosh or MIPS NT machine. They couldn't "catch the new wave" as it was happening, and a competitor jumped in...

Portable

Being architecture neutral is a big chunk of being portable, but there's more to it than that. Unlike C and C++, there are no "implementation dependent" aspects of the specification. The sizes of the primitive data types are specified, as is the behavior of arithmetic on them. For example, "int" always means a signed two's complement 32 bit integer, and "float" always means a 32-bit IEEE 754 floating point number. Making these choices is feasible in this day and age because essentially all interesting CPUs share these characteristics.
The libraries that are a part of the system define portable interfaces. For example, there is an abstract Window class and implementations of it for Unix, Windows NT/95, and the Macintosh.
The Java system itself is quite portable. The compiler is written in Java and the runtime is written in ANSI C with a clean portability boundary. The portability boundary is essentially a POSIX subset.

Interpreted

Java bytecodes are translated on the fly to native machine instructions (interpreted) and not stored anywhere. And since linking is a more incremental and lightweight process, the development process can be much more rapid and exploratory.
As a part of the bytecode stream, more compile-time information is carried over and available at runtime. This is what the linker's type checks are based on. It also makes programs more amenable to debugging.
The programmers at Archimedes spent a lot of time waiting for programs to compile and link. They also spent a lot of time tracking down senseless bugs because some changed source files didn't get compiled (despite using a fancy "make" facility), which caused version mismatches; and they had to track down procedures that were declared inconsistently in various parts of their programs. Another couple of months lost in the schedule.

High Performance

While the performance of interpreted bytecodes is usually more than adequate, there are situations where higher performance is required. The bytecodes can be translated on the fly (at runtime) into machine code for the particular CPU the application is running on. For those accustomed to the normal design of a compiler and dynamic loader, this is somewhat like putting the final machine code generator in the dynamic loader.
The bytecode format was designed with generating machine codes in mind, so the actual process of generating machine code is generally simple. Efficient code is produced: the compiler does automatic register allocation and some optimization when it produces the bytecodes.
In interpreted code we're getting about 300,000 method calls per second on an Sun Microsystems SPARCStation 10. The performance of bytecodes converted to machine code is almost indistinguishable from native C or C++.
When Archimedes was starting up, they did a prototype in Smalltalk. This impressed the investors enough that they got funded, but it didn't really help them produce their product: in order to make their simulations fast enough and the system small enough, it had to be rewritten in C.

Multithreaded

There are many things going on at the same time in the world around us. Multithreading is a way of building applications with multiple threads[1] Unfortunately, writing programs that deal with many things happening at once can be much more difficult than writing in the conventional single-threaded C and C++ style.
Java has a sophisticated set of synchronization primitives that are based on the widely used monitor and condition variable paradigm introduced by C.A.R.Hoare[2]. By integrating these concepts into the language (rather than only in classes) they become much easier to use and are more robust. Much of the style of this integration came from Xerox's Cedar/Mesa system.
Other benefits of multithreading are better interactive responsiveness and real-time behavior. This is limited, however, by the underlying platform: stand-alone Java runtime environments have good real-time behavior. Running on top of other systems like Unix, Windows, the Macintosh, or Windows NT limits the real-time responsiveness to that of the underlying system.
Lots of things were going on at once in their simulations. Ropes were being pulled, wheels were turning, levers were rocking, and input from the user was being tracked. Because they had to write all this in a single threaded form, all the things that happen at the same time, even though they had nothing to do with each other, had to be manually intermixed. Using an "event loop" made things a little cleaner, but it was still a mess. The system became fragile and hard to understand. They were pulling in data from all over the net. But originally they were doing it one chunk at a time. This serialized network communication was very slow. When they converted to a multithreaded style, it was trivial to overlap all of their network communication.

Dynamic

In a number of ways, Java is a more dynamic language than C or C++. It was designed to adapt to an evolving environment.
For example, one major problem with C++ in a production environment is a side-effect of the way that code is implemented. If company A produces a class library (a library of plug and play components) and company B buys it and uses it in their product, then if A changes its library and distributes a new release, B will almost certainly have to recompile and redistribute their own software. In an environment where the end user gets A and B's software independently (say A is an OS vendor and B is an application vendor) problems can result.
For example, if A distributes an upgrade to its libraries, then all of the software from B will break. It is possible to avoid this problem in C++, but it is extraordinarily difficult and it effectively means not using any of the language's OO features directly.
Archimedes built their product using the object-oriented graphics library from 3DPC Inc. 3DPC released a new version of the graphics library which several computer manufacturers bundled with their new machines. Customers of Archimedes that bought these new machines discovered to their dismay that their old software no longer worked. (In real life, backwards compatibility isn't always a high priority in the Unix world. In the PC world, 3DPC would never have released such a library: their ability to change their product and use C++'s object oriented features is severely hindered because they can't expect their customers to recompile.)
By making these interconnections between modules later, Java completely avoids these problems and makes the use of the object-oriented paradigm much more straightforward. Libraries can freely add new methods and instance variables without any effect on their clients.
An interface specifies a set of methods that an object can perform but leaves open how the object should implement those methods. A class implements an interface by implementing all the methods contained in the interface. In contrast, inheritance by subclassing passes both a set of methods and their implementations from superclass to subclass. A Java class can implement multiple interfaces but can only inherit from a single superclass. Interfaces promote flexibility and reusability in code by connecting objects in terms of what they can do rather than how they do it.
Classes have a runtime representation: there is a class named Class, instances of which contain runtime class definitions. If, in a C or C++ program, you have a pointer to an object but you don't know what type of object it is, there is no way to find out. However, in Java, finding out based on the runtime type information is straightforward. Because casts are checked at both compile-time and runtime, you can trust a cast in Java. On the other hand, in C and C++, the compiler just trusts that you're doing the right thing.
It is also possible to look up the definition of a class given a string containing its name. This means that you can compute a data type name and have it easily dynamically-linked into the running system.
To expand their revenue stream, the folks at Archimedes wanted to architect their product so that new aftermarket plug-in modules could be added to extend the system. This was possible on the PC, but just barely. They had to hire a couple of new programmers because it was so complicated. This also added problems when debugging.

Why Standard Java is not considered appropriate for hard real-time applications

When people hear about real-time computing they often make the mistake of thinking that these have to be fast systems and are nearly always used for control of mechanical systems. It is true that in most cases the response times required are fast, but speed is not what defines a real-time system. The true core of a real-time environment is that the system will guarantee to perform some task within a pre-defined time so that the system's behaviour becomes fully deterministic.

For enterprise class applications what are the advantages (and possibly disadvantages) of deployment on a real-time system? In many cases there is no great advantage. Once the non-functional requirements of a system (load capacity, average response time, peak-load response time, and so on) have been met the application can be deployed and the customer is satisfied. Should something happen that makes a request to, say, an HR application take rather longer than usual the user simply has to wait longer; there is no measurable impact. However, for many financial, enterprise class applications failing to do something within a given time can easily be equated to a cost, possibly a very large one. Financial markets, by their very definition, are extremely volatile and computer trading systems mean that prices can change at the rate of many times a second. If one part of a system decides to make a trade based on the current price and the actual trade gets delayed for whatever reason even a small change can result in a significant loss of money. If this delay happens frequently the system soon becomes less of an advantage and more of a liability.

Java, the language, and the Java Enterprise Edition platform have proved to be very popular for the development of enterprise applications. The ease-of-development, performance and reliability all make Java extremely attractive to developers. However, the Java platform does not support real-time applications, and even running a Java application on a real-time operating system will not make the application deterministic. The biggest obstacle to deterministic behaviour of a Java application is the way memory management is handled by the Java virtual machine (JVM). Unlike earlier languages like C and C++ Java uses a garbage collector to reclaim memory that is no longer being used by an application. The reason for this is to eliminate ‘memory leaks', where a developer forgets to explicitly free memory that is no longer being used. Since the amount of memory in a machine is finite, if this error occurs in some kind of loop eventually the system will run out of memory. (That's not to say you can completely eliminate memory leaks in Java; if a developer maintains references to objects the garbage collector will still not be able to reclaim the memory).

The garbage collector uses a background thread to monitor the heap space where objects are stored. The garbage collector identifies objects that are no longer referenced and reclaim the unused memory. Much of this work involves copying objects from one address to another within the heap. To prevent the possible corruption of data all application threads (referred to as mutator threads) must be paused when this is happening. On modern JVMs these pauses will not be noticeable for well tuned desktop applications. Even for most enterprise applications the use of the concurrent-mark-sweep collector (also known as the low-pause collector) will reduce pauses to levels that are acceptable for most applications. However, for certain classes of enterprise applications like those described earlier, non-deterministic behaviour and therefore Java is not suitable.

To solve this problem a Java Specification Request (JSR) was created to design and implement a real-time specification for Java (RTSJ). This was, in fact, the very first JSR created under the Java Community Process when it was started in 1998. The expert group had several guiding principals in the creation of the specification. Three of these principals are worth noting when considering the applicability to enterprise applications:
  1. Backwards compatibility, so that any class file generated by a Java compliant compiler would run on a RTSJ virtual machine.
  2. No syntactic extensions. No new keywords or syntactic changes would be made to the Java language. This is partly a result of the first point, but is also essential to enable Java developers to easily migrate to RTSJ and use existing development tools such as NetBeans.
  3. Predictable execution. This would be the first priority when making design decisions. The impact of this is that sometimes the typical computing performance may be reduced. This is one reason that an RTSJ system should be considered carefully for general enterprise applications.
The RTSJ specification describes eight areas of extended semantics for Java:
  1. Scheduling
  2. Memory management
  3. Synchronization
  4. Asynchronous event handling
  5. Asynchronous transfer of control
  6. Asynchronous thread termination
  7. Physical memory access
  8. Exceptions
Threads within the RTSJ can be one of three types, non real-time, soft real-time and hard real-time. A non real-time thread is somewhat obvious, in that it does not have a specific deadline when some action must be completed. It can be scheduled when convenient by the JVM and any impact of the garbage collector is immaterial. Soft real-time threads are ones that do have a deadline for completion of an action. However, there is a certain amount of leeway so that if the action gets completed shortly after when it should have done everything will still continue without any problems. For hard real-time threads they absolutely must complete the action by the deadline; if they do not an unrecoverable error has occurred. RTSJ applications can have threads of all three types running simultaneously. The choice of what type of thread to use is down to the designer of the application and the level of importance attached to the work of a thread. The diagram below shows the relationship between these types of threads:



Diagram 1. Threads in the RTJS

Typically threads will need to exchange data for the application to work. Since a hard real-time thread cannot rely on a non real-time thread to deliver results in real-time wait-free data transfer queues are used to ensure that a hard real-time thread is not blocked by other threads.

To create a new non real-time thread the existing Thread class is used unchanged. For soft real-time threads the RealtimeThread class is used, which is a sub-class of Thread. The constructor of this class takes optional priority and release parameters to define how the JVM should schedule the thread. For hard real-time threads the NoHeapRealtimeThread class is used which is a sub-class of RealtimeThread. The name of the class used for hard real-time threads probably gives you a clue about how it is implemented by the JVM; we'll discuss this more when we get to memory management.

The simplest way to convert an existing application to be a real-time application is to simply change all places where a new thread is started to use the RealtimeThread class instead. This would only make the application a soft real-time application, but shows how easy it can be.

The standard Java Thread class includes the concept of a priority so that more important threads can be given preference to lower priority ones. In RTSJ this is extended further and the specification says that there must be at least twenty eight distinct priority levels supported. Since the priority is represented as an integer an implementation could provide many more. The specification also says that threads of a higher priority will always run in preference to those of a lower priority and if a thread with a higher priority becomes runnable it will pre-empt the currently running thread. The classes used to represent this information are shown in diagram 2:

Diagram 2. Thread execution priorities

The PriorityParameters class encapsulates the integer value of the threads priority. If there are multiple threads with the same priority an importance can be associated with the thread to indicate which thread should be given preference.

One of the key concepts of a real-time system is that it should be possible, in advance, to determine whether the system can meet the requirements of the application. In order to do that, through rate monotonic analysis, the system must know details about the tasks. These are provided to the RTSJ through release parameters. The class hierarchy is shown in diagram 3:

Diagram 3. Release parameters

The ReleaseParameters class contains the cost of the thread in terms of time (which is platform specific and may change if the application is moved to a different platform), the deadline for when this task must be completed and handlers for both a cost overrun and a missed deadline. The types of task that will be processed can be either periodic, in which case they happen repeatedly at a given rate, or aperiodic in which case they could happen at any time. If a hard real-time system contains aperiodic tasks it is impossible to analyse for correctness so the concept of a sporadic task is included. This treats an aperiodic task as if it was periodic, giving it a minimum frequency and therefore making it possible to analyse the system. Making an aperiodic task sporadic has no impact to the way the application runs, it just enables the system to determine whether it can meet the real-time requirements.
The RTSJ must also implement what is called priority inversion avoidance. Diagram 4 illustrates the problem:

Diagram 4. Priority inversion

A low priority thread (at priority P3) acquires the lock on an object and is pre-empted by a higher priority thread (at priority P1), as the specification mandates. The P1 thread then needs the same object but cannot acquire the lock until the P3 thread has released it. Other tasks that are lower priority (P2) prevent the P3 thread from running and releasing the lock. The net effect is that P2 priority threads run in preference to the P1 thread which is not what the specification requires. There are two ways to avoid this. The first is priority inheritance. The system detects that the P3 thread is holding a lock required by the P1 thread and elevates its priority to P1 until the lock is released. This works with no changes to the code by the developer. The second way is priority ceiling emulation. Here the developer must realise that the thread holding the lock needs its priority raised and must put explicit calls in the code to do this. This method is optional in the RTSJ.
For memory management RTSJ uses the concept of a memory area. The class structure for this is shown in diagram 5.

Diagram 5. Real time memory areas

Since garbage collection causes non-deterministic pauses all hard real-time threads must use memory that is not subject to garbage collection. There are two ways to do this: scoped memory and immortal memory.

Scoped memory is memory that has a lifetime defined by the developer of an application. A developer will create a scoped memory area of a specific size and when objects are instantiated the space for them will be allocated from this area. There are two types of scoped memory, linear and variable which refers to the time required to instantiate an object. The LTMemory class represents an area of memory where the time to instantiate an object is the combination of a fixed allocation time and a variable initialisation time. Since the initialisation time is directly proportional to the size of the object the time is linear rather than constant. The VTMemory class represents an area of memory where the allocation mechanism can use any algorithm and hence can vary in time. Once all objects in the scoped memory are no longer referenced the memory is freed to be used again. One scenario for the use of scoped memory is to create a scoped memory area and provide it for use by a NoHeapRealTimeThread. When the thread execution finishes all objects are known to no longer be referenced and the area can be freed.

Immortal memory, as the name suggests, never gets collected in any way. Immortal memory is shared by all threads and should only be used for objects that the developer knows will exist until the JVM terminates.

The RTSJ specification also allows developers to do something that is impossible in standard Java: access physical memory directly. Since this is mostly applicable to embedded real-time applications and not enterprise applications we won't discuss this further in this article.

As you can see the RTSJ provides a range of capabilities to allow an enterprise application to run as a combination of non real-time, soft real-time and hard real-time threads. For financial applications where time is money the critical sections can be coded to run as hard real-time threads and avoid the non-deterministic behaviour of the garbage collector. With the release of RTSJ 2.0 a reference implementation is now available that runs on the freely available, open source Solaris 10 operating environment which has a real-time scheduler. (To provide real-time functionality in the JVM the operating system underneath must also support the concepts of real-time).

The obvious next step for enterprise applications is to use a real-time capable application server. Engineers at Sun have ported the GlassFish open source application server to RTSJ (in only five hours). IBM also has a real-time WebSphere product so progress has already been made. When evaluating the use of real-time Java for your enterprise application remember that, in this situation, nothing is free. You may get guaranteed response time, but this will come at the cost of overall throughput of the system. However, if your Java application really, really must respond within a certain time regardless of what the garbage collector does, RTSJ is now a possibility rather than a probability.

Saturday, March 31, 2012

bash - alias, function and script

In Bash, when to alias, when to script, and when to write a function is as trivial as important it is. Here is a look at the underlying implementation, the "why" behind the "what".

aliases and functions
  • are stored in memory (once they are read).
  • When invoked, they are read from memory and executed by the current shell.
Note that aliases and functions are grouped together for their similarities despite being functionally different.

scripts
  • are stored in files. If the script is located in a $PATH directory, many shells store a hash of its pathname to save time on future $PATH lookups.
  • When invoked, they are read from files (i.e. file I/O takes place), and executed by a subshell (i.e. a fork() will occur), unless sourced directly.
What does this mean? Ideal candidates for functions and aliases are commands that are very frequently used and very short, i.e. the type of things that you want to keep in memory and execute in the current shell for speed (although most OS's will cache commonly used files in memory). Ideal candidates for scripts are very long sequences of commands that are very rarely used, i.e. the type of things you don't want or need to permanently take up memory. A good example is initialization command sequences that only run once. 

This could be important for performance -- function is faster, since it doesn't fork() and exec(). In normal circumstances, the difference is trivial, but if you are debugging a system that is out of memory and is page-thrashing, it could make a big difference.

Also, if you want to modify your current shell environment, you should use a function. For example, a function could change the command lookup $PATH for the current shell, but a script cannot, because it operates on a fork/exec copy of $PATH.

With that said, these considerations probably will not make much of a difference on most modern systems with average memory space and disk speeds. However, if you are ever developing scripts for systems with more extreme requirements (like tiny amounts of RAM or uncommon permanent storage media types), it may be useful to keep them in mind. Also, the difference between scripts and functions might be noticeable if you execute them a very large number of times in a row, like iterating over a long file list or a bunch of lines in very long file. Chances are, the function / alias will run faster because it does not need to fork a process or read a disk file, although again, OS-level caching and other optimizations may reduce the differences somewhat.

PS: According to Bash Reference Manual
"For almost every purpose, shell functions are preferred over aliases."

Thursday, March 8, 2012

OLTP vs. OLAP

We can divide IT systems into transactional (OLTP) and analytical (OLAP). In general we can assume that OLTP systems provide source data to data warehouses, whereas OLAP systems help to analyze it. 

OLTP (On-line Transaction Processing) is characterized by a large number of short on-line transactions (INSERT, UPDATE, DELETE). The main emphasis for OLTP systems is put on very fast query processing, maintaining data integrity in multi-access environments and an effectiveness measured by number of transactions per second. In OLTP database there is detailed and current data, and schema used to store transactional databases is the entity model (usually 3NF).

OLAP (On-line Analytical Processing) is characterized by relatively low volume of transactions. Queries are often very complex and involve aggregations. For OLAP systems a response time is an effectiveness measure. OLAP applications are widely used by Data Mining techniques. In OLAP database there is aggregated, historical data, stored in multi-dimensional schemas (usually star schema).

The following table summarizes the major differences between OLTP and OLAP system design.



OLTP System
Online Transaction Processing
(Operational System)

OLAP System
Online Analytical Processing
(Data Warehouse)

Source of data
Operational data; OLTPs are the original source of the data.
Consolidation data; OLAP data comes from the various OLTP Databases
Purpose of data
To control and run fundamental business tasks
To help with planning, problem solving, and decision support
What the data
Reveals a snapshot of ongoing business processes
Multi-dimensional views of various kinds of business activities
Inserts and Updates
Short and fast inserts and updates initiated by end users
Periodic long-running batch jobs refresh the data
Queries
Relatively standardized and simple queries Returning relatively few records
Often complex queries involving aggregations
Processing Speed
Typically very fast
Depends on the amount of data involved; batch data refreshes and complex queries may take many hours; query speed can be improved by creating indexes
Space Requirements
Can be relatively small if historical data is archived
Larger due to the existence of aggregation structures and history data; requires more indexes than OLTP
Database Design
Highly normalized with many tables
Typically de-normalized with fewer tables; use of star and/or snowflake schemas
Backup and Recovery
Backup religiously; operational data is critical to run the business, data loss is likely to entail significant monetary loss and legal liability
Instead of regular backups, some environments may consider simply reloading the OLTP data as a recovery method



Comparison of Bill Inmon and Ralph Kimball paradigm:

In the data warehousing field, we often hear about discussions on where a person / organization's philosophy falls into Bill Inmon's camp or into Ralph Kimball's camp. We describe below the difference between the two.

Bill Inmon's paradigm: Data warehouse is one part of the overall business intelligence system. An enterprise has one data warehouse, and data marts source their information from the data warehouse. In the data warehouse, information is stored in 3rd normal form.

Bill Inmon: Endorses a Top-Down design
Independent data marts cannot comprise an effective EDW. Organizations must focus on building EDW.
"You can catch all the minnows in the ocean and stack them together and they still do not make a whale,"
Bill Inmon, January 8, 1998.

Ralph Kimball's paradigm: Data warehouse is the conglomerate of all data marts within the enterprise . Information is always stored in the dimensional model.
Kimball model also proposes the data warehouse bus architecture. This architecture is comprised of:
  • A staging area (which can have an E/R or relationally designed 3NF design or flat file format), which cannot be accessed by an end-user of the data warehouse bus (Presentation Layer) .
  • The Data Warehouse Bus itself which includes several atomic data marts, several aggregated data marts and a personal data mart but no single or centralized data warehouse component.
The Data Warehouse Bus:
  • Is dimensional;
  • Contains transaction and summary data;
  • Includes data marts, which have single subject or fact tables; and
  • Can consist of multiple data marts in a single data base.
There is no right or wrong between these two ideas, as they represent different data warehousing philosophies. In reality, the data warehouse in most enterprises are closer to Ralph Kimball's idea. This is because most data warehouses started out as a departmental effort, and hence they originated as a data mart. Only when more data marts are built later do they evolve into a data warehouse.

Ralph Kimball: Endorses a Bottom-Up design
EDW effectively grows up around many of the several independent data marts – such as for sales, inventory, or marketing
"...The data warehouse is nothing more than the union of all the data marts...,"
Ralph Kimball, December 29, 1997.

 
The main difference is Top-Down vs. Bottom-Up Approach.

Advantages of Top-Down Approach: [Bill Inmon Approach]:
  • A truly corporate effort, an enterprise view of data
  • Inherently architect ed- not a union of disparate DataMarts
  • Central rules and control
  • May be developed fast using iterative approach
Disadvantages of Top-Down [Bill Inmon Approach]:
  • Takes longer to build even with iterative method
  • High exposure/risk to failure
  • Needs high level of cross functional skills
  • High outlay without proof of concept
  • Difficult to sell this approach to senior management and sponsors
Advantages of Bottom-Up Approach [Ralph Kimball Approach]:
  • Faster and easier implementation of manageable pieces
  • Favorable ROI and proof of concept
  • Less risk of failure
  • Inherently incremental; can schedule important DataMarts first
  • Allows project team to learn and grow
Disadvantages of Bottom-Up Approach [Ralph Kimball Approach]:
  • Each DataMart has its own narrow view of data
  • Permeates redundant data in every DataMart
  • Difficult to integrate if the overall requirements are not considered in the beginning
Kimball encourages to have perspective of both “vertically” and “horizontally”
while gathering business requirements while developing/designing data marts using Bus Architecture to integrate in to Enterprise Data warehouse.

Vertical
  • Don’t just rely on the business data analyst to determine requirements
  • Inputs from senior managers about their vision, objectives, and challenges are critical
  • Ignoring this vertical span might cause failure in understanding the organization’s direction and likely future trends
Horizontal
  • Look horizontally across the departments before designing the Data Warehouse
  • Critical in establishing the enterprise view i.e Bus Architecture
  • Challenging to do if one particular department if funding the project. [Even one departments funds this project , but all the departments together become the company]
  • Ignoring horizontal span will create isolated, department-centric databases that are inconsistent and can’t be integrated while considering for Enterprise Data Warehouse
  • Complete coverage in a large organization is difficult , but CEO or CTO represents all of the departments. They should have the proper understanding of the full business and recommend what is good for whole company not just one department.
  • One rep. from each dept. interacting with the core development team can be of immense help
  • Creating a Business Decision Making group when there is a difference in the perspective from each department would help in resolve these kind of conflicts.
New Practical approach by Kimball
  • Plan and define requirements at the overall corporate level
  • Create a surrounding architecture for a complete warehouse
  • Conform and standardize the data content
  • Implement the Data Warehouse as a series of Supermarts, one at a time

SUPERMARTS
  • Totally monolithic approach vs. totally stovepipe approach
  • A step-by-step approach for building an Enterprise Data Warehouse from granular data
  • A Supermart s a data mart that has been carefully built with a disciplined architectural framework
  • A Supermart is naturally a complete subset of the Data Warehouse.
  • A Supermart is based on the most granular data that can possible be collected and stored
  • Conformed dimensions and standardized fact definitions