Page 214 - DCAP305_PRINCIPLES_OF_SOFTWARE_ENGINEERING
P. 214
Principles of Software Engineering
Notes (c) It must eventually end
(d) None of these
4. ………………techniques assist the programmer in writing effective error free programs.
(a) Computer programming (b) Modular programming
(c) Numerous programming (d) Structured programming
5. Top-down design method is easier to comprehend the solution of a smaller and less
complicated problem than to grasp the solution of a large and complex problem.
(a) True (b) False
10.3 Programming Practices
Experienced developers go after numerous programming practices or method of thumb, which
typically derived from hard-learned. The practices listed are not all-inclusive, and should not be
used without due consideration. Veteran programmers deviate from these practices on occasion,
but not with no careful consideration of the potential repercussions. Using the best programming
practice in the wrong context can cause more harm than good.
• To conserve resources, be selective in the choice of data type to ensure the size of a variable
is not excessively large.
• Keep the lifetime of variables as short as possible when the variables represent a finite
resource for which there may be contention, such as a database connection.
• Keep the scope of variables as small as possible to avoid confusion and to ensure
maintainability. Also, when maintaining legacy source code, the potential for inadvertently
breaking other parts of the code can be minimized if variable scope is limited.
• Use variables and routines for one and only one purpose. In addition, avoid creating
multipurpose routines that perform a variety of unrelated functions.
• When writing classes, avoid the use of public variables. Instead, use procedures to provide
a layer of encapsulation and also to allow an opportunity to validate value changes.
• When using objects pooled by MTS, acquire resources as late as possible and release them
as soon as possible. As such, you should create objects as late as possible, and destroy
them as early as possible to free resources.
• When using objects that are not being pooled by MTS, it is necessary to examine the
expense of the object creation and the level of contention for resources to determine when
resources should be acquired and released.
• Use only one transaction scheme, such as MTS or SQL Serve, and minimize the scope and
duration of transactions.
• Be wary of using ASP Session variables in a Web farm environment. At a minimum, do not
place objects in ASP Session variables because session state is stored on a single machine.
Consider storing session state in a database instead.
• Stateless components are preferred when scalability or performance are important. Design
the components to accept all the needed values as input parameters instead of relying
upon object properties when calling methods. Doing so eliminates the need to preserve
object state between method calls. When it is necessary to maintain state, consider using
alternative methods, such as maintaining state in a database.
208 LOVELY PROFESSIONAL UNIVERSITY