0% found this document useful (0 votes)
28 views14 pages

ANSWERS 1 SPC 2309 Component Programming Year III Supplementary & Special

Revision
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views14 pages

ANSWERS 1 SPC 2309 Component Programming Year III Supplementary & Special

Revision
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

UNIVERSITY EXAMINATION 2022/2023

EXAMINATION FOR THE DEGREE OF BACHELOR OF SCIENCE IN


COMPUTER SCIENCE

SPC 2309: Component Programming Year III Supplementary & Special

Date: Friday, 14th July 2023 Time: 1.30pm – 3.30pm Instructions

Answer Question ONE (compulsory) and Any Other Two


QUESTION ONE 30 MARKS)
a) Discuss software components in reference to component programming technology. (3
marks)

In component programming technology, software components are reusable,


self-contained units of code that encapsulate:

● Functionality: Well-defined operations or services that components offer to


other components.
● Data: The internal data structures and variables manipulated by the
component.
● Interfaces: Contracts that specify how other components can interact with the
component, promoting loose coupling.

b) Study the diagram below and answer the questions that follows

i. Outline the activities taking place in the system presented above (4 marks)

Based on the provided components, these activities likely occur:

1. User Interaction: A user interacts with the system, potentially browsing the
menu list using the "Menu List" component.
2. Order Placement: The user places an order, triggering interactions with the
"Place Order" component and possibly the "Food Database" or "Transaction
Database" for order details and storage.
3. Payment Processing: The user makes a payment using the "Payment"
component, possibly connecting to payment gateways for external processing.
4. Order Fulfillment: Upon successful payment, the system might interact with
the "Food Database" and "Delivery" components to prepare and deliver the
food.

ii. Describe the UML diagram in use (2 marks)

The diagram appears to be a conceptual representation of system components, not


a specific UML diagram type. However, it captures the essence of a Class Diagram
or Component Diagram, showing:

● Rectangles: Representing system components.


● Labels: Names of components (Food Database, Menu List, etc.).
c) Describe 3 characteristics of a component object in component programming (3 marks)
1. Encapsulation: Component objects hide their internal implementation details,
exposing functionality through well-defined interfaces. This promotes loose
coupling and prevents dependencies on internal data structures.
2. Reusability: Component objects are designed to be reused across different
applications and contexts, leading to faster development and reduced
redundancy.
3. Replaceability: Components can be replaced with functionally equivalent
components without affecting the entire system if interfaces remain consistent.
This enables flexibility and easier upgrades.
d) Using a diagram, describe a Web Services architecture outlining any two Components of
Web Services. (5 marks)

e) Explain role of interface in component model service giving a valid example (4 marks)

Example: In an online library system, you might have a Book component and a
Search component.

● The Book component encapsulates information and functionalities related to


books, but hides its internal implementation details.
● The Search component needs to find books based on certain criteria (e.g.,
title, author).
● The Book component would provide an interface called Searchable.
● This interface defines a method like searchBooks(String query) that
would allow the Search component to interact with the Book component to
find relevant books without knowing how the Book component manages its
data internally.

Advantages of Interfaces:

● Loose Coupling: Components only interact through interfaces, reducing


dependencies on specific implementations.
● Standardization: Interfaces enforce a contract that ensures compatibility
between components.
● Enhanced Maintainability: Changes to a component's implementation can
be made without affecting other components as long as the interface remains
the same.
f) Explain any three principles that govern Component Oriented Programming. (3 marks)
1. Encapsulation: As noted earlier, COP emphasizes encapsulating data and
functionality within components, promoting data protection and loose coupling.
2. Standardization: Components rely on well-defined interfaces to interact,
ensuring interoperability between components from different sources.
3. Loose Coupling: Components only depend on the functionality defined in
interfaces, not specific implementations. This allows components to be easily
replaced or upgraded without affecting the

g) Discuss using a component chart the composition of a Component Model (6 marks)

QUESTION TWO (20 MARKS)


a) Explain 2 types of interfaces in component model service. (4 marks)

In component-based systems, interfaces play a crucial role in defining how


components interact. Here are two main types of interfaces:

1. Local Interfaces:

● These interfaces exist within the same application or component model.


● They enable communication between components within an application
without external dependencies.
● Example: In a document editing application, a TextEditor component
might have a local interface named Editable that provides methods for
manipulating text. Other components within the application, like a
SpellChecker component, could interact with the TextEditor through this
interface.

2. Remote Interfaces:

● These interfaces facilitate communication between components located


across different applications or distributed systems.
● They typically rely on web service protocols like SOAP or REST for
standardized data exchange.
● Example: A travel booking application might utilize a remote interface
exposed by a flight aggregator website to retrieve flight information. This
remote interface would define methods for searching flights and obtaining
flight details, adhering to a protocol like REST.

Benefits of Interfaces:

● Loose Coupling: Components only interact through interfaces, reducing


dependencies on specific implementations and promoting maintainability.
● Standardization: Interfaces enforce a contract that ensures compatibility
between components.
● Flexibility: New components can be integrated by implementing the required
interfaces without affecting existing components.

b) Create a UML diagram that can be used to represent the organization, planning and
execution of a seminar in a university. The seminar intends to have attendance from
students and staff within the university premises in a scheduled time. The administration
will need to approve the seminar.(12marks)

Title: Seminar Organization (University)

UML Class Diagram for Seminar Organization

Classes:

● Seminar: Represents the seminar itself, encapsulating details like title,


description, date, time, location, and speaker information.
● Student: Represents a student who can register for the seminar, including
attributes like ID, name, and department.
● Staff: Represents a university staff member who can register for the seminar
or might be involved in the organization process (optional), with attributes like
ID, name, and department.
● Administration: Represents the university administration that approves or
rejects seminar proposals.
● Registration: Represents the registration process for the seminar, with
methods for handling student and staff registration (optional).

Relationships:

● Seminar -has-a-> Topic: (Optional) Represents the topic of the seminar.


● Seminar -1..*-> Student: A seminar can have many registered students.
● Seminar -1..*-> Staff: (Optional) A seminar can have many registered staff
members.
● Seminar -0..1-> Administration: A seminar can be approved or rejected by
the administration (optional).
● Registration -associates-> Seminar: The registration process is associated
with a specific seminar.
● Registration -1..*-> Student: A registration record can be linked to a student.
● Registration -1..*-> Staff: (Optional) A registration record can be linked to a
staff member.

Speaker Notes:

This UML Class Diagram depicts the key entities involved in organizing, planning,
and executing a seminar at a university. It shows that:

● A seminar has details like title, description, date, time, location, and speaker
information.
● Students and staff can register for the seminar (optional staff involvement).
● The administration may need to approve the seminar before it can be held.
● A registration process can be implemented to track student and staff
enrollments.
● The topic of the seminar can be included as an optional class.

Additional Considerations:

● You might add a Room class to represent the physical space where the
seminar will be held.
● A Schedule class could be included to manage potential conflicts with other
events.
● Consider adding a Notification class or mechanism to inform registered
participants of the seminar's approval or any updates.
● Depending on the complexity of the seminar, additional classes might be
necessary, such as Speaker and Materials to manage speaker
information and seminar materials.

c) Distinguish components and objects Giving valid examples (4 marks)

Components and Objects are fundamental concepts in object-oriented and


component-based programming. Here's how they differ:

Components

● Conceptual units of code: Represent reusable, self-contained functionality


that can be combined to build larger systems.
● Define interfaces: Expose functionalities and contract for other components
to interact with them (without revealing internal implementation details).
● Examples: A ShoppingCart component, a PaymentGateway component,
or a FlightSearch component in a travel booking application.

Objects

● Instances of classes: Represent specific data and behavior defined in a


class.

QUESTION THREE(20 MARKS)


a) Discuss three (3) properties of interfaces in component model service. (3 marks)

Interfaces in component models provide essential properties for building robust and
maintainable systems:

1. Loose Coupling: Interfaces promote loose coupling between components by


defining contracts for interaction without revealing implementation details.
Components interact through these interfaces, reducing dependencies on
specific implementations. This allows components to be replaced or upgraded
without affecting other components that rely solely on the interface.
2. Standardization: Interfaces act as standardized agreements for
communication. They specify the methods, parameters, and return types that
components can utilize. This ensures compatibility and promotes
interoperability between components from different sources. Developers can
focus on implementing the functionality defined in the interface without
worrying about internal details of the component.
3. Extensibility: Interfaces facilitate system extensibility. New components can
be integrated by implementing the defined interfaces without requiring
changes to existing components. This allows for flexible system evolution by
adding new functionalities through components that adhere to the established
interfaces.

b) Explain interface servers as contract to component technology.(3 marks)

In component technology, interface servers act as the concrete implementations of


interfaces that provide the services or functionalities promised by the interface
contract. They bridge the gap between the abstract definition provided by the
interface and the actual execution of the service.

Concept:

● An interface defines the "what" (functionalities) but not the "how"


(implementation details).
● The interface server represents the "how," containing the actual code that
implements the methods specified by the interface.
Benefits:

● Separation of Concerns: Interface servers decouple the definition of


services from their implementation. This allows for independent evolution of
interfaces and their implementations.
● Flexibility: Different implementations of an interface can exist, allowing for
selection based on performance, resource requirements, or other criteria.
● Maintainability: Changes to implementations can be made more easily
without affecting components that rely only on the interface.
c) Explain the six composition operators defined in a component infrastructure that
component software engineers can modify a component or integrate several to generate a
new component or application. (8 marks)

Component-based systems provide various operators for composing and integrating


components to build complex applications. Here's a breakdown of six common
operators:

1. Sequential Composition: Components are executed one after another,


where the output of one component becomes the input for the next.
○ Example: A "Payment Processing" component might follow a
"Checkout" component, processing the payment information after the
user selects items in the shopping cart.
2. Selection Composition: One of several components is chosen based on
specific conditions.
○ Example: An "Order Processing" component might select a "Domestic
Shipping" component or an "International Shipping" component
depending on the destination address.
3. Concurrent Composition: Components are executed simultaneously.
○ Example: A "User Registration" component might interact with a
"SendWelcomeEmail" component concurrently with saving user data in
the database.
4. Adaptation: An adapter component mediates communication between
incompatible components.
○ Example: A "LegacyDatabaseAdapter" component might allow an EJB
application to access data from a non-Java database, translating
requests and responses between incompatible formats.
5. Aggregation: A component is composed of other components, forming a
hierarchical structure.
○ Example: A "Shopping Cart" component might be made up of several
"Product" components, each representing a product item added to the
cart.
6. Delegation: A component delegates specific tasks to other components.
○ Example: A "Validation" component might delegate data validation
tasks to specific validator components for different data types (e.g.,
email validator, phone number validator).

d) Discuss three (3) characteristics of components.(6 marks)

Components are fundamental building blocks in component-based development.


They possess crucial characteristics for building modular and reusable systems:

1. Self-Contained: Components encapsulate data and functionality within


distinct boundaries. They define clear interfaces for interaction with other
components. This promotes data protection and prevents unwanted
dependencies.
2. Reusable: Components are designed to be reused across different
applications or parts of the same application. This reduces code duplication
and development time. A well-designed component should offer a well-defined
set of functionalities that can be applied in various contexts.
3. Replaceable: Components can be replaced with functionally equivalent
components as long as they adhere to the same interface. This enhances
flexibility and facilitates upgrades or integrations with alternative
implementations.
4. Standardization: Component models often define standards for interfaces,
development processes, and deployment mechanisms. This promotes
interoperability and simplifies component integration from different sources.
5. Independent (Loosely Coupled): Components interact primarily through
well-defined interfaces, minimizing dependencies on specific implementations
of other components. This promotes loose coupling and makes systems more
maintainable and adaptable.
6. Contractable: Interfaces define a contract for interaction between
components. This contract specifies the services offered, parameters
expected, and return types, ensuring clear
QUESTION FOUR (20 MARKS)
a) Use a diagram to discuss the architecture and components of the CORBA(6marks)

1. Object Request Broker (ORB): The central component that manages


communication between clients and servers. It hides the network details and
provides services like:
○ Invoking methods on remote objects.
○ Handling marshalling/unmarshalling of data between different
platforms.
○ Providing security and concurrency control.
2. Client Application: An application that uses remote objects provided by
servers. It interacts with the ORB to make requests and receive responses.
3. Server Application: An application that provides remote objects. It
implements these objects and registers them with the ORB.
4. Object Adapter (OA): A component that bridges the gap between the ORB
and server applications. It activates and deactivates objects, manages object
lifecycles, and maps between the ORB's communication protocol (IIOP) and
the server's programming language.
5. Interface Definition Language (IDL): A language for defining the interfaces
of remote objects. It specifies methods, parameters, and return types. IDL
descriptions are compiled into client and server stubs/skeletons for specific
programming languages like C++ or Java.
6. Stubs (Client-Side): Proxy objects on the client-side that act as local
representations of remote objects. They translate method calls into messages
sent to the ORB.
7. Skeletons (Server-Side): Server-side objects that receive requests from the
ORB, locate the actual object implementation, and invoke the appropriate
methods.
b) Compare and contrast between Java beans and Enterprise JavaBean.(8marks)

Java Beans:

● Simple, reusable software components that encapsulate data and provide


access methods (getters and setters) following specific conventions.
● Can be used in any Java application, not just enterprise applications.
● Focus on data representation and manipulation.
● Lightweight and easier to develop.
● Limited functionality for complex enterprise needs.

Enterprise JavaBeans (EJB):

● Built upon Java Beans, specifically designed for building distributed,


transactional enterprise applications.
● Managed by an EJB container that provides lifecycle management, security,
and transaction services.
● Three main types:
○ Session Beans: Manage short-lived conversations within a single user
session.
○ Entity Beans: Represent persistent data and provide CRUD (Create,
Read, Update, Delete) operations for database access.
○ Message-Driven Beans (MDBs): Asynchronous beans that process
messages from messaging systems like JMS (Java Message Service).
● More complex to develop and deploy compared to Java Beans.

c) Describe using examples, how a web service work.(6marks)

Scenario: A travel booking application wants to retrieve flight information from a


flight aggregator website using a web service.

1. WSDL (Web Services Description Language): The flight aggregator


website exposes a WSDL document describing its web service. This
document defines the available operations, parameters, and data formats.
2. Client Generates Code (Automatic): Most development tools automatically
generate code stubs or proxies based on the WSDL. These stubs provide
methods in your programming language (e.g., Java) that map directly to the
web service operations.
3. Client Sends Request: Your travel booking application uses the generated
code to create a request message. This message includes details like:
○ Origin city
○ Destination city
○ Travel dates
○ Number of passengers (optional)
4. SOAP or REST Communication:
○ SOAP (Simple Object Access Protocol): A more formal, XML-based
approach with defined structures for requests and responses.
○ REST (Representational State Transfer): A simpler approach based
on HTTP requests and leveraging existing web infrastructure (URLs,
methods like GET/POST).

The choice of protocol depends on the specific web service and your project
requirements.

5. Server Processes Request:


● The flight aggregator's web server receives your request message.
● It parses the message according to the WSDL and protocol specifications
(SOAP or REST) to understand the requested operation and its parameters.
6. Business Logic Execution:
● Based on the requested operation (search flights), the web service executes
its business logic on the server-side. This might involve:
○ Accessing the flight aggregator's own database of flight information.
○ Interacting with other airlines' web services to obtain real-time
availability.
7. Response Message:
● The web service generates a response message containing the search
results. This might include details like:
○ Available flights for the specified route and dates
○ Airline names
○ Departure and arrival times
○ Prices (including taxes

QUESTION FIVE(20 MARKS)


a) Describe three (3) components of EJB java architecture.

The EJB architecture consists of three primary components:

1. EJB Container: A runtime environment that manages the lifecycle of EJBs. It


provides:
○ Deployment: Loads EJBs into memory when needed.
○ Object Creation and Destruction: Creates and destroys EJB
instances as required.
○ Security: Enforces security policies for access control.
○ Transactions: Manages transaction boundaries (commit or rollback
changes).
○ Resource Management: Handles connections to databases and other
resources.
2. EJB Client: A component that interacts with EJBs. Clients can be:
○ Web applications: Utilizing servlets or JSPs to access EJBs.
○ Other EJBs: EJBs can interact with each other to create complex
workflows.
○ Standalone applications: Can use EJB client APIs to invoke EJB
methods directly.
3. EJBs (Enterprise JavaBeans): The core components that encapsulate
business logic. EJBs come in three main types:
○ Session Beans: Manage short-lived conversations within a user
session (e.g., shopping cart management).
○ Entity Beans: Represent persistent data and provide CRUD (Create,
Read, Update, Delete) operations (e.g., customer records).
○ Message-Driven Beans (MDBs): Asynchronous beans that process
messages from messaging systems (e.g., order confirmations).

b) Explain in detail about DCOM with its Architecture.


(6marks)

DCOM (Distributed Component Object Model) is a Microsoft technology that allows


software components written in different programming languages to communicate
across a network.

Architecture:

1. Clients: Applications that use DCOM components. They can be written in


various languages with DCOM support.
2. Components (COM Objects): Reusable software modules that provide
well-defined interfaces (interfaces define methods and properties). These
components can be:
○ In-Process Servers: Run in the same process space as the client.
○ Out-of-Process Servers: Run in a separate process space on the
same machine or a remote machine.
3. Interface Definition Language (IDL): A language for defining component
interfaces, similar to CORBA's IDL. IDL descriptions are compiled to
language-specific stubs and skeletons.
4. COM Runtime: Provides services for creating, managing, and invoking COM
objects:
○ Stub (Client-Side): Marshals method calls and data into network
packets before sending them to the server.
○ Skeleton (Server-Side): Unmarshals network packets, locates the
actual component implementation, and invokes the requested method.
○ The Moniker Service: Manages object references (monikers) that
encapsulate location information for accessing remote components.
5. OLE (Object Linking and Embedding): A technology built on top of COM
that allows embedding and linking of objects within documents or applications.
c) Discuss in detail about Black Box component framework.
(6 Marks)

A Black-Box component framework promotes component reuse by treating


components as opaque entities whose internal implementation details are hidden.
Developers interact with components solely through their interfaces, allowing for
independent development and deployment.

Benefits:

● Loose Coupling: Components are loosely coupled, as their internal workings


are not exposed. This reduces dependencies and simplifies system
integration.
● Reusability: Black-Box components can be reused across different
applications without knowledge of their internal code, promoting code reuse
and reducing development time.
● Maintainability: Changes to a component's internal implementation don't
affect clients as long as the interface remains the same. This simplifies
maintenance and upgrades.

Drawbacks:

● Limited Debugging: It can be challenging to debug issues within Black-Box


components, as developers cannot directly access the internal code.
● Performance Overhead: Communication through interfaces might introduce
minor performance overhead compared to tightly coupled components.

Examples:

● Many popular libraries and frameworks like Java's Swing components or


Spring framework components can be considered Black-Box components.
● Third-party libraries providing functionalities like image processing, data
encryption, or network communication often follow a Black-Box approach.

d) Use a diagram to describe the elements of a component model.


(2 marks)
e) Choose and describe one category of component model services.
i. Suns Microsystems Javabean.
(4 marks)
ii. Enterprise Java Beans.

Description:

Enterprise JavaBeans (EJB) are a category of component model services built upon
Java Beans specifically designed for developing distributed, transactional enterprise
applications. They offer features beyond basic Java Beans to address the needs of
complex enterprise systems.

Key Characteristics:

● Managed by an EJB Container: The EJB container provides lifecycle


management, security, and transaction services for EJBs, freeing developers
from these concerns.
● Three Main Types:
○ Session Beans: Manage short-lived conversations within a single user
session (e.g., shopping cart management).
○ Entity Beans: Represent persistent data and provide CRUD (Create,
Read, Update, Delete) operations for database access (e.g., customer
records).
○ Message-Driven Beans (MDBs): Asynchronous beans that process
messages from messaging systems (e.g., order confirmations).
● Security and Transactions: EJBs inherently support security for access
control and transaction management to ensure data consistency across
operations.
● Remote Invocation: EJBs can be accessed from distributed clients using
protocols like RMI (Remote Method Invocation) or web services protocols
(SOAP, REST).

Benefits:

● Faster Development: Pre-built functionalities and container management


features can accelerate development compared to writing everything from
scratch.
● Scalability and Manageability: EJBs enable building scalable and
manageable enterprise systems with features like transaction handling and
resource pooling.
● Reusability: EJBs promote component reuse within an enterprise
environment.

Comparison with Java Beans:

● Java Beans are simpler and lightweight, suitable for general use in any Java
application.
● EJBs are more complex and designed specifically for enterprise applications
with features like transactions and container management.

In conclusion, Enterprise Java Beans (EJB) offer robust functionalities for building
distributed, transactional enterprise applications. Their managed lifecycle, security,
and transaction support make them a valuable choice for complex systems
development within the Java ecosystem.

You might also like