Test-Driven Development: Software Engineering Application Software System
Test-Driven Development: Software Engineering Application Software System
Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test and finally refactors the new code to acceptable standards. Kent Beck, who is credited with having developed or 'rediscovered' the technique, stated in 2003 that TDD encourages simple designs and inspires [1] confidence. Test-driven development is related to the test-first programming concepts of extreme programming, [2] [3] begun in 1999, but more recently has created more general interest in its own right. Programmers also apply the concept to improving and debugging legacy code developed with older techniques.
A test case in software engineering is a set of conditions or variables under which a tester will determine whether an application or software system is working correctly or not. The mechanism for determining whether a software program or system has passed or failed such a test is known as a test oracle. In some settings, an oracle could be a requirement or use case, while in others it could be a heuristic. It may take many test cases to determine that a software program or system is considered sufficiently scrutinized to be released. Test cases are often referred to as test scripts, particularly when written. Written test cases are usually collected into test suites.
Code refactoring is a "disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior",[1] undertaken in order to improve some of the nonfunctionalattributes of the software. Advantages include improved code readability and reduced complexity to improve the maintainability of the source code, as well as a more expressive internal architecture or object model to improve extensibility. By continuously improving the design of code, we make it easier and easier to work with. This is in sharp contrast to what typically happens: little refactoring and a great deal of attention paid to expediently adding new features. If you get into the hygienic habit of refactoring continuously, you'll find that it is easier to extend and maintain code. Joshua Kerievsky, Refactoring to Patterns[2] Typically, refactoring is done by applying a series of standardised basic "microrefactorings", each of which is a (usually) tiny change in a computer program's source code that either preserves the behaviour of the software or at least does not modify its
conformance to functional requirements. Many development environments provide automated support for carrying out the mechanical aspects of these basic refactorings.
Types of Errors: There are a number of errors, some obvious and others not obvious that a less experienced C programmer could make. Complex coding and tricky coding might produce the errors. These errors are like: Missing braces in the program. Improper comment characters. Undeclared variables. Forgetting to declare the function parameters. Missing semicolons at the end of the statement. Missing quotes in strings. Forgetting the precedence of operators. etc These all types of errors can be classified under four types: SYNTAX ERROES. RUN TIME ERRORS. LOGICAL ERRORS. LATENT ERRORS. We make the discussion on these errors step by step. SYNTAX ERRORS: Any violation of rules of the language result comes under syntax error. The compiler can detect and isolate these types of errors. When syntax errors present in the program then compilation fails. RUN TIME ERRORS:
A program having this type of errors will run but produce erroneous result and there for the name run time error is given to such errors. Generally it is a difficult task to isolate run time errors. LOGICAL ERRORS: As the name implies, these errors are basically related to the program execution. These errors causes wrong results and these errors are primarily due to a poor understanding of a problem, in accurate translation of the algorithms in to the program and lake of hierarchy of operation. For example: If (x=y) { Printf("they are equal"); } When x and y are equal then rarely x and y becomes equal and it will create a logical error. LATENT ERRORS: These types of errors are also known as 'hidden' errors and show up only when that particular set of data is used For example: Ratio=(x+y)/ (p-q) That statement will generate the error if and only if when p and q are equal This type of error can be detected only by using all possible combination of test data.
prompt
A symbol on a display screen indicating that the computer is waiting for input. Once the computer has displayed a prompt, it waits for you to enter some information. Generally, it will wait forever, but some programs have built-intimeouts that cause the program to continue execution after it has waited a specified amount of time.
Script (computing), a small program written for a command interpreter or another scripting language
Script
A computer script is a list of commands that are executed by a certain program or scripting engine. Scripts may be used to automate processes on a local computer or to generate Web pages on the Web.
Interactive Mode
1. Operating a system, such as a communications, computer, automatic data processing, information, or control system, so that a sequence of alternating entries and responses takes place between the system and its user similar to a face-to-face dialogue between two persons, usually so that the user can alter or interact with the system via an input-output unit, such as a display system supported by a computer, a cursor, a light pen, a stylus, a keyboard, a mouse, one or more computer programs, a menu, display commands, and a display device, such as a cathode-ray tube (CRT), a fiberscope, a gas panel, a liquid-crystal display panel, or a light-emitting diode (LED) panel. Note: The wide bandwidths, high .
parse
Analyze (a sentence) into its component parts and describe their syntactic roles.
parse
Part of the Programming glossary:
To parse is to analyze something in an orderly way. In linguistics, to parse is to divide words and phrases into different parts in order to understand relationships and meaning. For example, English students are sometimes asked to parse a sentence by dividing it into subject and predicate, and then into dependent phrases, modifiers, and so forth. In general, to parse someone's writing or speech simply means to interpret it. In computers, to parse is to divide a computer language statement into parts that can be made useful for the computer. A parser in a program compiler is a program that takes each program statement that a developer has written and divides it into parts (for example, the main command, options, target objects, their attributes, and so forth) that can then be used for developing further actions or for creating the instructions that form an executable program.
Executable
From Wikipedia, the free encyclopedia
This article is about a general type of computer file. For the specific file type used in some operating systems, see EXE.
This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (July 2008)
In computing, an executable file causes a computer "to perform indicated tasks according to encoded instructions,"[1] as opposed to a data file that must be parsed by a program to be meaningful. These instructions are traditionally machine code instructions for a physical CPU. However, in a more general
sense, a file containing instructions (such as bytecode) for a software interpreter may also be considered executable; even ascripting language source file may therefore be considered executable in this sense. The exact interpretation depends upon the use; while the term often refers only to machine code files, in the context of protection against computer viruses all files which cause potentially hazardous instruction execution, including scripts, are conveniently lumped together.
Best Answer
Software utilities/Utility Software is a type of computer system software also referred to as service program, tool, service routine, or utility routine. Software Utilities are specifically designed to help the end-user manage and tune the computer hardware/Software, Operating system or application software and perform as single precise task as opposed to application software which performs multitasking. Utility software can be seen in many operating systems to day e.g. Windows XP, Windows Vista, Mac OS X etc. Examples of some of the commonly used utility software may include the following; Disk Defragmentation System Profile/Status Virus Scanners Text Editor Archive e.g. Winrar Compression Encryption Application Launchers
appearing outside any function causes this variable to be stored in the initialized data segment with its initial value. Uninitialized data segment, often called the "bss" segment, named after an ancient assembler operator that stood for "block started by symbol." Data in this segment is initialized by the kernel to arithmetic 0 or null pointers before the program starts executing. The C declaration long sum[1000];
appearing outside any function causes this variable to be stored in the uninitialized data segment. Stack, where automatic variables are stored, along with information that is saved each time a function is called. Each time a function is called, the address of where to return to and certain information about the caller's environment, such as some of the machine registers, are saved on the stack. The newly called function then allocates room on the stack for its automatic and temporary variables. This is how recursive functions in C can work. Each time a recursive function calls itself, a new stack frame is used, so one set of variables doesn't interfere with the variables from another instance of the function.
Heap, where dynamic memory allocation usually takes place. Historically, the heap has been located between the uninitialized data and the stack.
Figure 7.6 shows the typical arrangement of these segments. This is a logical picture of how a program looks; there is no requirement that a given implementation arrange its memory in this fashion. Nevertheless, this gives us a typical arrangement to describe. With Linux on an Intel x86 processor, the text segment starts at location 0x08048000, and the bottom of the stack starts just below 0xC0000000. (The stack grows from higher-numbered addresses to lower-numbered addresses on this particular architecture.) The unused virtual address space between the top of the heap and the top of the stack is large.
Several more segment types exist in an a.out, containing the symbol table, debugging information, linkage tables for dynamic shared libraries, and the like. These additional sections don't get loaded as part of the program's image executed by a process. Note from Figure 7.6 that the contents of the uninitialized data segment are not stored in the program file on disk. This is because the kernel sets it to 0 before the program starts running. The only portions of the program that need to be saved in the program file are the text segment and the initialized data. The size(1) command reports the sizes (in bytes) of the text, data, and bss segments. For example: $ size /usr/bin/cc /bin/sh
The fourth and fifth columns are the total of the three sizes, displayed in decimal and hexadecimal, respectively.
A typical memory representation of C program consists of following sections. 1. Text segment 2. Initialized data segment 3. Uninitialized data segment 4. Stack 5. Heap
1. Text Segment: A text segment , also known as a code segment or simply as text, is one of the sections of a program in an object file or in memory, which contains executable instructions. As a memory region, a text segment may be placed below the heap or stack in order to prevent heaps and stack overflows from overwriting it. Usually, the text segment is sharable so that only a single copy needs to be in memory for frequently executed programs, such as text editors, the C compiler, the shells, and so on. Also, the text segment is often readonly, to prevent a program from accidentally modifying its instructions. 2. Initialized Data Segment: Initialized data segment, usually called simply the Data Segment. A data segment is a portion of virtual address space of a program, which contains the global variables and static variables that are initialized by the programmer. Note that, data segment is not read-only, since the values of the variables can be altered at run time. This segment can be further classified into initialized read-only area and initialized read-write area. For instance the global string defined by char s[] = hello world in C and a C statement like int debug=1 outside the main (i.e. global) would be stored in initialized read-write area. And a global C statement like const char* string = hello world makes the string literal hello world to be stored in initialized read-only area and the character pointer variable string in initialized read-write area. Ex: static int i = 10 will be stored in data segment and global int i = 10 will also be stored in data segment 3. Uninitialized Data Segment: Uninitialized data segment, often called the bss segment, named after
an ancient assembler operator that stood for block started by symbol. Data in this segment is initialized by the kernel to arithmetic 0 before the program starts executing uninitialized data starts at the end of the data segment and contains all global variables and static variables that are initialized to zero or do not have explicit initialization in source code. For instance a variable declared static int i; would be contained in the BSS segment. For instance a global variable declared int j; would be contained in the BSS segment. 4. Stack: The stack area traditionally adjoined the heap area and grew the opposite direction; when the stack pointer met the heap pointer, free memory was exhausted. (With modern large address spaces and virtual memory techniques they may be placed almost anywhere, but they still typically grow opposite directions.) The stack area contains the program stack, a LIFO structure, typically located in the higher parts of memory. On the standard PC x86 computer architecture it grows toward address zero; on some other architectures it grows the opposite direction. A stack pointer register tracks the top of the stack; it is adjusted each time a value is pushed onto the stack. The set of values pushed for one function call is termed a stack frame; A stack frame consists at minimum of a return address. Stack, where automatic variables are stored, along with information that is saved each time a function is called. Each time a function is called, the address of where to return to and certain information about the callers environment, such as some of the machine registers, are saved on the stack. The newly called function then allocates room on the stack for its automatic and temporary variables. This is how recursive functions in C can work. Each time a recursive function calls itself, a new stack frame is used, so one set of variables doesnt interfere with the variables from another instance of the function.
5. Heap: Heap is the segment where dynamic memory allocation usually takes place. The heap area begins at the end of the BSS segment and grows to larger addresses from there.The Heap area is managed by malloc, realloc, and free, which may use the brk and sbrk system calls to adjust its size (note that the use of brk/sbrk and a single heap area is not required to fulfill the contract of malloc/realloc/free; they may also be implemented using mmap to reserve potentially non-contiguous regions of virtual memory into the process virtual address space). The Heap area is shared by all shared libraries and dynamically loaded modules in a process. Examples. The size(1) command reports the sizes (in bytes) of the text, data, and bss segments. ( for more details please refer man page of size(1) ) 1. Check the following simple C program
#include <stdio.h>
[narendra@CentOS]$ gcc memory-layout.c -o memory-layout [narendra@CentOS]$ size memory-layout text data bss dec filename 960 248 8 1216 memory-layout
hex 4c0
2. Let us add one global variable in program, now check the size of bss (highlighted in red color).
#include <stdio.h>
[narendra@CentOS]$ gcc memory-layout.c -o memory-layout [narendra@CentOS]$ size memory-layout text data bss dec filename 960 248 12 1220 memory-layout
3. Let us add one static variable which is also stored in bss.
#include <stdio.h>
hex 4c4
int main(void) { static int i; /* Uninitialized static variable stored in bss */ return 0; }
[narendra@CentOS]$ gcc memory-layout.c -o memory-layout [narendra@CentOS]$ size memory-layout text data bss dec filename 960 248 16 1224 memory-layout
hex 4c8
4. Let us initialize the static variable which will then be stored in Data Segment (DS)
#include <stdio.h>
int main(void) { static int i = 100; /* Initialized static variable stored in DS*/ return 0; }
[narendra@CentOS]$ gcc memory-layout.c -o memory-layout [narendra@CentOS]$ size memory-layout text data bss dec filename 960 252 12 1224 memory-layout
hex 4c8
5. Let us initialize the global variable which will then be stored in Data Segment (DS)
#include <stdio.h>
int main(void) { static int i = 100; /* Initialized static variable stored in DS*/ return 0; }
[narendra@CentOS]$ gcc memory-layout.c -o memory-layout [narendra@CentOS]$ size memory-layout text data bss dec filename 960 256 8 1224 memory-layout
hex 4c8
Sorting Arrays
Sorting Arrays
* Definition: Sorting is the process of putting data in order; either numerically or alphabetically.
It is often necessary to arrange the elements in an array in numerical order from highest to lowest values (descending order) or vice versa (ascending order). If the array contains string values, alphabetical order may be needed (which is actually ascending order using ASCII values). The process of sorting an array requires the exchanging of values. While this seems to be a simple process, a computer must be careful that no values are lost during this exchange. Consider the following dilemma: Suppose that grade[1] = 10 and grade[2] = 8 and you want to exchange their values so that grade[1] = 8 and grade[2] = 10. You could NOT just do this: grade[1] = grade[2]; grade[2] = grade[1];
In the first step, the value stored in grade[1] is erased and replaced with grade[2]. The result is that both grade[1] and grade[2] now have the same value. Oops! Then what happened to the value in grade[1]? It is lost!!! In order to swap two values, you must use a third variable, (a "temporary holding variable"), to temporarily hold the value you do not want to lose: //swapping variables temp = grade[1]; // holding variable grade[1] = grade[2]; grade[2] = temp; This process successfully exchanges, "swaps", the values of the two variables (without the loss of any values). Remember the example in class of the two horses switching stalls!!
swap them if they are in the wrong position. The bubble sort is one of the easiest algorithms to understand and we will begin our investigation with this sort.
Click to see the codings of these various algorithms: Bubble Sort Exchange Sort Selection Sort Insertion Sort Shell Sort Quick Sort Merge Sort
There are often built-in search and sort "routines" in various C++ compiler packages (such as bsearch, lfind, lsearch, and qsort). These routines were not designed to be used with apvectors. The use of these routines also requires an understanding of "pointers", which we have not yet discussed. It is imperative that you, the programmer, know and understand at least one method of searching an array and one method of sorting an array, separate from any built in "routines."
Program in the C programming language to sort all the elements in the array in the ascending order. This programs uses the bubble sort method to sort the numbers in ascending order. Definition Bubble Sort- Bubble sort is a simple sorting technique in which passes are used and after each pass larger no. obtains its sorted position. To sort the elements n-1 passes are used
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 } } getch(); printf("\n\n Array in the ascending order is - \n"); for(i=0;i<n;i++) { printf("\t %d",ar[i]); } } } for(i=0;i<n;i++) { for(j=0;j<n-i;j++) { if(ar[j]>ar[j+1]) { tmp=ar[j]; ar[j]=ar[j+1]; ar[j+1]=tmp;
01 // Find maximum and minimum element in an arary. 02 #include<stdio.h> 03 int 04 main () 05 { 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 } } } else if (a[i] < min) { min = a[i]; for (i = 0; i < 10; i++) { if (a[i] > max) { max = a[i]; int i; int a[10] = { 10, 55, 9, 4, 234, 20, 30, 40, 22, 34 }; int max = a[0]; int min = a[0];
Code
? 1 2 3 4
22 void main() #include<stdio.h> #include<conio.h>
5 6 7 8 9 10 11 12 13 14 15 16 17
printf("\nEnter the value of b:"); scanf("%d",&a); printf("Enter the value of a:"); clrscr(); int a,b,c; {
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
scanf("%d",&b);
scanf("%d",&c);
if(a>b)
{if(a>c)
printf("a is largest");
else
printf("c is largest");}
else
if(b>c)
printf("b is largest");
else
printf("c is largest");
44 45 46
23 24 25 26 }
getch();
return 0;
06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 }
int i; int a[10] = { 10, 55, 9, 4, 234, 20, 30, 40, 22, 34 }; int max = a[0]; int min = a[0];
for (i = 0; i < 10; i++) { if (a[i] > max) { max = a[i]; } else if (a[i] < min) { min = a[i]; } } printf ("Maximum element in an array : %d\n", max); printf ("Minimum element in an array : %d\n", min);
return 0;
printf("\nThe factors are:"); for(x=1; x<=no; x++) { if(no%x==0) printf("\n%d",x); } getch( ); } Output:Enter the required number: 27 The factors are: 1 3 9 27
C programming code
#include <stdio.h> main() { int n, reverse = 0; printf("Enter a number to reverse\n"); scanf("%d",&n); while (n != 0) { reverse = reverse * 10;
reverse = reverse + n%10; n = n/10; } printf("Reverse of entered number is = %d\n", reverse); return 0; }