Thursday, December 31, 2009

A scrollbar (Also known as a handle in the very first GUIs) is a graphical object in a GUI with which continuous text, pictures or anything else can be scrolled including time in video applications, i.e., viewed even if it does not fit into the space in a computer display, window, or viewport.


A scrollbar (Also known as a handle in the very first GUIs) is a graphical object in a GUI with which continuous text, pictures or anything else can be scrolled including time in video applications, i.e., viewed even if it does not fit into the space in a computer display, window, or viewport.

Usually designed as a long rectangular area on one or two sides of the viewing area, containing a bar (or thumb) that can be dragged along a trough (or track) to move the body of the document as well as two arrows on either end for precise adjustments. The "thumb" has different names in different environments: on the Macintosh it is called a "scroller"; on the Java platform it is called "thumb" or "knob"; Microsoft's .NET documentation refers to it as "scroll box" or "scroll thumb"; in other environments it is called "elevator", "quint", "puck", "wiper" or "grip". Additional functions may be found, such as zooming in/out or various application-specific tools. The thumb can also sometimes be adjusted by dragging its ends. In this case it would adjust both the position and the zooming of the document, where the size of the thumb represents the degree of zooming applied. A thumb that completely fills the trough indicates that the entire document is being viewed, at which point the scrollbar may temporarily become hidden.

Scrollbars can be seen as a computer representation of a thumb, with which you thumb through pages of documents.

A scrollbar should be distinguished from a slider which is another object that works in a similar fashion, the difference being that the slider is used to change values, and does not change the display or move the area that is shown.

Well, it's my own term - not one that you will see in any Java textbook. I use it to refer to a variety of input items in a Java applet, such as buttons (which you have already met) scroll bars, text fields and text areas. The following Java applet shows a few of these:

We have already met buttons, so I shan't be talking much about them here. Like buttons, scroll bars, text areas etc. are automatically placed as close to the top of the screen as possible, and in the centre. As you add more, they gradually fill up the screen downwards. Here is the code for the applet above:

import java.applet.*;
import java.awt.*;

public class furn1 extends Applet
{ public Scrollbar my_bar;
public TextField my_textline;
public TextArea my_blurb;

public void init ()
{ my_bar = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 100);
add(my_bar);
my_textline = new TextField(12);
add(my_textline);
my_blurb = new TextArea(7, 5);
add(my_blurb);
}
}

You can see that there is no paint() method. The fact that the screen furniture is declared, set up and added to the screen in method init() is enough to make them appear. Of course, the items added don't actually do anything - try dragging the scroll bar or typing text into the two text slots.

One thing that all the items have in common with buttons is the way in which they are declared. Each item has to be declared using the word public or private (I have chosen public here) and the type of the item (Scrollbar, TextField, TextArea) and the name.

Then the item has to be declared in the init() method, using the word new followed by the item type. The parameters passed to the type vary slightly from one item to the next. In the case of buttons, you will remember that the caption of the button was passed:

click_on_me = new Button("This button starts the program");

Here, different things are passed in the case of scroll bars, text areas etc. These are dealt with in their own sections below. Finally, each item has to be put onto the screen, using the add() instruction. If you don't, the item simply won't appear, even though it has been declared.
Scroll Bars

Scroll bars are declared using the Scrollbar type (Note that there is no space in the middle of that, and that the 'b' is lower case). A scroll bar consists of a small bar that can be dragged from one end of its "slot" to the other, and whenever the user does so, two things happen:

* Changing the scroll bar causes an event to happen (i.e. the program is alerted of the fact).
* The scroll bar returns a number to the program.

Setting up the scroll bar

You will notice that the command to set up the scroll bar consists of new Scrollbar() where the brackets contain 5 numbers:

* The first number is usually given in the form of a property, either Scrollbar.VERTICAL or Scrollbar.HORIZONTAL. These are in fact both numbers, although they are stored as values inside the Scrollbar class. Although you could try numbers here (I think it's 1 for vertical and 0 for horizontal, but I'm not sure) - it's probably easier to use the constants that they provide. If you are going to use the constant values, you must put them in upper case letters. Although Scrollbar.HORIZONTAL is correct, Scrollbar.Horizontal is not.

* The second number is the initial value that the scroll bar holds. Remember, the scroll bar represents a number that the user can alter, and that number has to start with a particular value. This starting value will also depend on what range of values are specified (the last two parameters, as explained below). There is no point in declaring that the scroll bar must return values in the range 0 to 100, and then start if off with a value of 200. I'll leave you to find out what happens if you try that.

* The third number is the Large Step Change. As well as dragging the scroll bar back and forth along its track, we can click on the arrows at the end. Every time that you do so, the value represented by the scroll bar will change by the amount specified in this parameter.

* The last two numbers indicate the minimum and maximum values (in that order) that the scroll bar can return. For instance, if you set these parameters to 100 and 200, then the scroll bar would only give numbers in that range: 100 when the slider was at one end of the track, 200 when it was at the other end, and some number in between on other occasions.

Here's an example of a scroll bar being set up:

Scrollbar indicate_strength = new Scrollbar(Scrollbar.HORIZONTAL, 25, 5, 0, 100);

This sets up a horizontal scroll bar which returns a range of numbers from 0 to 100. The scroll bar starts one quarter of the way along the track (i.e. at figure 25) and if we clicked on the arrows at the end of the track, it would return numbers increasing or decreasing by 5 (i.e. 30, 35, 40, 45 etc. or 20, 15, 10, 5, 0).
Reading values from the scroll bar

When the user drags the scroll bar to one side, or clicks on the arrows at the ends to change its values, the scroll bar should immediately hand a number back to the program and get the program to activate it. As you may have guessed, we need to write a special method, called handleEvent(), which we don't call specifically, but which Java calls automatically when the scroll bar is clicked on.

You may well be asking "Why doesn't Java use the action() method, which it uses to deal with buttons?" Well, that is a very good question, and I can't think of a sensible answer! It is a mystery to me also - I can't think of any reason why it should (although I dare say there is one).

The method handleEvent() is defined according to the following pattern. There is a single parameter, which I have chosen to call e() (but which you can call any name you like), which is used to distinguish between different events that may call handleEvent(). If you only have one possible event (e.g. there is only one scrollbar and nothing else that could call handleEvent()), then you don't have to refer to this parameter inside the body of the method (although it must still be included in the definition):

public boolean handleEvent (Event e)
{ // Statements in here to handle various events
return true;
}

Just like action(), handleEvent() is defined as returning a boolean value, so it should end in the statement return true. Inside the body of the method you include the statements to handle the event that has just occurred. In this case, we have a scrollbar called indicate_strength and we want to read its value. Scrollbar objects contain a method built into them called getValue() (note the capital V) which returns the value that the scrollbar is set to. Here is a sample program that reads the value of the scrollbar and displays it on the screen:

import java.awt.*;
import java.applet.*;

public class scrollDemo extends Applet
{ public int value = 0; // The value of the scrollbar
// will appear in this variable
public Scrollbar indicate_strength;

// Set up the scrollbar
public void init ()
{ indicate_strength = new Scrollbar(Scrollbar.HORIZONTAL, 25, 5, 0, 100);
add(indicate_strength);
}

public void paint (Graphics g)
{ g.drawString("Scrollbar value = " + value, 10, 40);
}

// The user has altered the scrollbar, so read its new value
public boolean handleEvent (Event e)
{ value = indicate_strength.getValue();
repaint();
return true;
}
}

The method handleEvent() contains a call to repaint() which updates the screen with the new value of the scrollbar. You would use the parameter e to distinguish between, for example, two scrollbars. The following example program has two scrollbars, termed leftbar and rightbar and displays their combined values:

import java.awt.*;
import java.applet.*;

public class scroll2 extends Applet
{ public String message = "";
public Scrollbar leftbar, rightbar;
public int leftvalue = 0, rightvalue = 0;

public void init ()
{ leftbar = new Scrollbar(Scrollbar.VERTICAL, 3, 1, 0, 10);
rightbar = new Scrollbar(Scrollbar.VERTICAL, 8, 1, 0, 10);
add(leftbar);
add(rightbar);
}

public void paint (Graphics g)
{ g.drawString("Total value = " + (leftvalue + rightvalue), 10, 70);
g.drawString(message, 10, 85);
}

// The user has altered the scrollbar, so read its new value
public boolean handleEvent (Event e)
{ if (e.target == leftbar)
{ leftvalue = leftbar.getValue();
message = "You altered the left bar.";
}
else
{ rightvalue = rightbar.getValue();
message = "You altered the right bar.";
}
repaint();
return true;
}
}

Inside the handleEvent() method, we use an if statement (which we will meet in a later section) to decide whether the left bar has been clicked or the right one. The appropriate variable is set, and a string variable is also set to indicate which bar was clicked.
Text Fields

A text field is a slot which is one line of text high. It is used for entering (generally) small quantities of text into programs. You can type as much text as you like into the text field - it scrolls as you type beyond the end of the slot - although if you want to enter large quantities of text, it is better to use a text area.

Text fields are handled in a similar way to scroll bars. They are set up at the start of the program and then values can be read from them at any point. Text fields, like other screen furniture, appear as close to the top central point of the applet as possible, with the applet "filling up" as more items are added.

Setting up a text field is simpler than setting up a scroll bar, as you only have to specify the number of columns in the field (i.e. its width). For example, the following command sets up a text field with 12 columns:

TextField type_age;

type_age = new TextField(12);
add(type_age);

Note that we declare the text field as being of type TextField (yes, that has a capital T and F), after which it can be set up and added to the screen. The declaration of the text field should be done in the earliest parts of the program, where the variables are declared. The setting up and adding of the text field should be done in the action() method. This is exactly the same procedure as for any other screen furniture, such as scroll bars.

Reading the contents of text fields is done in a similar way to scroll bars also, except that the method built into the TextField class is called getText() rather than getValue. Please, note, however, that this method returns a string rather than a number (more on this in a moment). Here is a simple example of a text field - simply enter any text into the text field and click on the button. The computer will then mimic what you typed below.

import java.applet.*;
import java.awt.*;

public class tFieldDemo extends Applet
{ public TextField type_something;
public Button do_it;
String repeat_mindlessly = "";

public void init ()
{ type_something = new TextField(20);
add(type_something);
do_it = new Button("Repeat this");
add(do_it);
}

public void paint (Graphics g)
{ g.drawString("You typed : " + repeat_mindlessly, 20, 50);
}

public boolean action (Event e, Object args)
{ repeat_mindlessly = type_something.getText();
repaint();
return true;
}
}

The parts of the program concerning the text field are shown in red. You will find that each of the lines in red corresponds to one of the things that you red about above.
Text Areas

Text areas are similar to text fields except they cover a certain number of columns and rows. They are set up as follows:

TextArea t;

t = new TextArea(15, 50);

The first number represents the number of rows (lines of text) and the second number the number of columns. Simply type the text in the box as you would into a normal word processor. As with text fields, there is a getText() method built into text area. Here is a duplicate of the applet that you saw above with a few changes made:


import java.applet.*;
import java.awt.*;

public class tAreaDemo extends Applet
{ public TextArea type_something;
public Button do_it;
String repeat_mindlessly = "";

public void init ()
{ type_something = new TextArea(10,40);
add(type_something);
do_it = new Button("Repeat this");
add(do_it);
}

public void paint (Graphics g)
{ g.drawString("You typed : " + repeat_mindlessly,20,270);
}

public boolean action (Event e, Object args)
{ repeat_mindlessly = type_something.getText();
repaint();
return true;
}
}

The text doesn't work wrap in the text area: You have to press Enter at the end of each line to move to the next one. There are several methods associated with text areas (and scroll bars, buttons and text fields, for that matter) that I haven't mentioned, but I haven't yet come across one that wraps text in a text area. Sorry!
Removing Screen Furniture

There may well be circumstances when you want to make various items of screen furniture disappear from the screen. For instance, a button may only have a valid function at some points in a program and be meaningless at other points, in which case it would be useful to make it disappear.

There is an instruction similar to add() which makes an item of screen furniture disappear from the screen. It doesn't remove all reference to the object, but simply makes it invisible! In the following applet, I set up two buttons. The first button makes the second one disappear and appear. The second button does nothing (it is simply there as an item of screen furniture). The boolean variable button_present is used only to keep track of whether the button is visible on the screen.

The source code for the applet should make its working clear:

import java.awt.*;
import java.applet.*;

public class testRemove extends Applet
{ Button a, b;
boolean button_present = true;

public void init()
{ a = new Button("Click here!");
add(a);
b = new Button("Hello");
add(b);
}

public boolean action (Event e, Object args)
{ if (e.target == a)
{ if (button_present == true)
{ remove(b);
button_present = false;
}
else
{ add(b);
button_present = true;
}
}
return true;
}
}

You will notice that the properties that the button possesses are not cancelled by the remove() instruction (or the add() instruction if the button is then redisplayed). The button still has the same caption (Hello) however many times you remove it and then add it again.
READ MORE - A scrollbar (Also known as a handle in the very first GUIs) is a graphical object in a GUI with which continuous text, pictures or anything else can be scrolled including time in video applications, i.e., viewed even if it does not fit into the space in a computer display, window, or viewport.

Buttons in Java Applets

 
 Buttons in Java Applets

* Creating a button object
* The concept of the "event driven program"
* The action() method
* The position of buttons on the screen
* Summary of buttons

Buttons are the small grey (usually) rectangles that you see appearing on the screen occasionally. They crop up in several languages, and even appear on web pages, such as the button that you see below:

We can create a button in a Java applet using something called a Button object. This button will always appear at the top of the screen in the centre (unless you use something called a canvas or a frame - more about these once I have worked out exactly how to use them myself!) and you can specify exactly what action the button carries out when you click on it.
Creating a button object

Unlike variables such as numbers (declared with int, float or double) or strings (declared with String), declaring objects is a two-stage process. I say "objects" rather than "button objects" because you will find that what I am about to show you will apply to a great many things in Java, not just button objects. However, for the time-being, we will stick to button objects.

* Firstly, declare the object exactly as you would declare a normal number, except this time, the variable type is Button:

Button clickOnMe;

This variable declaration should go with all the other declarations just inside the curly brackets used to set up the main program. The order in which you put your variable declarations isn't important - the button declaration can go at the beginning of the declarations, at the end or somewhere in the middle.
* Create a special method called init() as follows, and put in it the following instruction:

public void init ()
{ clickOnMe = new Button("Here's a button!");
add(clickOnMe);
}

init() is a special method that is called automatically by Java when you first run the applet. It is used to set up variables (to initialise them - hence the name) and to call up any methods that you want called immediately. It is the same method init() that you met in the last section.

There are two commands inside init() that you haven't met before. The first one reserves space in the memory for the button object. So far we have declared it (i.e. told Java that we intend to use a variable called clickOnMe, but we haven't actually reserved the memory for it. That is what this new Button instruction does. It is always followed by a pair of brackets and inside those is the caption that you want to appear on the button. In this case, the caption is "Here's a button!"

The add(clickOnMe) instruction actually makes the button appear on the screen. If you didn't include it, then the button would be created but would remain invisible. Here is the complete program:

import java.applet.*;
import java.awt.*;

public class buttonDemo1 extends Applet
{ Button clickOnMe;

public void init ()
{ clickOnMe = new Button("Here's a button!");
add(clickOnMe);
}
}

You will notice that (a) there is nothing on the screen except the button (and it doesn't do anything when you click on it!) and (b) the button still appears on the screen even though we didn't include a method called paint(Graphics g).
In fact, the add(clickOnMe) instruction causes the button to appear whether or not you put in a paint(Graphics g) method or not. Even if you alter various things about the button (such as its caption), then you still don't need paint() to update the button on the screen - it will just update automatically.

You can add more buttons if you like. In this following example, I have put in two buttons and an integer variable. Both the buttons are declared in the same Button statement, but there is no reason why you can't declare them on separate lines:

import java.applet.*;
import java.awt.*;

public class buttonDemo2 extends Applet
{ Button increase, decrease; // These are two buttons
int value = 1000;

public void init ()
{ increase = new Button("Increase the value");
add(increase);
decrease = new Button("Decrease the value");
add(decrease);
}

public void paint (Graphics g)
{ g.drawString("The value is currently " + value, 50, 80);
}
}

This time I have included a paint() method, but you will notice that it does not include any reference to the buttons at all. All it does is display the value of the variable value together with a simple message.

This program displays the two buttons and the variable, but it does not tie those buttons to actions. How do we get the buttons to do something? In the next two sections we will see how this is done by adding an extra method to that program I have just given you.
The concept of the "event driven" program

A Java applet is a type of program called "event driven." This will be familiar to anyone who has programmed in JavaScript or Visual C++ but less so to programmers coming from languages such as (ordinary) C++ or Pascal. It is best described using an analogy.

Suppose I am expecting a visitor to arrive at my front door. Unfortunately, I do not have a door bell or a door knocker, so I have to spend the time standing by the front door waiting for him to call. If I don't stand by the door, there is the possibility that he will arrive and then go away again - I will have missed him.

Some programs work this way. To see if you are clicking on a button, they continually have to check the status of the buttons at regular intervals. This makes them rather inefficient, since it cuts down the time they have available to do other things.

Now I get a doorbell fixed. This time, when my friend arrives, all he has to do is press the doorbell. I will break off from watching the television, doing the crossword, or picking my nose (i.e. whatever I am doing) and come running. This is what an event-driven program does. It carries on with whatever it is doing until you click on a button (or cause some other event to happen). Then it deals with that button click (or whatever) and goes back to what it was doing before.
The action() method

There is a special method called action() which is designed entirely to deal with button clicks. You do not have to call it specifically - it is called automatically whenever an event , such as a button click occurs. Although it can't trap all events (in particular, mouse clicks elsewhere on the screen, i.e. apart from on buttons - we track those using a different method), it can deal with most of them. Here is the program with the correct method added:

import java.applet.*;
import java.awt.*;

public class buttonDemo3 extends Applet
{ Button increase, decrease; // These are two buttons
int value = 1000;

public void init ()
{ increase = new Button("Increase the value");
add(increase);
decrease = new Button("Decrease the value");
add(decrease);
}

public boolean action (Event e, Object args)
{ if (e.target == increase)
value++;
if (e.target == decrease)
value--;
repaint();
return true;
}

public void paint (Graphics g)
{ g.drawString("The value is currently " + value, 50, 80);
}
}

A lot of that will be new to you so I will go through it one point at a time:

* Firstly, the action() method takes two parameters. The first one is of type Event and the second one is of type Object. I have chosen to call these e and args, simply because that is what I saw them called in the Java book that I read. You can call them anything, but you must include both of them, and you must specify that the first is of type Event and the second is of type Object. (In fact, we don't actually use the second parameter at all inside the method, but we must include it or Java will not recognise the method when we click on a button).

* The function action() is not marked as void as all the functions have been that you have met up to now. Instead, it returns a boolean value. You will notice that the last line of function is return true. boolean values are either true or false, and in this case, the standard thing to do is to return a true value at the end of the action() method. Why do we do this? Because that is what Java expects in this particular circumstance!

* We have two possible events that can happen - clicking on increase or clicking on decrease - and we need to distinguish between them. Fortunately, the Event variable (which I have called e) can tell us. It is an object with a property called target, and we use two if statements to distinguish whether the increase button was clicked or the decrease button.

In this case, if the increase button is clicked, the value of the variable is increased (as specified by value++) and if the decrease button is clicked, the value of the variable is decreased (as specified by value--).
* However, just changing the value of the variable isn't enough to make the screen change. For this reason, there is a special method called repaint() which automatically calls paint(Graphics g) again to redraw the screen. Note that the method repaint() does not take any parameters, not even a Graphics parameter!

Here is the updated applet, complete with the action() method:

The position of buttons on the screen

You will have noticed by now that we did not include any command to place the button at a certain position on the screen. The buttons simply appeared as close to the top of the applet as possible. Unfortunately, Java does not give you a way of specifying exactly where you want the buttons to appear on the screen - well, that's not entirely true. There are objects called frames and canvases, but they are horribly complex and definitely should be left until a later session.

For the moment, just get used to the fact that your buttons will appear at the top of the screen. They fill up the top "line" until there is no room for any more. Then they start to fill the next "line" down. The following applet is rather narrow (I declared the width of the applet to be 120). You will also note that I have displayed a message at position (10,10) and that it has been partially obscured by the buttons.

 Summary of Buttons

The following "skeleton" program gives the minimum amount of code necessary to run a button. Use it as a template and add as many buttons and as much code as you like:

import java.applet.*;
import java.awt.*;

public class button_skeleton extends Applet
{ Button b;

public void init ()
{ Button b = new Button("Button caption");
add(b);
}

public boolean action (Event e, Object args)
{ if (e.target == b)
{ // User has clicked on button 'b'
// so do something!
}
return true; // Yes, we do need this!
}
}
READ MORE - Buttons in Java Applets

Further detection can be done when the block is received is different from the bit pattern received codeword sent suppose 00100th block codeword that is not a valid password. If we consider acceptable invalid password is required only changing one bit will generate the bit pattern of a valid password

Sandi block is formed principally of runs of data with fixed length (k) then add a number (nk) bits that are formed along the n codeword unique.
Hamming distance: the number of bits that are not equal between the two codeword.

C1 = 011,011, C2 = 110,001

The second codeword Hamming distance can be expressed diatasa d (C1, C2) = 3

How the addition of these bits can provide correction capability in digital data transmission can be explained in the following examples:

for example: k = 2 and n = 5 then:

blocks of data: 00 01 10 11 converted into 5 bits of data

codeword: 00000 00111 11001 11110

Further detection can be done when the block is received is different from the bit pattern received codeword sent suppose 00100th block codeword that is not a valid password. If we consider acceptable invalid password is required only changing one bit will generate the bit pattern of a valid password, which is to be 00,000 while the other valid password is required for the conversion of 00,111 bits 2, 4 bits to 11,001, and 3 bits to 11,110. We can take the conclusion that the password is accepted because it has 00,000 compared to the largest possible passwords or other illegal has the smallest Hamming distance. This is the error correction capabilities with the addition of redundant bits.

In a password with a password C1, C2, C3, ... Cs with S = 2 ^ k, the smallest distance Dmin the password stated as:

Dmin = min [d (Si, Sj)] i ≠ j

if a password meets Dmin 2t ≥ t +1 with a positive integer then the password can correct the error of ≤ t. Furthermore the relationship between Dmin and t can be expressed as follows:

t = floor (Dmin-1) / 2; to correct the error of t

t = Dmin -1; to detect the error of t

If the error occurs several Dmin then this error can only change one valid codeword into another valid codeword, while when an error occurs then the series of Dmin error will not change a valid codeword into another valid codeword.

Some considerations in designing a block code include: 

  1.  for n and k, it is expected to be the largest Dmin 
  2.  should be easy in penyandianya, does not require memory and processing time is much  
  3.  a little bit redundant, saving bandwidth  
  4.  redundant bit much, reduce the error rate
READ MORE - Further detection can be done when the block is received is different from the bit pattern received codeword sent suppose 00100th block codeword that is not a valid password. If we consider acceptable invalid password is required only changing one bit will generate the bit pattern of a valid password

Creating MATLAB GUI controls on non-active or active

Creating MATLAB GUI controls on non-active or active
from Engadget confused looking eh dapet this function also of its MATLAB HELP:: HELP emang mantab,, must diligently, basically the following examples use the function to change the properties on matlab uicontrol GUI MATLAB:
matlab tutorial this at first we make the following view is a GUI editor:

The component consists of:

1.button group contains 3 radio buttons: button group causes only one of the three radio buttons is worth one


next to the GUI editor right click on the button group>> viewcallback>> SelectionChangeFcn
This makes the function of the third selection in the button group radiobutton



then we fill the above functions to make editing text into 3 kinds of circumstances in the property 'enabled':
0n: can be edited
off: not editable gray
inactive: not editable, but not gray
function as follows:
uipanel1_SelectionChangeFcn function (hObject, eventdata, handles)
% HObject handle to uipanel1 (see GCBO)
% Eventdata reserved - to be defined in a future version of MATLAB
% Handles structure with handles and user data (see GUIDATA)
% function to change the properties (enable) control ui
if (hObject == handles.on)
set (handles.edit1, 'enable', 'on');
elseif (hObject == handles.off)
set (handles.edit1, 'enable', 'off');
else
set (handles.edit1, 'enable', 'inactive');
end
word after (handles) is the name of "Tag" on the uicontrol property

results are as follows: 

READ MORE - Creating MATLAB GUI controls on non-active or active

Filling an Array

Filling an Array


An array is a systematic arrangement of objects, usually in rows and columns. Specifically, it may refer to several things.

An array is a systematic arrangement of objects, usually in rows and columns. Specifically, it may refer to several things.

In computer science

Generally, a collection of data items that can be selected by indices computed at run-time, including:

* Array data structure, an arrangement of items at equally spaced addresses in computer memory
* Array data type, used in a programming language to specify a variable that can be indexed
* Associative array, an abstract data structure model that generalizes arrays to arbitrary indices

or various kinds of the above, such as

* Bit array or bit vector
* Dynamic array, allocated at run time
* Parallel array of records, with each field stored as a separate array
* Sparse array, with most elements omitted, to store a sparse matrix
* Variable-length array
* Ragged (jagged) array, where the rows have different lengths individually

or various related concepts:

* Array processor, a computer to process arrays of data (not to be confused with a processor array)
* Array programming, using matrix algebra notation in programs (not the same as array processing)
* Array slicing, the extraction of sub-arrays of an array
* APL (programming language)

or also:

* Video Graphics Array (VGA), a display adapter and video format, and many variants thereof (EVGA, FWVGA, QVGA, QXGA, SVGA, SXGA, SXGA+, TXGA, UVGA, XGA, XGA+, ...)

In computer science, an array data structure or simply array is a data structure consisting of a collection of elements (values or variables), each identified by one or more integer indices, stored so that the address of each element can be computed from its index tuple by a simple mathematical formula.

For example, an array of 10 integer variables, with indices 0 through 9, may be stored as 10 words at memory addresses 2000, 2004, 2008, … 2036; so that the element with index i has address 2000 + 4 × i.

One-dimensional arrays

The one dimensional arrays are also known as Single dimension array and is a type of Linear Array. In the one dimension array the data type is followed by the variable name which is further followed by the single subscript i.e. the array can be represented in the row or column wise. It contains a single subscript that is why it is known as one dimensional array because one subscript can either represent a row or a column.

for example auto int new[10];

In the given example the array starts with auto storage class and is of integer type named new which can contain 10 elements in it i.e. 0-9. It is not necessary to declare the storage class as the compiler initializes auto storage class by default to every data type After that the data type is declared which is followed by the name i.e. new which can contain 10 entities.

For a vector with linear addressing, the element with index i is located at the address B + c · i, where B is a fixed base address and c a fixed constant, sometimes called the address increment or stride.

If the valid element indices begin at 0, the constant B is simply the address of the first element of the array. For this reason, the C programming language specifies that array indices always begin at 0; and many programmers will call that element "zeroth" rather than "first".

However, one can choose the index of the first element by an appropriate choice of the base address B. For example, if the array has five elements, indexed 1 through 5, and the base address B is replaced by B − 30c, then the indices of those same elements will be 31 to 35. If the numbering does not start at 0, the constant B may not be the address of any element.


Multidimensional arrays


For a two-dimensional array, the element with indices i,j would have address B + c · i + d · j, where the coefficients c and d are the row and column address increments, respectively.

More generally, in a k-dimensional array, the address of an element with indices i1, i2, …, ik is

B + c1 · i1 + c2 · i2 + … + ck · ik

This formula requires only k multiplications and k−1 additions, for any array that can fit in memory. Moreover, if any coefficient is a fixed power of 2, the multiplication can be replaced by bit shifting.

The coefficients ck must be chosen so that every valid index tuple maps to the address of a distinct element.

If the minimum legal value for every index is 0, then B is the address of the element whose indices are all zero. As in the one-dimensional case, the element indices may be changed by changing the base address B. Thus, if a two-dimensional array has rows and columns indexed from 1 to 10 and 1 to 20, respectively, then replacing B by B + c1 - − 3 c1 will cause them to be renumbered from 0 through 9 and 4 through 23, respectively. Taking advantage of this feature, some languages (like FORTRAN) specify that array indices begin at 1, as in mathematical tradition; while other languages (like Pascal and Algol) let the user choose the minimum value for each index.



In computer science, an array type is a data type that is meant to describe a collection of elements (values or variables), each selected by one or more indices that can be computed at run time by the program. Such a collection is usually called an array variable, array value, or simply array.[1] By analogy with the mathematical concepts of vector and matrix, an array type with one or two indices is often called a vector type or matrix type, respectively.

Language support for array types may include certain built-in array data types, some syntactic constructions (array type constructors) that the programmer may use to define such types and declare array variables, and special notation for indexing array elements.[1] For example, in the Pascal programming language, the declaration type MyTable: array [1..4,1..2] of integer, defines a new array data type called MyTable. The declaration var A: MyTable then defines a variable A of that type, which is an aggregate of eight elements, each being an integer variable identified by two indices. In the Pascal program, those elements are denoted A[1,1], A[1,2], A[2,1],… A[4,2].



Special array types are often defined the language's standard libraries.

Array types are distinguished from record types mainly because they allow the element indices to be computed at run time, as in the Pascal assignment A[I,J] := A[N-I,2*J]. Among other things, this feature allows a single iterative statement to process arbitrarily many elements of an array variable.

In more theoretical contexts, especially in type theory and in the description of abstract algorithms, the terms "array" and "array type" sometimes refer to an abstract data type (ADT) also called abstract array or associative array, a mathematical model with the basic operations and behavior of a typical array type in most languages — basically, a collection of elements that are selected by indices computed at run-time.

Depending on the language, array types may overlap (or be identified with) other data types that describe aggregates of values, such as lists and strings. Array types are often implemented by array data structures, but sometimes by other means, such as hash tables, linked lists, or search trees.

In order to effectively implement variables of such types as array structures (with indexing done by pointer arithmetic), many languages restrict the indices to integer data types (or other types that can be interpreted as integers, such as bytes and enumerated types), and require that all elements have the same data type and storage size. Most of those languages also restrict each index to a finite interval of integers, that remains fixed throughout the lifetime of the array variable. In some compiled languages, in fact, the index ranges may have to be known at compile time.

On the other hand, some programming languages provide more liberal array types, that allow indexing by arbitrary values, such as floating-pont numbers, strings, objects, references, etc.. Such index values cannot be restricted to an interval, much less a fixed interval. So, these languages usually allow arbtrary new elements to be created at any time. This choice precludes the implementation of array types as array data strcutures. That is, those languages use array-like syntax to implement a more general associative array semantics, and must therefore be implemented by a hash table or some other search data structure.

The number of indices needed to specify an element is called the dimension, dimensionality, or rank of the array type. (This nomenclature conflicts with the concept of dimension in linear algebra, where it is the number of elements. Thus, an array of numbers with 5 rows and 4 columns (hence 20 elements) is said to have dimension 2 in computing contexts, but 20 in mathematics. Also, the computer science meaning of "rank" is similar to its meaning in tensor algebra but not to the linear algebra concept of rank of a matrix.)

Many languages support only one-dimensional arrays. In those languages, a multi-dimensional array is typically represented by an Iliffe vector, a one-dimensional array of references to arrays of one dimension less. A two-dimensional array, in particular, would be implemented as a vector of pointers to its rows. Thus an element in row i and column j of an array A would be accessed by double indexing (A[i][j] in typical notation). This way of emulating multi-dimensional arrays allows the creation of ragged or jagged arrays, where each row may have a different size — or, in general, where the valid range of each index depends on the values of all preceding indices.

This representation for multi-dimensional arrays is quite prevalent in C and C++ software. However, C and C++ will use a linear indexing formula for multi-dimensional arrays that are declared as such, e.g. by int A[10][20] or int A[m][n], instead of the traditional int **A.

Index types

Array data types are most often implemented as array structures: with the indices restricted to integer (or totally ordered) values, index ranges fixed at array creation time, and multilinear element addressing. This was the case in most "third generation" languages, and is still the case of most systems programming languages such as Ada, C, and C++. In some languages, however, array data types have the semantics of associative arrays, with indices of arbitrary type and dynamic element creation. This is the case in some scripting languages such as Awk and Lua, and of some array types provided by standard C++ libraries.

Array index range queries

Some programming languages provide operations that return the size (number of elements) of a vector, or, more generally, range of each index of an array. In C and C++ arrays. They do not support the size function, so programmers often have to declare separate variable to hold the size, and pass it to procedures as a separate parameter.

Elements of a newly created array may have undefined values (as in C), or may be defined to have a specific "default" value such as 0 or a null pointer (as in Java).

In C++ a vector supports the store, select, and append operations with the performance characteristics discussed above. Vectors can be queried for their size and can be resized. Slower operations like inserting an element in the middle are also supported.
READ MORE - Filling an Array

Demonstrate the basic null-terminated string functions.

Demonstrate the basic null-terminated string functions.

READ MORE - Demonstrate the basic null-terminated string functions.

Application Component Factory framework may be designed using Object-Oriented programming (OOP) to generate the Application-Component ('AC')

The “Component Factory” (or CF) may be designed using Object-Oriented programming (OOP) to generate the Application-Component ('AC'). As shown in the Fig below, the CF may use reusable (e.g. COTS: ”Commercial Off The Shelf”) or pre-built GUI-Classes to present parts of the AC; and other objects, such as, DB-objects or EJB-objects to get the necessary data to generate custom AC for each user.

The CF tightly couples many Objects to build each Custom-AC as shown in the Fig below. The arrows shows the dependencies between the Objects. Please remember, one may need to write several dozens lines of code to initialize and customize each reusable GUI Class such as Chart or graph (for example, to input not only Data but also Style-data such as fonts and colors). So each arrow of dependency may represent dozens of function calls. The CF may get necessary data from other sources such as configuration files to customize the component (e.g. style, national language strings).

Furthermore, the data-pieces obtained from EJB or DB-Objects cannot be readily input to GUI Components, since often need to apply application-logic such as business rules/policies, user-preferences, algorithms or irritate over large data-sets to calculate summaries such as medians/average etc. Don't you agree all this code is essential, which force the developers to tightly-couple the Objects and Logics?

Application Components & Component Factory framework
The web-applications are mainly consists of many screens or web pages; which deliver information. Also may contain form-elements (e.g. check-boxes, radio-buttons or Text-input boxes) for end-user to enter information or send requests. Each web page may consist of many Application Components (or components on the web page). The Application Component or AC is a component (or presentation section on the web page) such as ‘weather-info’ or ‘stock-quote’ as shown in the figure#1 and figure#3.


While the types of ACs vary from application to application and are unique to each application, the process is same. In most web pages we can identify one or more such ACs. For example, CRM (Customer relationship management) application may present customer complaints, satisfaction or response time as charts, graphs and tables etc.; and HR (human resources) application may present organizational maps as hierarchical-trees and employee information/status/performance in a popup for each employee etc. Likewise, Air traffic control systems may contain Flights and Games may contain animated characters such as Race-cars.

The Component-Factory (or "CF") approach recommends identifying such ACs and building a ‘CF’ (or Java Class) for each Application Component or AC. The ‘Component Factory’ (or CF) is nothing but a simple Java-class, which access appropriate data-sources (e.g. RDBMS or Wire for real-time data such as Stock-quotes) to collect data for the component and creates the browser specific 'Code-block' (XHTML, SVG, DOM, Jscript etc.) to present the component. For example, for Fig#1, the CF is nothing but a Java-class, which takes the user’s city-name as input, accesses the database for latest weather-data and creates the HTML-code to presents the weather AC.

Likewise, Fig#3, the CF is nothing but a Java-class, which takes a ticker-symbol of a company as input and creates the HTML-table/SVG-charts code for the stock-quote AC. As shown in the Fig#2, the CF may use one or more reusable GUI-Classes for the charts to generate the code for the AC.

ComponentFactory Weather = new CF_Local_Weather(94089); //Set ZIP-Code
Weather.CGM ( User_Info, Out); // Write the 'Code-block' to present the Component

ComponentFactory Quote = new CF_Stock_Quote( "SUNW"); //Set Ticker Symbol
Quote.CGM ( User_Info, Out); //Write the 'Code-block' to present the Component
The ‘Java Classes’/CF created this way can be instantiated in any JSP/Servlet by just writing one or two lines of code. Hence, the components can be quickly interchangeable, by just replacing these two-lines. Also, if they are implemented as Portlets, they can be accessed from remote web-servers not only to get the information but also as well-packaged 'code-block' for the AC. These Classes can be seen as ‘component-factory’ for weather AC and ‘component-factory’ for stock-quote respectively, because they manufacture ‘ACs’ at real-time as per client/browser requirement and/or profile. Any application, which needs weather information, can request the Java-class to custom create browser/user-profile specific AC at real-time for the city (or zip code) passed to it.
These Java-classes (or CF) are highly independent and any modification to them would not require any updates in the code that uses them to build sub-ACs. Hence, the Java-class can be independently refined or redesigned to meet evolving needs. Also such classes can be made intelligent and adaptable. For example, ‘stock-quote’ may access the user profile and customize the AC for each user by choosing appropriate charts as per his preferences. Hence, the CF not only can produce ‘AC’ but also may customize it as per user preferences.

If many Component Factories are built, they can be used in the JSP/Servlet to build components in the each page quickly. For example, it is possible to create a CF-class for stock info table, which takes ticker symbol as one of its input and access the latest data from data source to generate SVG-code to present a stock quote table. Likewise, CF-class to generate SVG-code to present intra-day stock movement chart. Once such CF’s are built, they can be used in a JSP file to build AC for presenting stock information. For example, the following pseudo-code listing uses CFs to create stock-info as shown in the figure#3

Pseudo-code listing#1

1.
2. <% 3. String Ticker = req.getResource("TickerSymbol"); 4. %>
5.
6.
7. // Translate (X, Y) determines the X & Y location of this Group.
8. // You may think the SVG-Group as a Canvas to draw the component
9. // You can draw even very complex components on this canvas.
10. // This Canvas may contain other Canvases to draw subcomponents,
11. // And so on. This helps up build the component hierarchy.
12. <% 13. //Write Java Code to use CF to include the AC’s code. 14. // Instantiate & Initialize the CF 15. AgileTemplate Table = new StockInfoTable(Ticker); 16. // Call the method to generate and write the AC’s Code 17. Table.CGM(ati, out); 18. %>
19.
// Close the Canvas (i.e. SVG Group).
20.
21.
22. <% 23. AgileTemplate Chart1 = new IntraDayChart(Ticker); 24. Chart1.CGM(ati, out); 25. %>
26.

27.
28.
29. <% 30. AgileTemplate Chart2 = new MonthlyChart(Ticker); 31. Chart2.CGM(ati, out); 32. %>
33.

34.

 


Likewise, it is also possible to create larger-CF for comprehensive stock information AC. The larger-CF uses many CFs to build charts (or sub-ACs). For example, the following pseudo CGM() code shows, how larger CF may use other CFs to include sub-ACs.

This following pseudo method code listing shows, how one may use other Component factories or GUI-classes to build subcomponents. This larger CF could take a Ticker symbol to build a component as shown in the above figure. The Objects of this CF-Class can be used again, for example, to build subcomponents for a larger portfolio Tab-Class. The tab-component shows the company names as Tabs to select or to switch between the company-info components.

1. int CGM (AgileInfo ati, StreamWriter out) {
2.
3. String Ticker = this.Input_TickerSymbol; // Get the TICKER symbol.
4.
5. // Instantiate & Initialize the CF
6. AgileTemplate Table = new StockInfoTable(Ticker);
7. // Call the method to generate the AC’s Code
8. Table.CGM(ati, out, 0, 0, null);
9. //Note: The X & Y coordinates may be passed to CGM.
10.
11. // Instantiate & Initialize the CF
12. AgileTemplate Chart1 = new IntraDayChart(Ticker);
13. // Call the method to generate the AC’s Code
14. Chart1.CGM(ati, out, 0, 250, null);
15.
16. // Instantiate & Initialize the CF
17. AgileTemplate Chart2 = new MonthlyChart(Ticker);
18. // Call the method to generate the AC’s Code
19. Chart2.CGM(ati, out, 0, 500, null);
20.
21. }


Note: This also shows a method to build component-hierarchy. The large component contains a Table and two Charts. Likewise, one could build arrays, as shown below:
ComponentFactory CF_Array = {Table, Chart1, Chart2}; //Array of Components



As shown in Fig#2, CF encapsulates the tight coupling of all the Objects and all the logics (e.g. Application, presentation & business logics). It needs just 2 lines of code to include/replace an AC from webpage. If any two ACs needs to collaborate with each other, on average they need no more than 3 to 7 lines of communication code (e.g. to loosely couple service-provider & service-consumer ACs).


Notice, most online-GUI-classes (Navigational-menus, charts and trees etc.) contain in the Agile-Templates library may not be good ‘Component factories’ as per the definition in this document. Most components in the Agile-Templates library (i.e. online-GUI-API) require all the data to be supplied by the developer and do not access data on their own. Developer may use the classes from the GUI library to build his own CF.
The CF usually encloses both business logic and presentation-logic (e.g. one or more GUI-classes). Better designed ‘CF’ could not only ‘highly independent’ but also intelligent to effectively use user profile (client preferences, security/authentication etc.) to build personalized/customized ‘AC’ at real-time. To attain higher lever of Independence, the ‘Component factories’ should require little or no data from callers (or other peer components), except ‘Request’ and ‘Session’ objects; which may contain information about requesting browser, client-profile and/or database-connections etc.
If many such well designed ‘CF’ are available, they can be assembled to build JSP/Servlet for each page in hours and complex web-application in mater of days; or each new CF can be integrated in to any web-application in mater of minutes.
Please remember that, each ‘CF’ may use other ‘CF’ in the same way to build sub-ACs at run-time. For Example, in the Fig#3 example, the ‘CF’ for stock-quote may use other ‘CFs’, (each CF creates SVG-Charts respectively for 1Mont, 3Months, 6Months and 1Year etc.), and select one or more ‘sub-CFs’ by using simple ‘if-then-else’ statement at run-time as per user preferences.

Pseudo Code Sample listing#3

// One may use if-then-else to dynamically select a subcomponent.
AgileTemplate Chart2 = null;
If (user_preference == 1month)
Chart2 = new StockMonthlyChart(Ticker);
else If (user_preference == quterly)
Chart2 = new StockQuterlyChart(Ticker);
else If (user_prefers_half_year)
Chart2 = new StockHalfyearlyChart(Ticker);
else
Chart2 = new StockYearlyChart (Ticker);
// Call the method to generate the code for the sub Application Component.
Chart2.CGM(ati, out);
// If a user wish to see all three, all the charts can be placed one after the other



Notice the two dimensions of flexibility the application designers have, to build highly customized applications. The first dimension is that it is very easy to build ‘intelligent-CF’, which could get each user profile and build the AC as per his preferences. The second dimension is that: It is simple to create yet another intelligent-CF that could choose, at run-time dynamically, a subset of such intelligent ACs to assemble larger customized AC; as per each user preferences (Ex: Use 3 months or 6 months stock chart) by just using simple if-then-else construct.
The design objective of the “CF” is to encapsulate and hide the manufacturing complexity in an independent module (e.g. Java or C++ class). This would allow any one, who needs the AC can get a ready to integrate AC at real-time custom-built by the intelligent-CF. The Objective of the CF is to emulate the manufacturing process, where manufacturers hide the complexity of the manufacturing and internal complexity of the component. If one uses this component as a subcomponent in a larger component, all he needs to concern about the interfaces needed (e.g. to get its services) to integrate the AC and not much else.

For example, consider the Battery in the Cars: The battery maker encapsulates all the manufacturing and functional complexity in a ' Replaceable-Container' (Please review Appendix-A for the very important concept 'Replaceable-Container'). Note the separation of manufacturing and services. It allows the automakers to only concern about services to assemble a part. Since, the automaker mainly relies on the external service-interfaces, the batter-maker preserves his freedom to innovate, to refine the manufacturing process, improve the performance, services or reduce costs.
The component Factory framework is nothing but, building simple and independent CFs/ACs (Replaceable Containers); and assemble such components hierarchically to build larger and larger CFs, and hence WebPages (or Screens) and finally the Application.
You may picture the process of the creating a JSP/Servlet for a web page is just like typesetting the printing machine by placing a simple call to run each ‘CF’ at appropriate location in the page layout (i.e. screen layout). The ‘CF’ manufacture custom ‘AC’ at real-time and places them at appropriate location in the web page that is under construction for each request from client/browser.
For example, if developer likes to place an AC in a cell of a table, just include the code for the appropriate ‘CF’ in the cell. This code is as simple as including one line of code to instantiate the CF-Object, may be few lines to set data objects (remember, well designed CF might not need this data); and finally one line to invoke the Object’s code generation method. Later, if developer likes to replace the ‘CF’ with another ‘CF’, all he has to do is just replace this few lines of code with call to new ‘CF’ for the new AC. Also, if developer likes to select one of these two ‘CF’ based on user preferences, all he has to do is just use if-then-else construct to select appropriate ‘CF’ to build the custom ‘AC’.
READ MORE - Application Component Factory framework may be designed using Object-Oriented programming (OOP) to generate the Application-Component ('AC')

Wednesday, December 30, 2009

Object-oriented programming

Object-oriented programming (English: object-oriented programming OOP is abbreviated) is a programming paradigm to the object-oriented. All data and functions within this paradigm is wrapped into classes or objects. Compare with structured programming logic. Each object can receive messages, process data, and send messages to other objects.
 

Object-oriented data model is said to give more flexibility, ease of changing the program, and is widely used in engineering large-scale software. Furthermore, supporters claim that OOP OOP is easier to learn for beginners than with previous approaches, and object-oriented approach more easily developed and maintained.

The basic concept of Object Oriented Programming

Object-oriented programming emphasizes the following concepts:
  1. class is a collection of definitions of data and functions in a unit for a particular purpose. For example 'class of dogs' is a unit consisting of data definitions and functions which refer to various kinds of behavior / derived from dogs. A class is the basis of modularity and structure in object-oriented programming. A class should typically be recognizable by a non-programmer domain name even associated with existing problems, and code contained in a class should be (relatively) autonomous and independent nature (as the code is used if not using OOP). With modularity, the structure of a program would be associated with aspects of the problem to be resolved through the program. This way will simplify the mapping of the problem to a program or vice versa.
  2. Object is to wrap the data and functions together into a unit in a computer program; object is the basis of modularity and structure in an object-oriented computer program.
  3. Abstraction is the ability of a program to pass information processing aspects of it, namely the ability to focus on the core. Every object in the system serve as a model of the "actors" who can do abstract work, reports and changes in circumstances, and communicate with other objects in the system, without disclosing how the excess is applied. Processes, functions or methods can also be made abstract, and several techniques used to develop a the abstract.
  4. Encapsulation is an object Ensure user can not change the state of an object in a way that is not feasible; only method in which the object is given permission to access the situation. Each object access interface that mentions how other objects can interact with it. Other objects will not know and depend on the representation of the object.
  5. Polymorphism through message sending. Does not depend on subroutine calls, object-oriented language can send messages; specific methods associated with the delivery of the message depends on the particular object plane in which it was sent. For example, if a bird get the message "move fast", he'll move his wings and fly. When a lion receive the same message, he will move his feet and ran. Both answered a similar message, but in accordance with the animal's ability. This is called polymorphism as a variable in the program single can hold a variety of different types of objects while running the program, and the same text that the program can call a few different methods at different times in the same calling. This is in contrast to functional languages achieve polymorphism through the use of
First-class functions.
  1. Set Inheritas polymorphism and encapsulation by allowing objects to be defined and created a special type of object already exists - these objects can share (and expand) their behavior without re-touching to implement such behavior (object-based languages do not always have inheritas.)
  2. Using OOP do so in solving a problem we do not see how to solve a problem (structured) objects but what can be done solving the problem. For example, assume we have a department that has a manager, secretary, clerk and other data. Suppose the manager wants to obtain data from the administration bag is not the manager have to take it directly but can be ordered administration officials to retrieve bags. In the case of a manager does not have to know how to retrieve the data but the manager can get the data via object adminiistrasi officer. So to solve a problem with collaboration among the objects that exist because every object has his own job description.
How do I recognize the visual programming?

In essence, object-oriented visual programming brings to the next level. Visual programming goal is to make programming easier for the programmer and more easily accessible by the borrowing language nonprogrammer with OOP, and
use practices graphically or visually. Users visual programming allows for more focus on solving problems than how to handle the programming language. Here you do not need to learn the syntax, or writing code.

Visual programming is a method of programming where the programmer to make connections between objects by drawing, pointing, and clicking on the icons and diagrams and by interacting with the flow chart. Thus, programmers can create programs by clicking on the icon that represents programming routines in general.

  1. Examples of visual programming is Visual BASIC, object-oriented programming language based on Windows from Microsoft that allows users to develop Windows and Office applications to create command buttons, text boxes, windows and toolbars.
  2. The next will be a link to a small BASIC program to perform certain actions. Visual BASIC is an event-driven, meaning the program waiting for user to do something ( "event"), such as click on the icon, and then the program will respond. For example, at the beginning of the user can use drag and drop tool (drag-and-drop) to develop a graphical user interface that made automatically by the program. Karen its use easy, Visual BASIC allows novice programmers to creates based applications windows of interest.
The next will be a link to a small BASIC program to perform certain actions. Visual BASIC is an event-driven, meaning the program waiting for user to do something ( "event"), such as click on the icon, and then the program will respond. For example, at the beginning of the user can use drag and drop tool (drag-and-drop) to develop a graphical user interface that made automatically by the program. Karen its use easy, Visual BASIC allows novice programmers to creates based applications windows of interest.

Pemrograman Berorientasi Objek

What is Object?

Imagine you are programming in traditional languages such as BASIC third generation, create a line coded instructions at a time. When you are working on some segments of the program (eg, counting overtime), you would think, "I'll bet other programmers to make program's. Sure would save a lot of time ". Fortunately, there are repeated cycles, the object-oriented programming, an improved version of the 3GL.

Working OOP: Objects, Messages, and object-oriented programming method consists of the following components:

  1. What is OOP: object-oriented programming (OOP, pronounced "oop"), data and instructions for processing where the data are combined into "objects" that can suffice used on other programs. The most important thing here is the object.
  2. What is "object": the object is self-contained module of code that have been prepared pemrogaman earlier. Made load modules or both (1) branch of data, and (2) processing instructions that can be done on the data.
  3. When was the object data will be processed - send a "message": the object becomes part of a program, specific instructions are activated only when the "message" associated've sent. Is sending a warning message to the object when the operation should be performed involving a particular object.
  4. How data is processed object - "method": message simply identifies operations. How true it is done will be included in processing instructions that are part of the object. Instruction processing method is called.
Block reuse program code after you write a block of source code, the code can be reused in other programs. So, with OOP, unlike traditional programming-you do not need to start from scratch. Compared with traditional pemrogaman, learn the object pemrogaman berorintasi takes longer because of such thinking in new ways. Nevertheless, the benefits of OOP objects memilliki can be used repeatedly in different applications and by different programmers, because it was time pengembanganya any faster and could cost berkurang.Tiga OOP Concepts

How do I define the three basic concepts of OOP?
 

Object-oriented programming has three basic concepts are important, namely enskaplusi, inheritance, and polymorphism. Actually, the concept is not scary like seme. Encapsulation means that the object contains (1) data and (2) processing the relevant instructions. After the object is created, objects can be reused for other programs. The use of an object can be described through the concept of class and inheritance.
 

Inheritance (inheritance) after creates an object. You can use it as a foundation for the same object which has the same behavior or characteristics. All the objects come from or interconnected to form a class.

Each class contains special instructions (method) that can. class group uniqe to arranged in a hierarchy-class or subclass. Inheritance is a method to pass from one object cirri from class to subclass in the hierarchy. So the new object can be created with the passing of traits from existing classes.

Example as follows: "Object MACINTOSH could be one example PERSONAL COMPUTER classes, which inherit properties from classes COMPUTER SYSTEM". If you want to add a new computer, such as COMPAQ, you just enter what makes it different computers with other computers. Characteristics of personal computers can be inherited.

Polymorphism polymorphisms means "many forms". In object-oriented programming, polymorphism means that a message (a request which was generalized) give different results based on the object that was sent. Polymorphism is very useful. With polymorphism programmer can create a procedure of object type previously unknown, but it will be known when the program is run on a computer. Freedman gave the following example: "on-screen cursor will change shape from an arrow into a line depending on the program mode". Processing instruction "move the cursor on the screen in response to mouse movements will be written as a" cursor ", and needed to make the cursor polymorphisms into any shape at the time the program starts". Polymorphism also enables a new form of the cursor can be easily diitegrasikan into the program
.
READ MORE - Object-oriented programming
 
THANK YOU FOR VISITING