Archive

Posts Tagged ‘variables’

Introduction To Software Testing

July 19th, 2009 bodom_lx No comments

Elements and Concepts – A brief overview


Download PDF version of the whole document. You can browse the article online but I encourage the download of the PDF since it is written with accuracy.


Introduction

This document contains some basic concepts and definitions about software testing. It has been written for studying a part of the Software Engineering Project course at my University. It is composed by a summary of the intersection of more than 10 different sources, all of which are cited. If you feel that some contents of this publication belong to your intellectual property and it is not cited, please contact the author who is willing to correct any mistake.

The first part of the paper focuses on the definition of the most important key aspects of software testing. Then some information about input partitioning are given. What follows is a research about code coverage and two useful and famous tools, Control-flow coverage and Data-flow analysis. A complete example on using those tools is then given. The second half of the document also contains the definition of the most important software testing practices.

The goal of this tiny document is to clarify key terms and therefore become a base start for the reader to go in deep with the interested topics. Another goal is to give a simple but clear example about data flow analysis, as I realized that not all the people understand the examples around the Net.

Software Testing

Software Testing is an empirical investigation conducted to provide stakeholders with information about the quality of the product or service under test, with respect to the context in which it is intended to operate. Software Testing also provides an objective, independent view of the software to allow the business to appreciate and understand the risks at implementation of the software. Test techniques include, but are not limited to, the process of executing a program or application with the intent of finding software bugs. It can also be stated as the process of validating and verifying that a software program/application/product meets the business and technical requirements that guided its design and development, so that it works as expected and can be implemented with the same characteristics. 1

Read more…

Related posts

Heap vs. Stack in C++

March 20th, 2009 bodom_lx 4 comments

After the study of pointers versus references, the second natural question that comes in head of a ex Java developer turning to C++ is:

“What are the difference between static and dynamic memory allocation in C++?”

which can be translated as:

“When should I use the stack and when do I have to use the heap in C++?”

that can be further simplified to:

“When should I use the new operator in C++?”

I could simply summarize the answer to: “Use stack when possible”, but I think that this time there is the need of more explanations. Let’s have the following model for a process in the system:

A simplified model for a process

A simplified model for a process

I’m not really interested in an real representation of a process (see Modern Operating Systems by A. S. Tanenbaum for a very good explanation on processes), but focus on the stack and on the heap.
In reality the heap is a software abstraction but you can also imagine it like the stack.
In C++ programs there are also several other memory areas in which objects and non-object values may be stored (see this article on GotW for further details).

Why then choose between stack or heap? Quoting my publication on object-oriented memory management in Java:

Stack-based variables have their extent determined by their scope, so the former is constrained by the structure of the code at compile-time .

Sometimes there is a need for the variables with unconstrained extent in order to cope with
problems where lifetime of a variable can only be known at run-time.
In this case heap-based variables, whose extent is strictly under control of the programmer, are used. [..]

I promise that I will update my 17 pages about OO-memory management to cover also C++ by the end of June. By the way, following some forums, wikipedia, my publication and GotW, I also summarized pros and cons of stack and heap use in C++:

Stack Heap
Its size is determined at compile-time Size determined at run-time
Therefore, it is less expensive and quick Therefore, it is more expensive and slower than stack
The preferred way to store objects and variables if their size is limited. To be used only if needed: the amount of memory needed is variable and unknown, and may increase rapidly.
There is an AUTOMATIC CLEANUP of objects when they go out of their scope Objects STAY IN MEMORY even when you don’t use them anymore.
Programmers don’t have to bother to free resources Therefore, programmers HAVE TO CLEAN memory manually. However, all modern OS free the resources when the program exits.

Update 2009-07-03
After 4 months of heavy GUI and Database C++ programming, here are my thoughts: if you are planning to write a program with something more than a couple of objects interacting, using associations and therefore, objects as attributes, use the heap. Every serious program, even if not really big, uses heap for object allocation. Just take care to delete the objects when you don’t need them anymore. Objects on the heap are dynamically allocated and it is more comfortable to pass them through other objects using pointers. The use of the heap assures the live of objects even if the method that generated them runs out of scope ( =dies ). If you also plan to write GUIs, solid toolkits like QT recommend the use of heap to create graphical objects.

In some Operating Systems, stack is also very limited while heap is usually not.

Here are listed the sources I used for writing this article:

  • http://www.velocityreviews.com/forums/t278261-stack-vs-heap.html
  • http://www.computing.net/answers/programming/stackheap-c/2293.html
  • http://www.codeguru.com/forum/showthread.php?p=1186307#post1186307
  • http://www.codeguru.com/forum/showthread.php?t=350945
  • http://www.gotw.ca/gotw/009.htm
  • http://en.wikipedia.org/wiki/Process_(computing)#Representation
  • http://task3.cc/object-oriented-memory-management/

Hope that this article helped you to clearly understand the differences between stack and heap allocation in C++, write me if there are other issues or you need more explanations!

Related posts

BD-shell

April 21st, 2008 bodom_lx No comments

BD-shell (a.k.a. bdsh) is a tiny Unix shell written in C. It’s a project required for the Operating System Course at my University.
It is written using a clean coding style, following xP coding standard philosophy.
Version 1.0 is the release that satisfies all the course requirements!

Quick Jump:
Features
Download
License

Features

Cool Features

  • Lightweight
  • Implements real Job Control
  • Clear and understandable code, ideal for Academic (and personal) studies
  • Makes use of various system calls, signals, signal handlers, user input handling, data structures implementation
  • Free Software!

Cool Features NOT present (but may be in future)

  • No command history present
  • No command/filename auto completion
  • No wildcars
  • No command piping, just a single command can be launched at a time
  • Put everything else here.
These are the requirements asked by the teaching professor. The complete project description page is located at http://www.inf.unibz.it/~david/os/project.html
The shell must be able to do the following:

  1. to read commands from standard input and execute them in a loop until a
    built-in command exit is issued (we call these processes the foreground processes; there is always at most one of these at any particular time);
  2. be able to redirect the standard input and output of commands by prefixing them with built-in commands in file and out file;
  3. be able to terminate (involuntarily) the foreground process when user presses ^C and return back to the mini-shell;
  4. be able to interrupt the foreground process temporarily, when user presses ^Z, returning to the mini-shell;
  5. be able to execute any number of processes in background (i.e., in parallel with the foreground process), including in particular, the ability to start another process while a process has been temporarily suspended;
  6. inform the user when the background process finishes or is
    waiting for an input from the terminal;
  7. be able to inform the user what commands are executing in the background by issuing the built-in command jobs, this should include information about the state of the process (i.e., suspended, background, waiting for input, etc.) and about what file(s) is the background process using for standard input and output);
  8. be able to terminate involuntarily a background processes by issuing the built-in command kill job-number.
  9. to be able to resume a process or to make a background process into the foreground process (i.e., the one that currently interacts with the terminal) by issuing the fg job-number command.

Download:

  • 2008-09-14 – version 1.0.0.
    • fixed synchronization bug in putJobBackground() that made not notify background processes requesting input (in some situations)

    Known Bugs:

    • Lots of! I consider bdsh-1.0.0 stable because it covers ALL requirements of the course and does them whell on various Unix systems. So it works, but commands like “in non_existent_file cat” won’t work and will crash it!

    What will be next?

    • I don’t know. I may consider a 1.0.1 release to fix future bugs. I may also think to add cool features to make the shell complete. I hope I will have the time for it. You can also do it by yourself and send me the code
  • 2008-09-13 – version 1.0.0 Release Candidate 2.
    Changes from beta 1 / release candidate 1

    • removed gcc O3 flag from makefile
    • lots of bugs fixed in functions operating on the list of jobs
    • improvements in launchJob() when dealing with background commands
    • bug in putJobBackground() that made the shell crash has been fixed
    • killJob() now sends a SIGKILL
    • bugs fixed in signalHandler_child()
    • Code formatted using astyle (linux style)
    • A couple of variables renamed
    • Various usleep() removed

    Known Bugs:

    • So many =) This is a shell made for Academic purposes, not for production use!
  • 2008-07-30 – version 1.0.0 beta1.
    Characteristics:

    • First beta release of the final version
    • Every requirement has been covered
    • Real Job-Control implemented
    • About every function of bdsh.c has been rewritten
    • New source directory layout, very clean
    • Some documentation and makefile
    • IMPORTANT! this has to be considered a bug hunting release! Please report me any bugs
  • 2008-06-05 – version 0.7.1, corrects the linked list bug of version 0.7.0
  • 2008-05-09 – version 0.7.0.
    UPDATE 2008-06-05: there is a bug in the list handling, the shell crashes when using the standard input redirection. Please download version 0.7.1, which corrects the problem.
    Characteristics:
    • Cleaner code!
    • Lots of bugs fixed!
    • reads commands from standard input and executes them in a loop until a built-in command exit is issued
    • redirects STDIN and STDOUT of commands by prefixing them with built-in commands in file and out file
    • terminates (involuntarily) the foreground process when user presses ^C and return back to the shell
    • executes any number of processes in background (i.e., in parallel with the foreground process)
    • informs the user when the background process finishes
    • informs the user what commands are executing in the background by issuing the built-in command jobs
    • terminates involuntarily a background processes by issuing the built-in command kill job-number.
  • Due to a lots of compatibility issues with Gnu/Linux (the shell has been developed under Mac Os X), the final released has been delayed to mid-September. Sorry for this, I encountered so many problems the day before project presentation, that I decided to present it during the next exam session. I switched back to Gnu/Linux, too :)
  • Final release is scheduled on 2008-06-26, as the project deadline is 2008-06-25. The release will
    satisfy all the requirements, and as addition:

    • Execution system totally rewritten (e.g. one single short function that handles everything)
    • A Job Control will be implemented
    • Processes in foreground will really be in foreground, there are a lot of things that we did not learn during the course, like tcsetpgrp()
    • Some functions in utils.h will be deleted and optimized
    • Cleaner and clearer code!

  • 2008-04-21 – version 0.0.1
    Characteristics:
    • Modular code, divided in 3 files: bdsh.c, utils.h, headers.h
    • Clean user input from a char buffer to an array of strings
    • Built-in commands: exit (exits from the shell), cd (changes directory), in <filename> command (redirects STDIN of command from <filename>), out <filename> command (redirects STDOUT of command to <filename>)
    • Makes use of fork() to read commands from standard input and execute them

License:

BD-shell is released under The Gnu GPL version 3! This is different from the license of the contents of the blog

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http ://www.gnu.org/licenses/>>.

Related posts

Scrum Development Process

April 17th, 2008 bodom_lx No comments

For Programming Project course we’re adopting Scrum as software development process.
Scrum focuses on agile-like project management. The goal of Scrum is to deliver as much quality software as possible within a series of short intervals called Sprints. Scrum concentrates on identifying project variables (quality, time, requirements, etc.) and monitoring them constantly.

This process has been brought to our attention by prof. Pekka Abrahamsson, a guest professor that will stay with us until june.

I will update this page with new information as soon as they will be availabe.
These are the principal roles in Scrum:

Scrum Master: responsible for ensuring that the project is carried through according to the rules of Scrum and that it progesses as planned
Product Owner: responsible fot the project, managing and controlling. Makes the final decisions of the tasks related to a product backlog
Scrum Team: the project team that decides on the necessary actions and to organize itself in order to achieve the goals
Customer: participates in the tasks related to product backlog
Management: in charge of final decision making

Here is a nice model I drew yesterday, of the principal concepts of the Scrum method:

Related posts

OO Memory Management Model summary updated

April 6th, 2008 bodom_lx No comments

Today I wrote a new version of my summary posted here. The new version covers more topics, here is the updated list:

  • Memory portions assigned to a program (code area, heap / dynamic memory area), execution stack
  • How code is loaded in Java
  • The Activation Record (AR) and function calls
  • Abbrevations (AR, RV, RA, SP, N/E, @, ??, arb)
  • Examples on method calls and activation records usage
  • Declaraion vs. Definition of a variable, the scope of a variable, blocks
  • Scope Activation Record (SAR), Static Link (SL), the role of SL
  • The extent/lifetime of a variable
  • Dynamic memory allocation and handling
  • Dynamic vs. Static memory allocation
  • Dynamic memory scope and extent
  • Accessing dynamic memory
  • Classes and Objects in detail, object instantiation
  • Memory Management issues
  • Objects vs. Variables (definitions)
  • Methods of Objects
  • Class Attributes
  • The null value
  • Parameters (formal, actual), parameters passing (by reference, by value)
  • Constructors and Inline Initialization
  • Constructor’s call

Related posts

Object Oriented Memory Management

March 19th, 2008 bodom_lx No comments

Major Update on 10th April 2009, inclusion of C++ programming language!
Updated on 18th April 2008, a complete example on stack and heap
Updated on 15th April 2008, new contents and new layout!
Updated on 6th April 2008, new contents!

The paper you can download from here is about a model for memory management during the execution of programs written in Java and C++.

It started on March, 2008 as a summary of the lecture notes of both the “Programming Project” and
“Software Engineering Project” courses held by professors of the CASE (Center for Applied Software Engineering) of the Free University of Bolzano – Bozen.

The first versions of this publication were only about Java memory management.
Subsequent revisions added information found on other sources. Unfortunately, the author forgot to
reference the sources on the document.

On March, 2009 the author began to add the information about C++ programming language. More
information from other sources were added, including their attribution.

The biggest source of this document is still the set of presentations of CASE.
The code snippets and their corresponding stack/heap diagrams are copied in full from those of the
slides.

The next major revision will contain original images (not belonging to CASE slides), as well as other code
snippets that I could find more clear than those of CASE.

If you find that this document contains information taken from one of your publications, please
contact the author, that is willing to either delete them from this document or to add an attribution to
your work.

Download the PDF of the summary

Table of Contents:

  • The model
  • Code load and execution
  • Activation Record (AR)
  • Contents of the Activation Record
  • Abbreviations for
  • Declaration vs. Definition
  • The scope of a variable
  • Extent of a Variable
  • Blocks
  • Scope Activation Record (SAR)
  • Example on SAR
  • Role of SLs
  • Dynamic Memory Allocation And Handling
  • Dynamic Vs. Static memory allocation
  • Dynamic Memory Scope and Extent
  • Accessing dynamic memory
  • Classes
  • Objects
  • Object instantiation
  • Objects in Memory (Java)
  • Objects in Memory (C++)
  • Memory Management issues (Java)
  • Memory Management issues (C++)
  • Methods
  • Methods (Java)
  • Methods (C++)
  • Attributes
  • The null value (Java)
  • The NULL value (C++)
  • Parameter
  • Parameter Passing (Java)
  • Example of parameters passing (Java)
  • Example of parameters passing (Java), continued
  • Parameter Passing (C++)
  • Example of parameters passing by value (C++)
  • Example of parameters passing by reference (C++)
  • Pointers vs. Parameters (C++)
  • Previous example using pointers (C++)
  • Constructor
  • Inline initialization
  • A constructor’s call (Java)
  • Class attributes
  • Example of class attributes (Jav)
  • Example of class attributes (C++)
  • Class Method
  • Example of Stack/Heap Diagrams in Java
  • Code
  • Stack Diagram
  • Heap Diagram
  • Memory portions assigned to a program (code area, heap / dynamic memory area), execution stack
  • How code is loaded in Java
  • The Activation Record (AR) and function calls
  • Abbrevations (AR, RV, RA, SP, N/E, @, ??, arb)
  • Examples on method calls and activation records usage
  • Declaraion vs. Definition of a variable, the scope of a variable, blocks
  • Scope Activation Record (SAR), Static Link (SL), the role of SL
  • The extent/lifetime of a variable
  • Dynamic memory allocation and handling
  • Dynamic vs. Static memory allocation
  • Dynamic memory scope and extent
  • Accessing dynamic memory
  • Classes and Objects in detail, object instantiation
  • Memory Management issues
  • Objects vs. Variables (definitions)
  • Methods of Objects
  • Class Attributes
  • The null value
  • Parameters (formal, actual), parameters passing (by reference, by value)
  • Constructors and Inline Initialization
  • Constructor’s call
  • Class attributes (static variables)
  • Class methods (static methods)
  • Complete Example of Stack/Heap Diagrams

Everything is integrated with simple examples.

Download the PDF of the summary

Related posts