C preprocessor or cpp is a program that is executed prior to the execution of the compiler. It’s very important as it removes all the comments from the source and performs textual substitution based on the code and passes it to the compiler for actual compiling and it also handles directives for the inclusion of source files. Consider the following statement:
#define
This is the way all macros and defines are declared. Before the start of compilation, the preprocessor resolves all of the defines. Macro is also a kind of define, but it is capable of appearing to perform some logical operations, math’s functions and it has a unique name. While defining a macro, it is imperative that there should be no space between the name of the macro and opening parentheses. If a space is present, it makes it difficult for the compiler to determine whether its macro or not. Instead it’ll handle it like a simple substitution define statement.
Often there are a lot of extra parentheses in a macro definition but they are extremely important. Most experienced C programmers always put parentheses around each and every variable in a macro and entire expression. This avoids error and allows any macro to work properly. A macro cannot be expanded within a quoted string, although, the arguments’ text can be quoted and that will be treated as a string literal. This can be done using “#” directive. There are macros called variadic macros which can take a varying number of arguments. They are useful when writing wrappers to variables of number functions. X macro is a header file which contains a list of similar macro calls. Macros are of two types namely object-like and function-like.
Object like macros do not accept parameters whereas function like macros do. Function like macro should not have a whitespace between the variable and the opening parentheses. Presence of a whitespace will make the compiler treat it as an object like macro. Object like macros are conventionally used to create symbolic names for constants and are generally considered as part of good programming. You can extend a macro across many lines by using a back slash escape sequence at the end of every line. The ternary conditional operator “?:” is also a function like macro. Token pasting or concatenation is another very easy to abuse feature of C preprocessor. Using this we can join together two arguments using ## preprocessor. This is basically used to create more elaborated macros. Multiple statements macros must be avoided as far as possible because they can show unexpected behavior. We can make a macro safe by replacing the semicolon with comma since it has lowest precedence.
Conditional compilation is a very useful construct and is used to include a feature if we are using a certain processor, a certain operating system and certain hardware. The following are the directives that can be used for conditional compilation: #if, #ifdef, #ifndef, #else, #elif and #endif. More trivial programs are too large and cannot be place within a single file and it becomes very cumbersome to work with. Therefore, it becomes very necessary for these files to work and communicate together as one large program.
What do we mean by pragma? It’s a kind of instruction to the compiler to perform a particular action at the time of compilation. The pragmas vary from compiler to compiler since they are not standardized. If the compiler provides a source listing file, then it does have pragmas to format output. #ptragma is used suppress specific error messages, to stack debugging and to manage heaps.
Saturday, September 3, 2011
What is a C PREPROCESSOR ? Why is it important?
Posted by
Ashish Agarwal
at
9/03/2011 12:10:00 AM
0
comments
Labels: C Language, Explanation, Preprocessor, Software, Software theory, Theory
|
| Subscribe by Email |
|
Tuesday, August 17, 2010
Regression Testing – what is it, and what is the need
Often when a bug is detected in a software product all the energy of a developer is concentrated on that particular bug that he sometimes forgets the big picture which results in introduction of many more errors into the program. This is where regression testing comes into picture. Regression testing is any type of software testing that seeks to uncover software errors by partially retesting a modified program. In regression testing systematic selection of appropriate minimum suite of tests needed to adequately cover the affected change is done. Often it is extremely difficult for a programmer to figure out how a change in one part of the software will echo in other parts of the software hence regression testing includes rerunning previously run tests and checking whether previously fixed faults have re-emerged.
For identification of regression the most accepted practice is that once a bug is located and fixed, a test that exposes the bug is recorded and regularly retested after subsequent changes from the program. Although this can be done through manual testing procedures but often automated testing tools are used for this. Such test suites contain software tools that allow the testing environment to execute all the regression test cases automatically. In some cases these suites are re-run at specific intervals and any failures are reported. Regression testing is an integral any present day software development method. Extensive, repeatable and automated testing of the entire software is done at every stage in the software development cycle. Traditionally in the corporate world, regression testing is performed by the software quality assurance team after development team has completed work. As a consequence of introduction of new bugs, program maintenance requires far more system testing per statement written than any other programming. Theoretically, after each fix one must run the entire batch of test cases previously run against the system, to ensure that it has not been damaged in an obscure way. In practice, such regression testing is very costly.
The biggest challenge faced by this kind of regression testing is that these tend to be very fragile. Fragile in the sense that even a trivial change in the application often causes the tests to report “failures” that actually indicate that the script needs to be updated to deal with the change in the application. This causes inconvenience because it often takes more time and effort to maintain these automated regression tests that it would have taken to just execute them manually.
Concluding the discussion it should be mentioned the programmer should be aware when it is useful to use regression testing and when it’s a waste of resources. If your testing mission is to unleash as many defects as possible then maybe regression testing is not a good choice but when the purpose is to demonstrate the ruggedness of some specific features of the product on a relatively stable and mature application then automated testing is the right choice for you.
Posted by
Ashish Agarwal
at
8/17/2010 11:17:00 PM
2
comments
Labels: Automated Testing, Detection, Explanation, Information, Regression, Regression Testing, Testing Strategy
|
| Subscribe by Email |
|
Tuesday, June 30, 2009
What are Routers, Switches, Hubs — Is There a Difference between them ?
Each device has its own function in a network environment. Two reasons confusion exists are
(1) all three are simple boxes with several plugs that accept cables and
(2) at times the functions of each device are rolled into one single device.
A hub, also known as a repeater, is a simple device used for years to connect all nodes, or computers, on a network to a central location. Each node on a network has a unique hardware address called a MAC address. A hub is known as a repeater because when a packet of data, or frame, is sent through the hub, it is repeated to each and every computer on the network.
A switch-based network is one that utilizes switches instead of hubs. A switch is a major upgrade to a hub. Instead of sending all network data to each and every network node, the switch will analyze the MAC address and determine where to send the data. Network bandwidth is not wasted by sending every frame to every port.
Routers not only provide connections to the internet, they also protect the LAN from the Internet. The router could block any Packet that has a destination address outside of the LAN. In short, a router can perform many of the same functions as switches and hubs, but it has address translation and filtering capabilities.
Posted by
Sunflower
at
6/30/2009 11:56:00 PM
0
comments
Labels: Explanation, Hubs, Routers, Switches
|
| Subscribe by Email |
|
Friday, June 19, 2009
Software Design - Structural Partitioning
The program structure should be partitioned both horizontally and vertically.
(1) Horizontal partitioning defines separate branches of the modular hierarchy for each major program function.
Simplest way is to partition a system into: input, data transformation (processing), and output
Advantages of horizontal partition:
- easy to test, maintain, and extend
- fewer side effects in change propagation or error propagation
Disadvantage: more data to be passed across module interfaces
- complicate the overall control of program flow
(2) Vertical partitioning suggests the control and work should be distributed top-down in program structure.
Advantages:
- good at dealing with changes:
- easy to maintain the changes
- reduce the change impact and and propagation
Posted by
Sunflower
at
6/19/2009 11:05:00 PM
0
comments
Labels: Design, Explanation, Software
|
| Subscribe by Email |
|
What is Software Architecture ?
Software architecture is the hierarchical structure of program components and their interactions. One goal of software design is to derive an architectural rendering of a system. This rendering serves as a framework from which more detailed design activities are conducted.
Set of properties of architecture design are:
-Structural properties:
The architecture design defines the system components and their interactions.
- Extra-functional properties:
The architecture design should address how the design architecture achieves requirements for performance, capacity, reliability, adaptability, security.
- Families of related systems:
The architecture design should draw upon repeatable patterns in the design of families of similar systems.
Different architectural design methods:
- Structural models: represent architecture as an organized collection of components.
- Framework models: increase the level of design abstraction by identifying repeatable architecture design frameworks (patterns).
- Dynamic models: address the behavior aspects of the program architecture.
- Process models: focus on the design of the business or technical process.
- Functional models: can be used to represent the functional hierarchy of a system.
Posted by
Sunflower
at
6/19/2009 11:03:00 PM
0
comments
Labels: Architecture, Definition, Explanation, Software
|
| Subscribe by Email |
|
Thursday, May 7, 2009
A brief summary of design engineering
Design Engineering is a process used by software engineers which encompass the set of principles, concepts and practices that result in the development of a high quality system or product. Design Engineering is the point which actually has a great role in determining the quality of the software, and a careful review of the design process is useful in ensuring that the quality of the software remains high. Software design serves as the foundation for all software engineering steps that follow regardless of which process model is being employed. Without a proper design we risk building an unstable system – one that will fail when small changes are made (and we all know how likely small (or even big) changes can happen, one that may be difficult to test; one whose quality cannot be assessed until late in the software process, perhaps when critical deadlines are approaching and much capital has already been invested into the product. Making changes later down in the cycle to compensate for problems in the design process is not guaranteed to succeed, and is expensive.
Steps Involved In Design Engineering:
1. Identifying the need.
2. Defining the problem.
3. Conducting Research.
4. Narrowing Research
5. Analyzing set criteria
6. Finding alternative solutions
7. Analyzing possible solutions
8. Making a decision.
9. Presenting the product.
10. Communicating & selling the product.
During the design process the software specifications are transformed into design models that describe the details of the data structures, system architecture, interface, and components. Each design product is reviewed for quality before moving to the next phase of software development. At the end of the design process a design specification document is produced. This document is composed of the design models that describe the data, architecture, interfaces and components.
Posted by
Ashish Agarwal
at
5/07/2009 10:55:00 PM
1 comments
Labels: Design, Engineering, Explanation, Processes, Software, Summary
|
| Subscribe by Email |
|
Tuesday, December 23, 2008
Difference between various software testing terms
Here are some similar sounding terms that confuse most people. We need to get more clarity on what the difference between these terms is, so here is an attempt to do that. The Difference Between Quality Assurance, Quality Control, And Testing, explained below.
A large number of people are confused about the difference between quality assurance (QA), quality control (QC), and testing. These terms are closely related, but they are essentially different concepts and we need to understand the difference between them. Their being difference does not minimize the importance of all of them, and since all three are critical to managing the risks of developing and maintaining software, it is important for software managers to understand the differences. The definition of these terms is below:
• Quality Assurance: Defined as a set of activities designed to ensure that the development and/or maintenance process is adequate to ensure a system will meet its objectives.
• Quality Control: Defined as a set of activities designed to evaluate a developed work product.
• Testing: The process of executing a system with the intent of finding defects, including all the necessary planning for the testing, and just does not mean the actual execution of test cases.
QA activities ensure that the process is defined and appropriate. Methodology and standards development are examples of QA activities. A QA review would focus on the process elements of a project - such as whether the requirements are being defined at the proper level of detail. In contrast, QC activities focus on finding defects in specific deliverables - e.g., are the defined requirements the right requirements. Testing is one example of a QC activity, but there are others such as inspections. Both QA and QC activities are generally required for successful software development.
There can be disagreements over who should be responsible for QA and QC activities -- i.e., whether a group external to the project management structure should have responsibility for either QA or QC. The correct answer will vary depending on the situation, but here are some suggestions:
• While line management can and should have the primary responsibility for implementing the appropriate QA, QC and testing activities on a project, an external QA function can provide valuable expertise and perspective, and his help is in most cases, beneficial.
• There is no right value for the the amount of external QA/QC, more like it should be a function of the project risk and the process maturity of an organization. As organizations mature, management and staff will implement the proper QA and QC approaches as a matter of habit and as a result, the need for external guidance reduces, with review being more relevant.
Posted by
Ashish Agarwal
at
12/23/2008 10:57:00 PM
0
comments
Labels: Explanation, Processes, Terms, Testing
|
| Subscribe by Email |
|
Tuesday, December 9, 2008
Some testing definitions
Some definitions of key testing terms:
What is software 'quality'?
Trying to attain software quality implies being able to meet the following goals: reasonably bug-free, delivered on time and within budget, meets requirements and/or expectations, and is maintainable. It is not easy to objectively define quality. It will depend on who the 'customer' is and their overall influence in the scheme of things. if you were to take a holistic view of the customers, you would involve the following people: end-users, customer acceptance testers, customer contract officers, customer management, the development organization's management/accountants/testers/salespeople, future software maintenance engineers, stockholders, magazine columnists, etc. Each type of 'customer' will have their own slant on 'quality' - the accounting department might define quality in terms of profits while an end-user might define quality as user-friendly and bug-free.
What is the 'software life cycle'?
A software life cycle is one of the most popular terms that a person working in software is expected to know. The life cycle begins when an application is first conceived and ends when it is no longer in use. The various in-between parts of the life cycle is enough to fill a separate book, but as a first level, the terms includes aspects such as initial concept, requirements analysis, functional design, internal design, documentation planning, test planning, coding, document preparation, integration, testing, maintenance, updates, retesting, phase-out, and other aspects.
What is 'Software Quality Assurance'?
Software QA involves the entire software development paradigm from beginning to end - monitoring and improving the process, making sure that any agreed-upon standards and procedures are followed, and ensuring that problems are found and dealt with. It is oriented to 'prevention', to ensuring that such processes are defined that make it more difficult to get into problems.
What is 'Software Testing'?
When a software is written by developers, it is a given that there will be sections that will not be working properly. Testing involves operation of a system or application under controlled conditions and evaluating the results (eg, 'if the user is in interface A of the application while using hardware B, and does C, then D should happen'). The controlled conditions should include both normal and abnormal conditions, and can cover a wide gamut of activities. Testing should intentionally attempt to make things go wrong to determine if things happen when they shouldn't or things don't happen when they should. It is oriented to 'detection'.
Posted by
Ashish Agarwal
at
12/09/2008 11:39:00 PM
0
comments
Labels: Explanation, Learn, Terms, Testing
|
| Subscribe by Email |
|