Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 OBJECT-ORIENTED PROGRAMMING Visual Basic provides full support encapsulation, inheritance, and polymorphism. for object-oriented programming including Encapsulation means that a group of related properties, methods, and other members are treated as a single unit or object. Inheritance describes the ability to create new classes based on an existing class. Polymorphism means that you can have multiple classes that can be used interchangeably, even though each class implements the same properties or methods in different ways. This section describes the following concepts: • Classes and objects ➢ Class members 1) Properties and fields 2) Methods 3) Constructors 4) Destructors 5) Events 6) Nested classes ➢ Access modifiers and access levels 1) Instantiating classes 2) Shared classes and members 3) Anonymous types ➢ Inheritance 1) Overriding members 2) Interfaces 3) Generics 4) Delegates CLASSES AND OBJECTS The terms class and object are sometimes used interchangeably, but in fact, classes describe the type of objects, while objects are usable instances of classes. So, the act of creating an object is called instantiation. Using the blueprint analogy, a class is a blueprint, and an object is a building made from that blueprint. To define a class: VB Class SampleClass End Class Visual Basic also provides a light version of classes called structures that are useful when you need to create large array of objects and do not want to consume too much memory for that. To define a structure: VB Structure SampleStructure End Structure Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 CLASS MEMBERS Each class can have different class members that include properties that describe class data, methods that define class behavior, and events that provide communication between different classes and objects. To define a field: VB Class SampleClass Public SampleField As String End Class Properties have “get” and “set” procedures, which provide more control on how values are set or returned. Visual Basic allows you either to create a private field for storing the property value or use so-called auto-implemented properties that create this field automatically behind the scenes and provide the basic logic for the property procedures. To define an auto-implemented property: VB Class SampleClass Public Property SampleProperty as String End Class If you need to perform some additional operations for reading and writing the property value, define a field for storing the property value and provide the basic logic for storing and retrieving it: VB Class SampleClass Private m_Sample As String Public Property Sample() As String Get ' Return the value stored in the field. Return m_Sample End Get Set(ByVal Value As String) ' Store the value in the field. m_Sample = Value End Set End Property End Class Most properties have methods or procedures to both set and get the property value. However, you can create read-only or write-only properties to restrict them from being modified or read. In Visual Basic you can use ReadOnly and WriteOnly keywords. However, autoimplemented properties cannot be read-only or write-only. METHODS A method is an action that an object can perform. Note: In Visual Basic, there are two ways to create a method: the Sub statement is used if the method does not return a value; the Function statement is used if a method returns a value. Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 To define a method of a class: VB Class SampleClass Public Function SampleFunc(ByVal SampleParam As String) ' Add code here End Function End Class A class can have several implementations, or overloads, of the same method that differ in the number of parameters or parameter types. To overload a method: VB Overloads Sub Display(ByVal theChar As Char) ' Add code that displays Char data. End Sub Overloads Sub Display(ByVal theInteger As Integer) ' Add code that displays Integer data. End Sub In most cases you declare a method within a class definition. However, Visual Basic also supports extension methods that allow you to add methods to an existing class outside the actual definition of the class. CONSTRUCTORS Constructors are class methods that are executed automatically when an object of a given type is created. Constructors usually initialize the data members of the new object. A constructor can run only once when a class is created. Furthermore, the code in the constructor always runs before any other code in a class. However, you can create multiple constructor overloads in the same way as for any other method. To define a constructor for a class: VB Class SampleClass Sub New(ByVal s As String) // Add code here. End Sub End Class DESTRUCTORS Destructors are used to destruct instances of classes. In the .NET Framework, the garbage collector automatically manages the allocation and release of memory for the managed objects in your application. However, you may still need destructors to clean up any unmanaged resources that your application creates. There can be only one destructor for a class. EVENTS Events enable a class or object to notify other classes or objects when something of interest occurs. The class that sends (or raises) the event is called the publisher and the classes that receive (or handle) the event are called subscribers. For more information about events, how they are raised and handled, see Events. ➢ To declare events, use the Event Statement. Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 ➢ To raise events, use the RaiseEvent Statement. ➢ To specify event handlers using a declarative way, use the WithEvents statement and the Handles clause. ➢ To be able to dynamically add, remove, and change the event handler associated with an event, use the AddHandler Statement and RemoveHandler Statement together with the AddressOf Operator. NESTED CLASSES A class defined within another class is called nested. By default, the nested class is private. VB Class Container Class Nested ' Add code here. End Class End Class To create an instance of the nested class, use the name of the container class followed by the dot and then followed by the name of the nested class: VB Dim nestedInstance As Container.Nested = New Container.Nested() ACCESS MODIFIERS AND ACCESS LEVELS All classes and class members can specify what access level they provide to other classes by using access modifiers.The following access modifiers are available: Visual Basic Modifier Definition Public The type or member can be accessed by any other code in the same assembly or another assembly that references it. Private The type or member can only be accessed by code in the same class. Protected The type or member can only be accessed by code in the same class or in a derived class. Friend The type or member can be accessed by any code in the same assembly, but not from another assembly. Protected Friend The type or member can be accessed by any code in the same assembly, or by any derived class in another assembly. INSTANTIATING CLASSES To create an object, you need to instantiate a class, or create a class instance. VB Dim sampleObject as New SampleClass() After instantiating a class, you can assign values to the instance's properties and fields and invoke class methods. Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 VB ' Set a property value. sampleObject.SampleProperty = "Sample String" ' Call a method. sampleObject.SampleMethod() To assign values to properties during the class instantiation process, use object initializers: VB Dim sampleObject = New SampleClass With {.FirstProperty = "A", .SecondProperty = "B"} SHARED CLASSES AND MEMBERS A shared member of the class is a property, procedure, or field that is shared by all instances of a class. To define a shared member: VB Class SampleClass Public Shared SampleString As String = "Sample String" End Class To access the shared member, use the name of the class without creating an object of this class: VB MsgBox(SampleClass.SampleString) Shared modules in Visual Basic have shared members only and cannot be instantiated. Shared members also cannot access non-shared properties, fields or methods. ANONYMOUS TYPES Anonymous types enable you to create objects without writing a class definition for the data type. Instead, the compiler generates a class for you. The class has no usable name and contains the properties you specify in declaring the object. To create an instance of an anonymous type: VB ' sampleObject is an instance of a simple anonymous type. Dim sampleObject = New With {Key .FirstProperty = "A", .SecondProperty = "B"} INHERITANCE Inheritance enables you to create a new class that reuses, extends, and modifies the behavior that is defined in another class. The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class. However, all classes in Visual Basic implicitly inherit from the Object class that supports .NET class hierarchy and provides low-level services to all classes. Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 Note: Visual Basic doesn't support multiple inheritance. That is, you can specify only one base class for a derived class. To inherit from a base class: VB Class DerivedClass Inherits BaseClass End Class By default, all classes can be inherited. However, you can specify whether a class must not be used as a base class, or create a class that can be used as a base class only. To specify that a class cannot be used as a base class: VB NotInheritable Class SampleClass End Class To specify that a class can be used as a base class only and cannot be instantiated: VB MustInherit Class BaseClass End Class OVERRIDING MEMBERS By default, a derived class inherits all members from its base class. If you want to change the behavior of the inherited member, you need to override it. That is, you can define a new implementation of the method, property or event in the derived class. The following modifiers are used to control how properties and methods are overridden: Visual Basic Modifier Definition Overridable Allows a class member to be overridden in a derived class. Overrides Overrides a virtual (overridable) member defined in the base class. Notoverridable Prevents a member from being overridden in an inheriting class. Mustoverride Requires that a class member to be overridden in the derived class. Shadows Hides a member inherited from a base class INTERFACES Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes. An interface represents a contract, in that a class that implements an interface must implement every aspect of that interface exactly as it is defined. Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 To define an interface: VB Public Interface ISampleInterface Sub DoSomething() End Interface To implement an interface in a class: VB Class SampleClass Implements ISampleInterface Sub DoSomething ' Method implementation. End Sub End Class GENERICS Classes, structures, interfaces and methods in .NET can include type parameters that define types of objects that they can store or use. The most common example of generics is a collection, where you can specify the type of objects to be stored in a collection. To define a generic class: VB Class SampleGeneric(Of T) Public Field As T End Class To create an instance of a generic class: VB Dim sampleObject As New SampleGeneric(Of String) sampleObject.Field = "Sample string" DELEGATES A delegate is a type that defines a method signature, and can provide a reference to any method with a compatible signature. You can invoke (or call) the method through the delegate. Delegates are used to pass methods as arguments to other methods. Note: Event handlers are nothing more than methods that are invoked through delegates. For more information about using delegates in event handling, see Events. To create a delegate: VB Delegate Sub SampleDelegate(ByVal str As String) Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 To create a reference to a method that matches the signature specified by the delegate: VB Class SampleClass ' Method that matches the SampleDelegate signature. Sub SampleSub(ByVal str As String) ' Add code here. End Sub ' Method that instantiates the delegate. Sub SampleDelegateSub() Dim sd As SampleDelegate = AddressOf SampleSub sd("Sample string") End Sub End Class Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 Software Testing and Quality WHAT IS QA IN SOFTWARE TESTING? In the past, quality assurance testing has generally been brought into process relatively late in the development cycle. For example, in Waterfall, the software is produced and passed along to the QA team, who offer feedback, then send the software back to development so they can fix the problems. Quality Assurance in Software Testing is defined as a procedure to ensure the quality of software products or services provided to the customers by an organization. Quality assurance focuses on improving the software development process and making it efficient and effective as per the quality standards defined for software products. Quality Assurance is popularly known as QA Testing. In an Agile environment, everyone, including the Quality Assurance Team, works collaboratively to make improvements on an ongoing basis. Yet, as developers, operators, and testers embrace a shared responsibility for making sure they deliver a high-quality end product, QA often struggles to find its place. Automated software testing adds another layer of complexity to the mix, which brings up an important question: what is quality assurance (QA) testing and how does it fit into today’s fastpaced development process? WHAT IS QUALITY ASSURANCE TESTING? Quality assurance testing is quality assurance (QA) or a quality testing process that ensures that an organization delivers the best products or services possible.QA aims to deliver consistent results through a set of standardized procedures, which means that organizations also need to make sure that their processes for achieving the desired results hit specific quality benchmarks themselves. In brief, you might say that QA includes all activities that center around implementing standards and procedures associated with ensuring that software meets a certain set of requirements before it’s released to the public. The key thing to keep in mind is that QA doesn’t involve the actual testing of products. Instead, it focuses on the procedures to ensure the best outcome. QA activities are ultimately process oriented. HOW TO DO QUALITY ASSURANCE: COMPLETE PROCESS Quality Assurance methodology has a defined cycle called PDCA cycle or Deming cycle. The phases of this cycle are: • • • • Plan - Organization should plan and establish the process related objectives and determine the processes that are required to deliver a high-Quality end product. Do - Development and testing of Processes and also "do" changes in the processes Check - Monitoring of processes, modify the processes, and check whether it meets the predetermined objectives Act - A Quality Assurance tester should implement actions that are necessary to achieve improvements in the processes Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 Quality Assurance Process These above steps are repeated to ensure that processes followed in the organization are evaluated and improved on a periodic basis. Let's look into the above QA Process steps in detail. An organization must use Quality Assurance to ensure that the product is designed and implemented with correct procedures. This helps reduce problems and errors, in the final product. WHAT IS QUALITY CONTROL? Quality Control, or QC, is a software engineering process, typically used to ensure the quality of the products or services. It’s a bit different than QA, in that, where quality assurance is about the process, quality control examines the quality of the end products. QC consists of product-oriented activities that focus on the final outcome. The objective of quality control is to ensure the product design meets the requirements and specifications of the customers. It is a Software Engineering process used to ensure quality in a product or a service. It does not deal with the processes used to create a product; rather it examines the quality of the "end products" and the final outcome. The main aim of Quality control is to check whether the products meet the specifications and requirements of the customer. If an issue or problem is identified, it needs to be fixed before delivery to the customer. QC also evaluates people on their quality level skill sets and imparts training and certifications. This evaluation is required for the service-based organization and helps provide "perfect" service to the customers. If QC should find an issue with the end product, it ideally should be resolved before the end-customer receives the final product. To put it simply, QC includes everything involved in making sure that a product or service meets the standard quality requirements and the demands of customers. It involves testing the effectiveness and outcomes of an actual product, such as executing software after the software development process to find and fix defects before making it publicly available. The activities of quality control are product oriented. WHAT IS TESTING? Testing refers to the actual testing of a product to meet QC standards. This may involve using or stress testing the product or seeing if the actual service results match the expected results. The process identifies problems in the product or service before it goes live. In software testing, this ensures the identification of errors, bugs, and defects in software. Testing software involves executing a software component to evaluate its properties. Testing activities are also product oriented. Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 TESTING, QUALITY ASSURANCE, AND QUALITY CONTROL Most people get confused when it comes to pin down the differences among Quality Assurance, Quality Control, and Testing. Although they are interrelated and to some extent, they can be considered as same activities, but there exist distinguishing points that set them apart. The following table lists the points that differentiate QA, QC, and Testing. Quality Assurance Quality Control Testing QA includes activities that ensure the implementation of processes, procedures and standards in context to verification of developed software and intended requirements. It includes activities that ensure the verification of a developed software with respect to documented (or not in some cases) requirements. It includes activities that ensure the identification of bugs/error/defects in a software. Focuses on processes and procedures rather than conducting actual testing on the system. Focuses on actual testing by executing the software with an aim to identify bug/defect through implementation of procedures and process. Focuses on actual testing. Process-oriented activities. Product-oriented activities. Product-oriented activities. Preventive activities. It is a corrective process. It is a preventive process. It is a subset of Software Test Life Cycle (STLC). QC can be considered as the subset of Quality Assurance. Testing is the subset of Quality Control. AUDIT AND INSPECTION Audit − It is a systematic process to determine how the actual testing process is conducted within an organization or a team. Generally, it is an independent examination of processes involved during the testing of a software. As per IEEE, it is a review of documented processes that organizations implement and follow. Types of audit include Legal Compliance Audit, Internal Audit, and System Audit. Inspection − It is a formal technique that involves formal or informal technical reviews of any artifact by identifying any error or gap. As per IEEE94, inspection is a formal evaluation technique in which software requirements, designs, or codes are examined in detail by a person or a group other than the author to detect faults, violations of development standards, and other problems. Formal inspection meetings may include the following processes: Planning, Overview Preparation, Inspection Meeting, Rework, and Follow-up. TESTING AND DEBUGGING Testing − It involves identifying bug/error/defect in a software without correcting it. Normally professionals with a quality assurance background are involved in bugs identification. Testing is performed in the testing phase. Debugging − It involves identifying, isolating, and fixing the problems/bugs. Developers who code the software conduct debugging upon encountering an error in the code. Debugging is a part of White Box Testing or Unit Testing. Debugging can be performed in the development phase while conducting Unit Testing or in phases while fixing the reported bugs. Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 DIFFERENCE BETWEEN QUALITY CONTROL AND QUALITY ASSURANCE? Sometimes, QC is confused with the QA. Quality control is to examine the product or service and check for the result. Quality Assurance in Software Engineering is to examine the processes and make changes to the processes which led to the end-product. Quality Control Vs Quality Assurance Examples of QC and QA activities are as follows: QUALITY CONTROL ACTIVITIES WALKTHROUGH TESTING INSPECTION CHECKPOINT REVIEW QUALITY ASSURANCE ACTIVITIES Quality Audit Defining Process Tool Identification and selection Training of Quality Standards and Processes The above activities are concerned with Quality Assurance and Control mechanisms for any product and not essentially software. With respect to software • • QA becomes SQA (Software Quality Assurance) QC becomes Software Testing. Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 DIFFERENCES BETWEEN SQA AND SOFTWARE TESTING Following table explains on differences between SQA and Software Testing: SQA Software quality assurance is about engineering process that ensures quality SOFTWARE TESTING Software testing is to test a product for problems before the product goes live Involves activities related to the implementation of processes, procedures, and standards. Example audits training Involves actives concerning verification of product example - review testing Process focused Preventive technique Product focused Corrective technique Proactive measure Reactive measure The scope of SQA applied to all products that will be created by the organization The scope of software testing applies to a particular product being tested. BEST PRACTICES FOR QUALITY ASSURANCE: • • • • • • • Create a Robust Testing Environment Select release criteria carefully Apply automated testing to high-risk areas to save money. It helps to fasten the entire process. Allocate Time Appropriately for each process It is important to prioritize bugs fixes based on software usage Form dedicated security and performance testing team Simulate customer accounts similar to a production environment QUALITY ASSURANCE FUNCTIONS: There are 5 primary Quality Assurance Functions: 1. Technology transfer: This function involves getting a product design document as well as trial and error data and its evaluation. The documents are distributed, checked and approved 2. Validation: Here validation master plan for the entire system is prepared. Approval of test criteria for validating product and process is set. Resource planning for execution of a validation plan is done. 3. Documentation: This function controls the distribution and archiving of documents. Any change in a document is made by adopting the proper change control procedure. Approval of all types of documents. 4. Assuring Quality of products 5. Quality improvement plans QUALITY ASSURANCE CERTIFICATIONS: There are several certifications available in the industry to ensure that Organizations follow Standards Quality Processes. Customers make this as qualifying criteria while selecting a software vendor. Tomboc, Angelo G. BS CoE – 3 Software Design Research Work #2 May 7, 2021 ISO 9000 This standard was first established in 1987, and it is related to Quality Management Systems. This helps the organization ensure quality to their customers and other stakeholders. An organization who wishes to be certified as ISO 9000 is audited based on their functions, products, services and their processes. The main objective is to review and verify whether the organization is following the process as expected and check whether existing processes need improvement. This certification helps • • • • Increase the profit of the organization Improves Domestic and International trade Reduces waste and increase the productivity of the employees Provide Excellent customer satisfaction CMMI LEVEL The Capability Maturity Model Integrated (CMMI) is a process improvement approach developed specially for software process improvement. It is based on the process maturity framework and used as a general aid in business processes in the Software Industry. This model is highly regarded and widely used in Software Development Organizations. CMMI has 5 levels. An organization is certified at CMMI level 1 to 5 based on the maturity of their Quality Assurance Mechanisms. • • • • • Level 1 - Initial: In this stage the quality environment is unstable. Simply, no processes have been followed or documented Level 2 - Repeatable: Some processes are followed which are repeatable. This level ensures processes are followed at the project level. Level 3 - Defined: Set of processes are defined and documented at the organizational level. Those defined processes are subject to some degree of improvement. Level 4 - Managed: This level uses process metrics and effectively controls the processes that are followed. Level 5 - Optimizing: This level focuses on the continuous improvements of the processes through learning & innovation. CONCLUSION: Quality Assurance is to check whether the product developed is fit for use. For that, Organization should have processes and standards to be followed which need to be improved on a periodic basis. It concentrates mainly on the quality of product/service that we are providing to the customers during or after implementation of software.