It is a question from a book called Essentials of Software Engineering 4th editi
ID: 3742745 • Letter: I
Question
It is a question from a book called Essentials of Software Engineering 4th edition
Chapter 1 Exercises 1.7
2) What sequence of activities did you observe in considering the programming effort discussed in this chapter?
1.4.1 A Few Pointers on Implementation Although software engineering tends to focus more on requirements analysis, design, and processes rather than implementation, a bad implementation will definitely mean a bad program even if all the other pieces are perfect. Although for simple programs almost anything will do, following a few simple rules will generally make all your programming easier. Here we will discuss only a few language-independent rules, and point you to other books in the References and Suggested Readings section at the end of this chapter. The most important rule is to be consistent—especially in your choice of names, capitalization, and programming conventions. If you are programming alone, the particular choice of conventions is not important as long as you are consistent. You should also try to follow the established conventions of the programming language you are using, even if it would not otherwise be your choice. This will ensure that you do not introduce two conventions. For example, it is established practice in Java to start class names with uppercase letters and variable names with lowercase letters. If your name has more than one word, use capitalization to signal the word boundaries. This results in names such as FileClass and fileVariable. In C, the convention is to use lowercase almost exclusively and to separate with an underscore. Thus, when we program in C, we follow the C conventions. The choice of words for common operations is also dictated by convention. For example, printing, displaying, showing, or echoing a variable are some of the terminologies meaning similar actions. Language conventions also provide hints as to default names for variables, preference for shorter or longer names, and other issues. Try to be as consistent as possible in your choice, and follow the conventions for your language. Choose names carefully. In addition to being consistent in naming, try to make sure names for functions and variables are descriptive. If the names are too cumbersome or if a good name cannot be easily found, that is usually a sign that there may be a problem in the design. A good rule of thumb is to choose long, descriptive names for things that will have global scope such as classes and public methods. Use short names for local references, which are used in a very limited scope such as local variables, private names, and so on. Test before using a function or method. Make sure that it works. That way if there are any errors, you know that they are in the module you are currently writing. Careful unit testing, with test cases written before or after the unit, will help you gain confidence in using that unit. Know thy standard library. In most modern programming languages, the standard library will implement many common functions, usually including sorting and collections of data, database access, utilities for web development, networking, and much more. Don’t reinvent or reimplement the wheel. Using the standard libraries will save extra work, make the code more understandable, and usually run faster with fewer errors, because the standard libraries are well debugged and optimized. Keep in mind that many exercises in introductory programming classes involve solving classic problems and implementing well-known data structures and algorithms. Although they are a valuable learning exercise, that does not mean you should use your own implementations in real life. For our sample programming problem, Java has a sorting routine that is robust and fast. Using it instead of writing your own would save time and effort and produce a better implementation. We will still implement our own for the sake of illustration but will also provide the implementation using the Java sorting routine. If possible, perform a review of your code. Software reviews are one of the most effective methods for reducing defects in software. Showing your code to other people will help detect not just functionality errors but also inconsistencies and bad naming. It will also help you learn from the other person’s experience. This is another habit that does not blend well with school projects. In most such projects, getting help from another student might be considered cheating. Perhaps the code can instead be reviewed after it is handed in. Reviews are good for school assignments as well as for real-world programs.
Explanation / Answer
This chapter tells us that Software engineering tends to focus on the requirement analysis,design and processes.
Software engineering also tells that a bad implementation can happen only when
- we write a bad program ,even if all the other pieces are perfect.
While writing a simple program there are certain rules that needs to be followed ,so as to avoid a bad implementation.
Every programming language independently has its own rules and programming conventions.
We should always try to be consistent - especially in case of names, capitalization, and programming conventions.
Suppose for example Java is a programming language which follows certains rules :
1. class names should start with uppercase letters.
2. variable names should start with lowercase letters
3. if variable name has more than one word, use capitalization to signal the word boundaries.
(example - String fullName)
Conventions for "C" programming language is different , they are as follows :
1. variable names should start with lowercase almost exclusively and to separate with an underscore
(example - String full_Name)
In any programming language to perform certain operations there are conventions that are followed.
Example for print a value in java programming language - System.out.print("Hello world") is used.
for print a value in C programming language - printf("Hello world")
In any programming language, we should follow conventions and should be consistent. Suppose for example we should choose variable "names" very carefully so that they are as meaningful as possible.This consistency should also be applied in "function" name .
The best practice are as follows :
1. choose descriptive names for things that have global scope ,such as classes and public methods.
2. we should use short names for local references, which are used in a very limited scope such as local variables, private names.
3. We should test before using a function or method so that modules are working correctly.
4. We should carefully write test cases for a unit testing,this will help us gain confidence in using that unit.
5. All the standard library should be known to us.
6. In any modern programming languages, the standard library will implement many common functions, usually including sorting and collections of data, database access, utilities for web development, networking.
7. We should not write our own techniques for this ,as using the standard libraries will save extra work, make the code more understandable, and usually run faster with fewer errors, because the standard libraries are well debugged and optimized.
Points to remember :- many exercises in introductory programming classes involve solving classic problems and implementing well-known data structures and algorithms, they are a valuable learning exercise and using our
own implementations should be avoided.
For Example, Java has sorting routine that is robust and fast ,using it instead of writing our own would save time and effort and produce a better implementation.
8. We should always review of our code.
9. Software reviews are one of the most effective methods for reducing defects in software.
10. We should share our code to other people which will help detect not just functionality errors but also inconsistencies and bad naming. It will also help us learn from the other person’s experience.
11. The above practice of code sharing and getting reviewed from other, when follow in school projects is considered
to be cheating.
12. We should always remember, reviews are good for school assignments as well as for real-world programs.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.