UE18CS353_OOAD_Unit3
UE18CS353_OOAD_Unit3
Unit 3
Aronya Baksy
March 2021
1 Design Principles
1.1 GRASP
• General Responsibility Assignment Software Principles (or Patterns) is a set of principles that
help in assigning responsibilities to objects.
• Responsibility: a contract/obligation to be fulfilled by a component/class/module
1.1.1 Creator
• Assign B the responsibility of creating object A if:
– Instances of B contain or aggregate instances of A
– Instances of B record instances of A
– Instances of B closely use instances of A
– Instances ofB have the initializing information for instances of A and pass it on creation
1.1.4 Controller
• Minimizing dependency between UI classes and system classes that represent system-level opera-
tions.
• The controller class receives requests from UI layer objects and then controls/coordinates with
objects of the domain layer to fulfill the request.
• The controller can be reused, can maintain the state of the use case and can control the sequence
of the activities
1
1.1.5 High Cohesion
• Merge related responsibilities into single modules. Clearly defining the purpose of a single man-
ageable unit.
• High cohesion allows for more code reuse, more understandability and maintainability.
1.1.6 Polymorphism
• Responsibility for defining the variation of behaviors based on type is assigned to the type for which
this variation happens
• Handle related but varying elements based on their type.
1.1.8 Indirection
• Avoid direct coupling between 2 classes by introducing an intermediate unit to communicate be-
tween the other units, so that the other units are not directly coupled
• Implemented in Adapter and Façade design patterns
• Identify points of predicted variation or instability; assign responsibilities to create a stable interface
around them
• Implementation: Provide an interface so that the there will be no effect on other units and then
use polymorphism to create various implementations of this interface
• Provides flexibility and more structured design
1.2 SOLID
• Just like GRASP, another set of patterns for implementing best practices/low coupling/high cohe-
sion etc
• Enables changes, makes code more flexible, maintainable, stable, and reusable
2
1.2.2 Open-Closed Principle
• A class should be open for extension but closed for modification. Also stated as: ”One should be
able to extend the class behavior without modifying it”
• Implemented using inheritance and composition. In inheritance, the base class behaviour does not
need to be touched in order to extend its behaviour using a subclass
3
– Anticipate change
– Construct readable, testable and reusable code
• Characteristics of implementation phase:
• Security breaches: consider every opportunity for a security breach in the code, e.g. buffer
overflow, SQL injection
• Effective use of computation power on host system, considering other programs also running
on that system
• Documentation about the code, and within the code (combined with machine-readable source
code)
• Optmization: Use performance analysis tools to identify slow-running sections of code, optimize
those to run faster
• Aspect-oriented languages: Allow more separation of concerns and increase modularity (e.g. basi-
cally any language you can think of)
• Object Oriented: Highest level of abstraction, developers now think of the problem in terms of
real-life objects and their behaviour (e.g. C++, Java, C#, Python, etc.)
• The cost of catching a bug at each subsequent stage increases exponentially. Hence catching bugs
ASAP is crucial.
4
2.5 Characteristics of Code
• Well structured, well designed. Not too many lines per function, lines per file, args per
function, levels of nesting and conditions
• Meaningful, descriptive but short variable names that follow consistent naming (Pascal
case, camel case or underscore prefix)
• Restrictions enforced by programming language syntax (keywords, identifier length etc.)
• Highlight dependencies in software through file organization. Logically grouped and partitioned
files, properly initialized data structures (Abstract Data Types or ADTs)
• Easy to read code with indentation, brackets (when applicable), spaces, newlines, parenthesis for
grouping,
• Well commented code. Comment should be brief and concise but not cryptic, misleading or
redundant.
2.6 Refactoring
• Improve internal structure of code without changing external behaviour
• Improve non-functional and objective attributes of the code (cyclomatic complexity, length, dupli-
cation, coupling/cohesion) that improve understandability and maintenance.
• Does not involve rewriting code, fixing bugs or changing observable interfaces.
• Improve readability, maintainability of code by removing effects of different personalities that work
on code
• Secure Programming is the practice of developing computer software in a way that guards
against the accidental introduction of security vulnerabilities. Practices involved in secure pro-
gramming are:
– Validate input from untrusted source
– Heed compiler warnings and eliminate them using analysis tools
– Default deny all permissions to all modules, unless a permission is absolutely essential for a
particular module to function properly.
– Principle of least privilege. Each process gets the most minimal set of privileges for the most
minimal amount of time that is needed to finish it’s work and nothing more
– Sanitize data sent between external components and your code.
• Programming for Testability involves the use of the following:
– Assertions identify out-of-range and inappropriate values
– Test Points are functions that set and get current module status for debugging
– Scaffolding emulates the functionality of not-yet-built features for message exchange
5
– Test harness is code written to drive incomplete objects/modules as if they were complete
– Test Stub is a function that returns a fixed value as it has not yet been implemented
– Instrumentation, aka logging
– Building test dataset
• Simplifies maintenance
• Code quality measured in terms of static code analysis results on length, insturction paths,
complexity. Metric is number of errors per KLoC
• Team Velocity measures the number of stories the team completes per sprint. It can be measured
in story points or hours, and can be used for estimation and planning.
• Throughput is the total value added work per unit time. Measured as number of tickets (i.e.
stories) completed per unit time.
• Cycle Time is the time elapsed between a team starting work on an item and completing that
work.
• Test-first: First build test harness, then write code. Ensures that developers don’t cheat by
writing tests that pass on their code only
• Code Stepping: Execute code line by line and check system state (variable values etc.) at each
time to check control flow.
• Pair Programming: Two developers, one focusing on function logic, another one on syntax and
accuracy
• Code Inspection: formal review of code in front of a review board that consists of code inspectors
6
2.8.4 Code Inspection
• Build checklist:
• Planning: Select team, venue. Make documentation and code available to inspection team in
advance.
• Inspection takes place, errors are noted, modifications are made if necessary to repair those errors.
• Re-inspection may or may not be required post the changes
• Coverage Analyzers and Debuggers: Find percentage of code that is covered by unit tests, and
locate and fix errors (e.g.: JaCoCo available with Eclipse for Java apps, Cobertura, PureCoverage)
• Wizards: automated test generation given input parameters
• Record-Playback Tools: Start a session, record a sequence of mouse and keyboard activities
and replay those later quickly and accurately (e.g.: Selenium)
• Increase productivity, increase and plan coordination among the programmers in a team and elim-
inate confusion
• In a Scrum team, SCM is the responsibility of the entire team. Max amount of automation is used
for SCM process.
• In a Scrum team, evelopers pull from central repo. Make changes in their local env, perform unit
tests, once the tests all pass then push changes to central repo.
7
3.2 Roles in SCM
• Configuration Manager: Identify config items, identify procedures for promotion and release
3.4.2 CM Directories
• The programmer’s directory is controlled by the developer only. It contains newly created or
modified CIs only
• The master directory is an entry-controlled, authorized directory used for managing current
baselines and controlling changes made to those baselines.
• The software repository is an archive for the various baselines released to the public. These are
distributed to requesting parties
3.4.3 Baseline
• A specification or product that has been formally reviewed and agreed to by responsible manage-
ment, that serves as the basis for further development, and can only be changed through formal
change control procedures
• Baselines may or may not be tied to the schedule defined in the project plan.
8
3.4.4 Branch Management
• A branch is a copy of the source code (fully or a part) within the repository. Branching is done for
the following reasons:
– Support concurrent development
– Support multiple versions of a solution
– Enables experimentation by developers without affecting the central codebase
• Merging is bringing back and integrating the changes done in branches to the working branch.
Frequent merging from related branches into the working branch helps decreasing the likelihood
and complexity of a merge conflict
• Branch strategies:
– Single working branch
– Branch by developer or workspace
– Branch by customer or organization
– Branch by module or component
9
3.4.7 Install Management
• Involves placing multiple executable files, downloading or copying from a repository.
• Could also involve downloading executable files, config files, libraries, images etc. from the internet
• Also involves interaction with the OS when requesting for resources to run the software, and
managing appropriate permissions.
• Automated install management is performed by tools like InstallShield, InstallAware, Jenkins etc.
10
3.4.11 Defect Management
• Defect is a variation between the actual behaviour of the software product and the expected business
requirements.
• Bugs are tracked and fixed using automated tools like BugZilla
• Steps in defect management:
1. Discover bug. Report it and log it into a tool with an unique ID
2. Validation, analysis, priority (critical, high, med, low)
3. Open formal request and get approval for the same.
4. Bug resolution (assignment, schedule, fix, test, report)
5. Verification by submitter of bug report. Once verified merge code
6. Update version number, plan release of the bug fix.
7. Close the process, generate report.
11