Object-Oriented Programming (C++)

Chapter 12
Industrial, Urban and Consumer Applications

Bachelors Program in Computer Science Engineering
Object-Oriented Programming (C++)   •   Post Graduate

Industrial, Urban and Consumer Applications

Introduction and Context

Object-oriented programming (OOP) becomes especially valuable when software must represent complex physical processes, organizations, devices, services, and user interactions. Industrial automation, urban infrastructure, and consumer products contain many interacting entities: sensors, machines, vehicles, buildings, users, payments, controllers, alerts, and external services. C++ is widely used in these domains because it combines abstraction mechanisms with predictable performance, direct hardware access, mature tooling, and support for real-time and resource-constrained systems.

The central challenge is not simply to write a program that works once. Industrial, urban, and consumer software must often satisfy simultaneous requirements for performance, reliability, safety, security, maintainability, interoperability, and long operational life. An object-oriented design must therefore connect domain concepts to computational structures without hiding critical timing, memory, or failure behavior.

This chapter examines how C++ object-oriented principles are applied in three application environments:

  • industrial systems such as robotics, process control, manufacturing execution, and predictive maintenance;
  • urban systems such as intelligent transport, energy management, waste management, and public safety; and
  • consumer systems such as embedded appliances, vehicles, wearable devices, multimedia products, and connected-home platforms.

The chapter treats OOP as an engineering discipline rather than merely a collection of language features. The emphasis is on architecture, design decisions, real-time behavior, safety, governance, and the trade-offs involved in using abstraction in operational systems.

Learning Objectives

After completing this chapter, a student should be able to:

  1. Explain why C++ and OOP are suitable for industrial, urban, and consumer applications.
  2. Model physical and organizational entities as cohesive classes and components.
  3. Apply abstraction, encapsulation, inheritance, polymorphism, composition, and generic programming appropriately.
  4. Design event-driven and layered C++ systems that interact with sensors, actuators, networks, and databases.
  5. Distinguish hard real-time, soft real-time, safety-critical, mission-critical, and ordinary application requirements.
  6. Evaluate design patterns and concurrency approaches for operational software.
  7. Analyze reliability, cybersecurity, privacy, safety, and regulatory concerns.
  8. Develop and critically assess an object-oriented architecture for a realistic application scenario.

1. Application Domains and Their Engineering Constraints

1.1 Industrial applications

Industrial software operates machines and processes whose failures may damage equipment, interrupt production, or endanger people. Examples include programmable robotic cells, numerical-control machines, refinery monitoring, warehouse automation, medical manufacturing, and power-generation systems.

Industrial software commonly has the following properties:

  • deterministic or bounded response time;
  • continuous acquisition of sensor data;
  • command of actuators and machinery;
  • integration with programmable logic controllers (PLCs), supervisory control and data acquisition (SCADA), and manufacturing execution systems (MES);
  • long deployment lifetimes and strict change-control procedures;
  • traceability of alarms, commands, configuration changes, and maintenance actions.

In such systems, a convenient abstraction is not automatically a good abstraction. A virtual function call may be acceptable in a supervisory application but inappropriate inside a highly constrained interrupt path. Similarly, dynamic memory allocation may be harmless in a configuration tool but dangerous in a long-running control loop because allocation latency and fragmentation may be difficult to bound.

1.2 Urban applications

Urban computing coordinates infrastructure distributed across geographical areas. Intelligent transportation systems, traffic-signal coordination, smart parking, water distribution, public lighting, emergency response, and environmental monitoring are representative examples.

Urban systems are generally heterogeneous and networked. They combine edge devices, communication networks, cloud services, geographic information systems, mobile applications, and administrative databases. The software must tolerate intermittent connectivity, inaccurate sensors, different equipment vendors, changing policies, and large variations in demand.

A traffic-management platform, for example, may receive vehicle counts from cameras, loop detectors, connected vehicles, and public-transport systems. Its decisions may affect congestion, emissions, emergency-vehicle priority, and public safety. Consequently, the system requires both technical correctness and institutional accountability.

1.3 Consumer applications

Consumer software is embedded in products used by large and diverse populations. Examples include smart televisions, cameras, home appliances, game consoles, wearable devices, automobiles, and mobile-connected products.

Consumer applications emphasize responsiveness, usability, battery life, cost, privacy, updateability, and product differentiation. A device may contain a resource-constrained microcontroller, a real-time operating system, a graphical user interface, wireless communication, and a cloud companion service. The same conceptual product therefore often contains multiple C++ subsystems with different timing and reliability requirements.

2. Translating Domains into Object-Oriented Models

2.1 From physical entities to software responsibilities

An object-oriented model should not be a literal inventory of every noun in a requirements document. A class should exist because it owns data, enforces an invariant, provides behavior, or represents a stable boundary between components.

For example, a manufacturing cell can be represented by classes such as Robot, Conveyor, SafetyGate, Workpiece, and CellController. A poor design may expose all internal variables and permit any component to alter machine state. A stronger design gives each class a narrow responsibility:

class SafetyGate {
public:
    void open();
    void close();
    bool isClosed() const noexcept;
private:
    bool closed_{false};
};

class Robot {
public:
    bool moveTo(Position target);
    void stop();
    RobotState state() const noexcept;
private:
    RobotState state_{RobotState::Idle};
};

The example is intentionally incomplete: a production system would require interlocks, diagnostics, authorization, and verified motion control. Its design point is that operations are expressed through meaningful interfaces rather than unrestricted field access.

2.2 Encapsulation and invariants

Encapsulation places representation behind an interface and ensures that an object cannot be placed into an invalid state through ordinary use. An invariant is a condition that must remain true whenever an object is observable.

A TemperatureReading class might reject impossible values, record the measurement unit, and preserve the time at which the reading was acquired. A Vehicle class might prevent a transition directly from Decommissioned to Moving. Such constraints are more reliable when enforced by the class itself rather than by every caller.

Resource Acquisition Is Initialization (RAII) is a particularly important C++ form of encapsulation. A resource is acquired during object construction and released during destruction. Standard library types such as std::unique_ptr, std::lock_guard, and file-stream classes implement this principle. RAII reduces leaks and ensures cleanup when exceptions or early returns occur.

2.3 Composition over inheritance

Composition constructs a system from objects that collaborate. Inheritance expresses an “is-a” relationship and is most appropriate when substitutability is genuine. A ThermalCamera may implement a Sensor interface, but a TrafficSystem does not necessarily need to inherit from Database, Map, or Network merely because it uses them.

Composition is often preferable in operational systems because it permits replacement of hardware drivers, communication protocols, and policies without changing the domain model.

class Sensor {
public:
    virtual ~Sensor() = default;
    virtual Measurement read() = 0;
};

class MonitoringService {
public:
    explicit MonitoringService(std::unique_ptr<Sensor> sensor)
        : sensor_(std::move(sensor)) {}

    Measurement sample() { return sensor_->read(); }
private:
    std::unique_ptr<Sensor> sensor_;
};

The service depends on the abstraction Sensor, while a physical sensor, simulator, or test double can provide the implementation. This supports dependency inversion and testability.

2.4 Polymorphism and its costs

Runtime polymorphism allows one interface to refer to multiple implementations. It is useful when the concrete type must vary at run time, as in selecting a CAN, Ethernet, or wireless communication driver. However, virtual dispatch introduces a small run-time cost and may complicate worst-case timing analysis.

Compile-time polymorphism through templates can provide zero- or low-overhead abstraction:

template <typename SensorType>
class Sampler {
public:
    explicit Sampler(SensorType& sensor) : sensor_(sensor) {}
    auto acquire() { return sensor_.read(); }
private:
    SensorType& sensor_;
};

Templates improve static verification and performance but can increase compilation time, code size, and diagnostic complexity. The choice between runtime and compile-time polymorphism should follow deployment constraints rather than stylistic preference.

3. Architectural Models for Operational C++ Systems

3.1 Layered architecture

A common architecture separates hardware access, infrastructure, domain logic, and presentation or integration:

LayerTypical responsibilityExample C++ elements
Hardware abstractionRegister, bus, and device accessGPIO, CAN, Modbus drivers
InfrastructureTiming, storage, networking, loggingThread pools, repositories, message clients
DomainRules and state transitionsBoiler, Route, Payment, Alarm
ApplicationUse cases and orchestrationControllers, services, workflows
InterfaceHuman or external-system interactionGUI, REST adapter, mobile gateway

The domain layer should not depend directly on a particular database or user-interface toolkit. Ports and adapters, also called hexagonal architecture, make these dependencies explicit. A MaintenanceRepository interface can be implemented by a SQL repository in production and an in-memory repository in tests.

3.2 Event-driven architecture

Industrial and urban systems naturally generate events: a temperature limit is exceeded, a bus arrives, a door opens, or a payment is authorized. An event-driven design represents changes as messages and allows independent components to subscribe.

Events should be immutable value objects where possible. An event may contain an identifier, event type, timestamp, source, measured value, quality indicator, and correlation identifier. Time semantics must be explicit: device time, gateway time, and server time may differ. Systems that require ordering should use sequence numbers or a defined clock strategy rather than assuming network arrival order equals physical occurrence order.

3.3 State machines

Many devices and services are best represented by finite-state machines. A washing machine, railway crossing, robotic cell, and payment terminal all have legal states and transitions.

For a state machine, let the system state at step t be xt, input event be et, and transition function be δ. The transition is:

xt+1 = δ(xt, et)

This notation is applicable when the next state is determined by the current state and event, possibly together with additional guarded data. A transition table should identify permitted transitions, guards, actions, and failure behavior. Explicit state modeling prevents invalid combinations of Boolean flags such as isRunning, isOpen, and isFaulted.

3.4 Data-oriented considerations

OOP models behavior and responsibility, but high-throughput systems may also require data-oriented design. Sensor streams are often processed more efficiently when homogeneous values are stored contiguously rather than scattered among many heap-allocated objects. C++ permits a hybrid approach: domain objects can govern policies while packed arrays and views support efficient numerical processing.

The design should be evaluated using measurements. Cache behavior, allocation frequency, lock contention, and message latency should be profiled rather than guessed.

4. Real-Time, Reliability, and Concurrency

4.1 Timing categories

Hard real-time means that missing a deadline is a system failure. Soft real-time means that deadline misses reduce quality but are not necessarily catastrophic. Safety-critical systems require that hazards be controlled to an acceptable level; they are not defined merely by speed. A factory dashboard may be soft real-time, while an emergency braking controller may have hard timing and safety requirements.

A periodic task with period T must complete before its next release under the relevant scheduling assumptions. For a simple single-processor utilization estimate, if task i has execution time Ci and period Ti, utilization is:

U = ∑i=1n Ci / Ti

Here Ci and Ti must use the same time unit, so U is dimensionless. This is only a preliminary workload measure. It does not by itself prove schedulability; priorities, blocking, release jitter, overhead, and scheduling policy must also be analyzed. For example, if three tasks require 2 ms every 10 ms, 1 ms every 20 ms, and 4 ms every 100 ms, then U = 2/10 + 1/20 + 4/100 = 0.19, or 19%. The remaining capacity is not automatically available because operating-system and communication overheads must be included.

4.2 Concurrency mechanisms

C++ supports threads, mutexes, condition variables, atomics, futures, and coroutines. The mechanism should reflect the problem:

  • use message passing when ownership and isolation are more important than shared access;
  • use mutexes to protect small, clearly defined critical sections;
  • use atomics for simple shared state when the memory-ordering requirements are understood;
  • use lock-free structures only when measurement and correctness justify their complexity;
  • avoid blocking operations in interrupt handlers and hard real-time paths.

A data race is not merely a logical conflict; in C++, unsynchronized conflicting accesses can produce undefined behavior. Deadlocks can be reduced by consistent lock ordering, narrow critical sections, timeouts, and ownership-based resource management.

4.3 Fault handling and observability

Operational systems should distinguish transient faults, degraded operation, and unrecoverable faults. Exceptions can express failures in ordinary application code, but some embedded or safety-oriented environments restrict exceptions. Regardless of mechanism, a failure policy must specify detection, containment, recovery, logging, notification, and safe state.

Logs should be structured and include timestamps, severity, component identity, correlation identifiers, and relevant context. Sensitive data must not be written indiscriminately. Metrics such as message latency, sensor-quality rate, queue depth, restart count, and actuator faults support diagnosis and capacity planning.

5. Industrial Applications

5.1 Robotics and manufacturing cells

A robotic cell typically coordinates robot motion, fixtures, conveyors, machine tools, safety devices, and production recipes. Object-oriented design separates equipment drivers from cell-level orchestration. A recipe can describe operations without embedding vendor-specific commands. A driver translates domain commands into a robot protocol.

Safety must dominate convenience. Software interlocks should complement, not replace, certified physical safeguards. A command such as moveTo() should verify authorization, operating mode, gate status, emergency-stop state, and workspace constraints. The system should fail to a defined safe state when critical communication or sensor validation fails.

5.2 Predictive maintenance

Predictive maintenance combines sensor acquisition, signal processing, historical data, and maintenance workflows. A C++ edge component may calculate vibration features locally to reduce bandwidth, while a server-side service performs model inference and schedules work orders.

A useful design separates:

  • acquisition objects, which collect raw readings;
  • feature-extraction components, which transform signals;
  • diagnostic models, which estimate condition;
  • policy objects, which map condition to action; and
  • maintenance records, which preserve evidence and accountability.

Machine-learning output should be treated as evidence rather than an unquestionable command. Thresholds, confidence, model version, data quality, and human review should be recorded.

5.3 Process control

A process-control application may model a plant as interacting equipment and control loops. A simplified proportional controller is:

u(t) = Kp e(t)

where e(t) = r(t) − y(t) is the difference between the desired value r(t) and measured output y(t), Kp is the proportional gain, and u(t) is the control command. This equation is applicable only as a simplified proportional component; actuator limits, sampling, delays, integral action, derivative action, stability, and anti-windup may be essential in a real controller. The software should make units and saturation behavior explicit.

6. Urban Applications

6.1 Intelligent transportation

A transport platform may contain Vehicle, Route, Stop, SignalController, Incident, and PassengerInformation objects. It must integrate real-time events with relatively stable reference data. A route-planning component should not directly manipulate signal hardware; instead, a traffic-policy service issues authorized recommendations to a signal-control adapter.

Urban systems also require fairness analysis. A congestion policy that improves average travel time may disadvantage certain neighborhoods or mobility-impaired users. Performance measures should therefore include reliability, accessibility, emissions, emergency response, and distributional effects rather than a single average.

6.2 Smart energy and water systems

Energy-management software coordinates meters, distributed generation, storage, demand-response policies, and tariffs. Water systems monitor pressure, flow, quality, pumps, reservoirs, and leakage. These are cyber-physical systems: software decisions have physical consequences, while physical uncertainty affects software behavior.

A robust model represents measurement quality explicitly. A reading should be distinguishable from a missing, stale, estimated, or out-of-range reading. Treating all numeric values as equally trustworthy can cause unsafe or economically harmful decisions.

6.3 Urban data governance

City platforms process location traces, video, household consumption, and service requests. Data minimization, purpose limitation, access control, retention limits, encryption, and auditability are essential. A technically successful system can still be socially unacceptable if residents cannot understand how data are used or challenge automated decisions.

7. Consumer Applications

7.1 Embedded products

A connected appliance may use a microcontroller for sensor and actuator control, a processor for user interaction, and cloud services for remote access. C++ classes can represent capabilities such as TemperatureSensor, Compressor, DoorLock, NetworkSession, and UpdateManager.

The product lifecycle is critical. Secure boot, signed firmware, rollback protection, vulnerability response, and long-term update support should be designed from the beginning. A device that cannot be updated safely may create security and environmental problems after sale.

7.2 User experience and accessibility

Encapsulation and state machines help maintain consistent behavior, but consumer quality also depends on clear feedback. A device should communicate whether an action succeeded, is pending, or failed. Accessibility requires support for different physical abilities, languages, sensory conditions, and connectivity circumstances.

7.3 Automotive and wearable systems

Vehicles and wearables combine real-time sensing, wireless connectivity, power management, and safety or health implications. A wearable health estimate should expose uncertainty and should not be presented as a clinical diagnosis unless appropriately validated and regulated. Automotive software must isolate safety-related functions from entertainment and external connectivity domains.

8. Design Patterns and C++ Techniques

Several patterns recur in these application domains:

PatternApplicationPrincipal caution
AdapterConvert a vendor device protocol to a domain interfaceDo not hide important failure semantics
StrategySelect routing, control, pricing, or diagnostic policyValidate policy changes
Observer or publish-subscribeDistribute sensor and status eventsControl subscription lifetime and back pressure
StateRepresent legal operating modesDefine illegal events and recovery
FactoryConstruct hardware- or configuration-specific objectsAvoid uncontrolled global factories
RepositoryIsolate persistence from domain logicPreserve transaction and consistency requirements
CommandQueue, authorize, log, and undo operationsEnsure replay safety and authorization

Modern C++ best practices include value semantics where practical, const correctness, strong types for units and identifiers, smart pointers for ownership, scoped locks, checked conversions, and static analysis. A strong type can prevent accidental mixing of metres and seconds or a user identifier and a device identifier.

Testing should include unit tests, property-based tests, integration tests with hardware simulators, fault-injection tests, timing tests, security tests, and field trials. Mocking is useful but cannot replace tests involving actual schedulers, networks, electromagnetic conditions, sensor errors, and power interruptions.

9. Illustrative Case Study: Municipal Adaptive Street Lighting

This is a fictional illustrative case, designed to demonstrate engineering reasoning rather than report a real deployment.

Background

A municipality operates 8,000 street lights. The existing system uses fixed schedules, leading to unnecessary energy use during low-traffic periods. The proposed platform uses motion sensors, ambient-light sensors, lamp controllers, a wireless mesh, and a central management service.

Problem

The municipality wants to reduce energy consumption while preserving road safety, emergency visibility, maintainability, and resident privacy. Wireless connectivity is intermittent, and lamps from three manufacturers expose different protocols.

Analysis

The system has several distinct responsibilities:

  1. A device layer reads sensors and controls dimming hardware.
  2. An edge policy component determines a local lighting level when communication is unavailable.
  3. A gateway aggregates status and forwards events.
  4. A central service manages schedules, firmware, alarms, and reports.
  5. An administrative interface authorizes policy changes.

A single monolithic class would mix hardware protocols, lighting policy, network communication, and user authorization. Such coupling would make testing and vendor replacement difficult.

Approach and solution

The design uses a LampController interface with manufacturer-specific adapters. LightingPolicy is a strategy object that receives validated observations and returns a desired level. LampState is an explicit state machine with states such as Off, Dimmed, Full, Faulted, and Maintenance. A command object records who requested a change, the old policy version, the new policy version, and the time of authorization.

The edge controller applies a conservative local policy if the gateway is unavailable. Motion events are aggregated locally rather than transmitting continuous individual movement traces. The system records sensor quality, lamp faults, policy versions, and overrides. Firmware is signed, and update rollout is staged so that a fault does not disable every lamp simultaneously.

Outcome

In an evaluation period, the design is expected to reduce energy use while maintaining a configurable minimum illumination response. The exact saving cannot be asserted without field measurements because it depends on lamp efficiency, traffic patterns, weather, seasonal daylight, policy parameters, and fault rates. The architecture nevertheless supports measurement through energy meters, response-time logs, illumination surveys, and incident reports.

Learning points

  • Local autonomy is essential when network availability is not guaranteed.
  • Hardware abstraction supports multi-vendor deployment.
  • Privacy can be improved by processing events at the edge and minimizing retained data.
  • Policy, authorization, and audit records are part of the software design, not administrative afterthoughts.
  • Energy optimization must be evaluated together with safety and equity.

10. Ethical, Regulatory, and Governance Considerations

Industrial, urban, and consumer systems can affect employment, mobility, safety, privacy, and access to essential services. Developers should identify stakeholders beyond the purchaser: operators, residents, maintenance workers, vulnerable users, and people affected indirectly by automated decisions.

Safety cases should connect hazards to requirements, design controls, verification evidence, and operational procedures. Cybersecurity should address authentication, authorization, secure communication, secrets management, vulnerability handling, least privilege, and incident response. Privacy engineering should minimize collection, separate identity from telemetry where possible, and provide retention and deletion mechanisms consistent with applicable law.

Artificial intelligence is increasingly integrated into inspection, traffic prediction, demand forecasting, and consumer interfaces. Its use requires attention to training-data quality, drift, explainability appropriate to the decision, human override, false-positive and false-negative costs, and model update governance. A model should not silently change the behavior of a safety-relevant system without validation and approval.

11. Contemporary Developments and Best Practices

Current systems increasingly combine edge computing, digital twins, containerized services, 5G or private wireless networks, secure hardware, and machine learning. These technologies are useful when they solve a defined operational problem. A digital twin should be maintained as a model with known assumptions and calibration status, not treated as a perfect copy of reality.

Recommended practices include:

  1. Begin with hazards, use cases, quality attributes, and measurable acceptance criteria.
  2. Define ownership and invariants for every important object.
  3. Prefer composition, explicit interfaces, and dependency injection.
  4. Keep hardware, domain policy, persistence, and presentation concerns separate.
  5. Make time, units, quality, and failure states explicit.
  6. Bound memory use and latency where operational requirements demand it.
  7. Use static analysis, sanitizers, code review, and automated testing continuously.
  8. Test degraded operation, network loss, stale sensors, power interruption, and malicious input.
  9. Record configuration, software versions, commands, and relevant evidence.
  10. Measure real performance and energy use before optimizing.
  11. Design secure and maintainable update mechanisms before deployment.
  12. Include human factors, accessibility, privacy, and social impact in acceptance criteria.

Chapter Summary

Industrial, urban, and consumer applications illustrate the practical value and limitations of object-oriented C++. Classes can represent equipment, services, measurements, policies, and users, but effective design depends on responsibility, invariants, and explicit system boundaries. Encapsulation protects state; composition supports flexibility; polymorphism separates interfaces from implementations; RAII manages resources; and templates can provide efficient compile-time abstraction.

Operational systems require more than functional correctness. Real-time behavior, fault containment, observability, concurrency, security, safety, privacy, and updateability must be treated as architectural concerns. Layered, event-driven, port-and-adapter, and state-machine designs are particularly useful for cyber-physical environments. C++ permits both high-level domain modeling and low-level control, but abstractions must be evaluated against timing, memory, certification, and maintainability requirements.

The most responsible design is one that delivers measurable operational value while remaining understandable, testable, secure, governable, and safe for the people and environments it affects.

Key Terms

Encapsulation: Restricting direct access to representation while exposing controlled operations.

Abstraction: Representing essential behavior while hiding irrelevant implementation detail.

Polymorphism: Allowing one interface to support multiple implementations.

Composition: Building a component from collaborating objects.

RAII: C++ resource-management technique that ties resource lifetime to object lifetime.

Invariant: A condition that must remain true for a valid object or system state.

Cyber-physical system: A system in which software interacts with physical processes.

Hard real-time: A timing regime in which a missed deadline constitutes failure.

Soft real-time: A timing regime in which deadline misses degrade service quality.

State machine: A model of states, events, guards, and permitted transitions.

Event-driven architecture: An architecture in which components communicate through events.

Hardware abstraction: An interface that hides device-specific implementation details.

Dependency injection: Supplying a component’s dependencies from outside the component.

Interlock: A condition that prevents an unsafe operation.

Observability: The ability to understand internal system behavior through logs, metrics, and traces.

Edge computing: Processing data near the devices or physical source that produces it.

Predictive maintenance: Using condition data to anticipate failures or maintenance needs.

Digital twin: A computational model associated with a physical asset or process.

Safety case: Structured evidence that a system is acceptably safe for its intended use.

Data minimization: Collecting and retaining only the data necessary for a defined purpose.

Review Questions

Short Answer Questions

  1. Why is C++ frequently selected for industrial and embedded applications?
  2. Distinguish composition from inheritance in the design of a device platform.
  3. What is the purpose of an explicit state machine?
  4. Define hard real-time behavior and give one application example.
  5. Why should sensor quality be represented separately from a sensor’s numeric value?

Long Answer Questions

  1. Explain how layered architecture and dependency inversion improve maintainability in a municipal infrastructure system.
  2. Discuss the benefits and limitations of runtime polymorphism and template-based polymorphism in real-time C++ software.
  3. Describe the major design concerns in an object-oriented robotic manufacturing cell.
  4. Explain how concurrency, fault handling, and observability should be designed in an urban sensing platform.
  5. Analyze the ethical, privacy, safety, and cybersecurity responsibilities of a connected consumer product manufacturer.

Analytical / Application Questions

  1. Design a class and component architecture for an automated warehouse containing robots, storage locations, orders, safety zones, and a maintenance service. Justify where you use interfaces, composition, state machines, and event messages.
  2. A smart-water system receives flow readings from unreliable sensors and controls pumps remotely. Develop a failure-handling strategy for stale readings, network loss, contradictory measurements, and unauthorized commands.
  3. Evaluate the fictional adaptive street-lighting case using at least five measurable criteria. Explain how you would determine whether energy savings were achieved without reducing safety, privacy, accessibility, or service equity.

Multiple Choice Questions with Answers

Question 1

Which design principle most directly allows a manufacturing service to use different sensor implementations without changing its domain logic?

A. Dependency inversion through an abstract sensor interface

B. Public exposure of all sensor data members

C. Replacement of composition with global variables

D. Hard-coding one vendor protocol in the domain layer

Correct Answer: A. Dependency inversion through an abstract sensor interface

Question 2

For tasks with execution times Cᵢ and periods Tᵢ, which expression gives the basic processor-utilization estimate?

A. U = ∑ Ti/Ci

B. U = ∑ Ci/Ti

C. U = ∏ CiTi

D. U = ∑ (Ci + Ti)

Correct Answer: B. U = ∑ Ci/Ti

Question 3

Why can dynamic memory allocation be problematic in a hard real-time control path?

A. It always produces incorrect numerical results

B. It prevents all forms of polymorphism

C. Its latency and fragmentation may be difficult to bound

D. It makes compilation impossible

Correct Answer: C. Its latency and fragmentation may be difficult to bound

Question 4

Which pattern is most suitable for representing legal operating modes such as Idle, Running, Faulted, and Maintenance?

A. State pattern or explicit state machine

B. Repository pattern

C. Adapter pattern only

D. Singleton pattern

Correct Answer: A. State pattern or explicit state machine

Question 5

What is a principal benefit of RAII in C++?

A. It guarantees that network connections never fail

B. It ties resource release to object lifetime

C. It eliminates the need for interfaces

D. It makes every operation hard real-time

Correct Answer: B. It ties resource release to object lifetime

Question 6

In an urban sensing system, why should a stale measurement be distinguished from a valid zero measurement?

A. Because all zero values are illegal

B. Because stale and valid values have different decision implications

C. Because timestamps are never useful

D. Because sensor values cannot be stored as numbers

Correct Answer: B. Because stale and valid values have different decision implications

Question 7

Which approach best supports operation when a street-light gateway loses network connectivity?

A. Disable every lamp until connectivity returns

B. Use a conservative local policy at the edge

C. Ignore all safety constraints

D. Wait indefinitely for a central command

Correct Answer: B. Use a conservative local policy at the edge

Question 8

What does a safety interlock primarily do?

A. Improves graphical appearance

B. Prevents an operation when required safety conditions are absent

C. Compresses historical data

D. Increases network bandwidth

Correct Answer: B. Prevents an operation when required safety conditions are absent

Question 9

Which practice best supports secure consumer-device maintenance after deployment?

A. Unsigned firmware accepted from any source

B. Permanent administrative passwords shared across devices

C. Signed updates with controlled rollout and rollback planning

D. Disabling all diagnostic records

Correct Answer: C. Signed updates with controlled rollout and rollback planning

Question 10

Why is a single average congestion measure insufficient for evaluating an urban transport policy?

A. Averages cannot be computed for transport data

B. It may hide effects on accessibility, reliability, emissions, or particular communities

C. Congestion has no relationship to travel time

D. Urban systems never require performance measures

Correct Answer: B. It may hide effects on accessibility, reliability, emissions, or particular communities

Object-Oriented Programming (C++)
Chapter 12 of 12