Subscribe by Email


Showing posts with label Programmer. Show all posts
Showing posts with label Programmer. Show all posts

Saturday, May 19, 2012

Explain simple loops in detail?


Loops are such an important programming constructs for various object oriented languages that they cannot be neglected. All of us are aware of the looping constructs that we have in programming languages like C and C++. We have three basic loops:
  1. For loop
  2. While loop
  3. Do while loop

Why Loops are Important?


- Loops find extensive use in programming and they are a means to tell the program to keep executing a set of statements until some break condition is encountered.
- Loops come to be a very handy tool when it comes to the repetition of the whole block of code. 
- It can be done to reduce the length of the code and the task of the programmer or developer of writing the same code again and again innumerable times. 
- In some cases it also happens that the number of times for which the loop is to be executed is obtained from the user, in such cases looping of the particular block of code becomes extremely important. 
-There are many software programs or applications that perform very complex tasks or calculations all by the virtue of the looping constructs. 

Before taking on the loops in to your software program you should be well versed with the true and false concept of the programming language that you are using. Let us discuss all the above mentioned three loops one by one:

                1.  For Loop: 
               Here’s the syntax of the for loop:

For (initialization of the variable; test condition; increment condition)
{
Statement 1;
Statement 2; (code to be executed)
.
.
.
Statement n;
}
In the expression for the initialization of the variable one can declare the variable for the loop and initialize it with the required value. Secondly the test condition is responsible for checking the whether the loop should be executed or not on the basis of the true or false value. The increment condition lastly helps the loop to increment the value of the initialized variable. All of these 3 expressions are separated from each other by semicolon. An empty condition is evaluated to false value.

2. While Loop: 
Here’s the syntax for the while loop:

While( test condition)
{
Statement 1;
.
.
Statement n;
}
According to some programmers the while loops are perhaps the easiest to operate. While loops are supposed to be entry controlled loop since the condition is checked up on the entry itself and based on its true value it is executed. While loops are somewhat like the for loops except that they contain the initialization expression and the update expression inside their body. But the drawback with this loop is that it is quite length. This loop won’t allow the execution of the statements even once if the test condition is evaluated to be false.
      
          3. Do while loop
          Here’s the syntax for the do – while loop:
Do
{
Statement 1;
Statement 2;
.
.
.
Statement n;
} while (test condition)
This loop holds good for the programs in which the execution of a particular block of statements is required at least once irrespective of whether the test condition is true or false. The test condition is encountered in the last and is evaluated. If it is found to be false, then the loop won’t be eligible for a second iteration. Because of this factor the do while loop is commonly known as the exit controlled lop. 


Thursday, May 17, 2012

Explain nested loops in detail?



Why Loops are Important?


- Loops are an extremely important entity when it comes to the programming in languages like C and C++ i.e., to say the object orient languages. 
Loops are used to handle many other program constructs and execute the same statement or a block of statement as many times as required by the program or as specified by the user.
- Loops are either manually included in to the source code of the program or are generated in to the code by the state machine code generators or by an optimizing compiler. 

There are various types of loops but this article is limited only to the discussion regarding the nested loops. Let us see what the nested loops in detail are.
What the phrase “to nest” means?  
It means to keep one object inside the other object.  This holds good when it comes to the context of the loops also. All the types of loops can be nested in to the similar types of loops irrespective of their type.

What are Nested Loops?


- Nested loops are the loops that have been declared inside another loop which may or may not be of the same type as that of the nested loop.
- The loop which is placed inside the another loop is called the nested loop and the loop which holds this nested loop is called the parent loop.
- It is not necessary that the nested loop and the parent loop should be of similar types.
- Nesting the loops falls under the context of combining the looping procedures.
- Whenever a loop is nested, its parent loop is said to take the control of it that is the parent loop decides how many times the inner loop is to be executed. 
- Although the nesting holds good for all the types of loop, it is the for loop that dominates the line. - Once the parent loop has been iterated once, the control is transferred to the inner loop.
- After this the parent loop iterates for a second time only when the execution and iteration of the inner loop is wholly complete. 
- To say it other way round, the inner or the nested loop is triggered by the first pass of the outer or parent loop which is then executed to completion. 
- Then, the inner loop is again triggered by the second pass of the parent loop which is then executed till its complete iteration.
- This process continues till the test condition for the outer parent loop is evaluated to a false value. - If a break statement has been incorporated inside the inner loop then it may come out of the loop before all the iterations of the outer loop are complete. 
- The continue and the break commands are the two commands affecting the behavior of the both nested loops and the outer parent loops. 

Basically the nested loops find their use in the problems that involve working with matrices. Let us illustrate the working of nested with the help of the code written below:

// this code has been written to accept elements in to a 3 x 3 matrix
For ( int r = 0; r < 3; r++)
{
For (int c = 0; c < 3; c++)
{
Scanf(“%d”, &A [r] [c]);
}
}
In the above written c code two loops have been used to accept the elements for a matrix among which one is nested in to the another. The variables r and c denote the rows and columns respectively. Nested loops can be thought of as a logical structures which consist of two repeating statements are placed in the nested that is one inside the other. 


Thursday, May 3, 2012

What are the requirements in a test driven development?


The test driven development is often abbreviated as “TDD” and has been recognised as one of the common development strategies that are quite popular among the developers and the programmers. 

What is a Test Driven Development?
- This development methodology involves the repetition of short typical development cycles.
- These development cycles are shorter in duration when compared to the usual development cycles of the other software development strategies.
- The developer first requires writing a failing automated test case defining a desired new function or an improvement in an already existing function. 
- A code is then written to pass the test and later it is subjected to refactorization to meet the acceptable standards. 
- Test driven development is often considered to be related to the extreme programming to some extent.
But, now it is being considered as a development process of its own rules and objectives.
- The test driven development also serves to improve and debug the legacy code that has been developed using the other methodologies. 

No development methodology can be carried out further without requirements, this holds true for the test driven development also. This article emphasize on the requirements of the test driven development. 

Requirements in a Test Driven Development
- The whole methodology of test driven development is supported by a set of unit tests that are automated. 
These automated test cases are written in order to define the requirements of a particular piece of the code. 
- Such unit tests first identify the requirements and then immediately write down the code for the identified requirements all by themselves. 
- Certain assertions i.e., the true and false values are also contained in those automated unit tests. 
- The code is continually evolved and re-factorized and then subjected to testing via the automated unit tests which are put up on an automated testing frame work such as xUnit.
- Such frame works facilitate the automatic execution of the unit tests.
- These small unit tests drive the development of a small fragment of the solution.
- These unit tests also serve a tested and canonical documentation for the usage of the program’s object. 
- In the test driven development, writing the test is given the first preference rather than writing the code first. - But, this approach is considered to be difficult by many of the software programmers and developers and even some resist the use of the test driven development methodology since for them it turns out for them as the upside down approach for development.
- The test driven development methodology takes in to consideration the fact that the test is the rightmost important thing and it is required that we make sure that the test passes. 

But what is to be done if the unit tests itself are wrong and do not suffice for providing adequate coverage to the code? 

- If it is the latter case i.e., if the tests are not able to provide enough coverage then there is one possibility that your unit tests are missing out some of the requirements of the code. 
- This often happens in the case of manual testing but not so when we use the automation techniques.
- Automated unit tests make sure that no requirement of the code is left uncovered.
- So, the quality of the unit tests defines the quality of the whole test driven development process also. 

Starting with the requirements is known as the top down approach and is more commonly followed than the bottom up approach. The requirements are treated as the executable tests which are clarified by the managers, stake holders and developers. 


Saturday, April 14, 2012

What are the advantages and limitations of a mock object?

Mock objects are nowadays quite popular with the testers. The mock objects are now being used widely for conducting unit testing and also in many software development processes like the test driven development.

- The mock objects are known for their mimicking behaviour of the other non mock or original objects for which they have been created.

- The mock objects are used under the context of the object oriented programming.

- They are nothing but the fake objects that are simulated in a way as to mimic the behavior of the real objects in a way that is properly controlled and defined.

- The behavior of most of the non mock or real objects is tested against the behavior of a mock object.

- You can compare the mock object with a crash test dummy that is used by the car designers to the impact of the vehicle on the human body.

Reasons for Use


Few of them have been mentioned below:

1. The real object provides non deterministic result like current temperature and time.
2. The real object has the states that cannot be easily recreated or reproduced such as a network error.
3. The real object is quite slow such as a data base that needs initializing before the commencing of the test.
4. The real object does not exist currently.
5. The real object tends to change its behaviour.
6. The real object is to include the information for the testing purposes.

Advantages of Mock Object



- One of the characteristic of the mock objects is that they possess the same interface as that of the real objects that they mimic.

- With such an arrangement the client stays unaware of whether he is using the real object or the mock object.

- With the use of mock objects it becomes easy for the programmer to specify which and all methods will be invoked and in what order and it can also be specified which parameters are to be passed to the mock objects.

- All this is done by using the mock object frame works.

- The mock objects can even mimic the behaviour of the complex objects, for example the network socket.

- The use of mock objects can help the programmer in various ways.

- The programmer can determine whether the object that is under test responds well to the variety of situations it is put in works properly or not.

Limitations of Mock Object


- Use of mock objects can lead to close coupling of the several unit tests similar to that in the actual implementation of the code that is under testing.

- If a programmer is using the mock object frame work, the order of and number of times the mock methods are to be invoked on a mock object can be specified.

- If the code is subsequently refactored, it may fail even though the contract of the previous implementation is followed in the method.

- The unit tests are known to test only the external behaviour of the mock methods rather than testing its internal implementation.

- Therefore, maintenance needed for the tests increases if there is an overuse of the mock objects.

- Mock objects need to model the real objects perfectly well which becomes difficult if the real object has not been written yet.


Saturday, January 7, 2012

What are different aspects of exploratory testing?

Exploratory testing is a usual approach to software testing and can be defined as a test designing, test execution and simultaneously learning process.

It was named by Cem Kaner in 1983. "He stated exploratory testing as a kind of software testing that is emphasized and focused up on the responsibility and the personal freedom of the software tester to optimize the quality and effectiveness of his /her work continually by taking in to consideration mutually supportive activities like test designing, test related learning, test result interpretation and test execution".

These activities run in parallel to each other.

- Exploratory testing basically heeds to exploiting the creativity of the tester or the programmer.
- During the testing of the software, the tester comes across various new things to learn together with experiencing them.
- The tester or the developer with his /her creativity can generate new and better test cases to run.
- Exploratory can be thought of as a black box testing methodology or technique instead of thinking of it as an approach to testing that can be used for any type of testing methodology and also at any phase of development of the software system or application.

According to some misconceptions, the testing technique or the object is considered to be the key here but, it is not so.
- In actual, the key is the cognitive engagement of the software tester and his /her responsibility of managing time.
- The effectiveness of the exploratory testing depends basically on how it is performed.
- Exploratory testing should always be performed by skilled testers or developers.
- Exploratory testing can also be thought of as an intellectual activity.
- Exploratory testing is all about discovering how the software system or application actually works and how it handles both the easy and difficult cases.

The effectiveness or the quality of the testing is largely dependent on the skills for developing test cases by the tester.
- It also depends on his/ her ability to find defects in the software code.
- We can say that the quality of the testing is directly proportional to the knowledge of the tester about the software product and different test methods.
- The more he/ she know about the software system under test and testing methodologies, the better will be the exploratory testing.
- While carrying out the exploratory testing, the expectations should be kept open.
- Only some results can be expected or predicted but not all.
- The tester is responsible for configuring, operating, observing and evaluating the product itself and its behavior, investigating the result and reporting information. - If we see practically the actual testing is a combination of both scripted testing and exploratory testing but, depending on the context of the testing the tendency is towards either one.
- Exploratory testing is more about thinking how the testing should be done more than a testing technique.

The documentation part of the exploratory testing includes:

- Documentation of all the test cases used.
- Documentation of the bugs.

Exploratory testers use tools like:
- Screen capture
- Video tools

These tools are used to generate situations of interest or as a record of the exploratory session. For exploratory testing less before hand testing is needed. Bugs are discovered quickly and the approach tends to be more intellectual. Deductive reasoning based on the results of the previous tests can also be used in the exploratory testing. This leads to increased bug detection when used properly. The main disadvantage is that the tests can’t be reviewed before hand.


Saturday, April 2, 2011

Users involved in Development Process and End-Users who are involved indirectly in the development process...

GUIDELINES FOR END-USERS
The higher the level of the manager, the less he or she is likely to care about computer technology.
The goals and priorities of management may be in conflict with those of the supervisory and operational users.
Management may not provide resources, funding or time that the users feel is necessary to build an effective system.

The end users involved indirectly in the development process are auditors, standard bearers, and quality assurance group.
The objective of this group is to ensure that the system is developed in accordance with various standard set:
- standards by other departments.
- standards by government regulatory agencies.
- accounting standards.
- they do not get involved until the end of project.
- they provide the necessary notation and format of documentation.

Development Team
It is responsible in building the software that will supporta domain specific system.
System Analyst
Responsibility is understanding the system. Within this system, he identifies customer wants, and documents and prioritizes requirements.
System Designer
Responsibility is to transform a technology free architectural design that will providethe framework within which the programmers can work.
Programmers
Responsibility of the programmers is to write the codes of the software using a particular programming language based on system design.
Testers
Work product should be reviewed for faults and errors. It ensures thatwork products meet requirements and standards defined.


Sunday, October 3, 2010

Verification Strategies - Overview to Walkthroughs.

Walkthrough is a static analysis technique in which a designer or programmer leads members of the development team and other interested parties through a segment of documentation or code, and the participants ask questions and make comments about possible errors, violation of development standards, and other problems.
the objectives of Walkthrough can be summarized as follows:
- Detect the errors early.
- Train and exchange technical information among project teams which participate in the walkthrough.
- Increase the quality of the project, thereby improving morale of the team members.
The participants in walkthroughs assume the role of a walk-through leader, recorder, author and a team member.
To consider a review as a systematic walk-through, a team of at least two members shall be assembled. Roles may be shared among the tam members. the walk-through leader or the author may serve as the recorder. The walk-through leader may be the author.
Individuals holding management positions over any member of the walk-through team shall not participate in the walk-through.

Input to the walk-through includes:
- A statement of objectives for the walk-through.
- The software product being examined.
- Standards that are in effect for the acquisition, supply, development, operation and/or maintenance of the software product.
- Any regulations, standards, guidelines, plans, and procedures against which the software product is to be inspected.
- Anomaly categories.

The walk-through shall be considered complete when
- The entire software product has been examined.
- Recommendations and required actions have been recorded.
- The walk-through output has been completed.


Facebook activity